Skip to content

Commit 49d67b8

Browse files
authored
QABACKLOG-1610: Return the last SAM response when waitUntilSAMStatusGreen fails on timeout (#80)
1 parent 6ec0cef commit 49d67b8

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

fixtures/graphql/sam/healthStatus.graphql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ query($severity: GqlProbeSeverity) {
66
health
77
message
88
}
9+
probes(health: YELLOW) {
10+
name
11+
status {
12+
health
13+
message
14+
}
15+
}
916
}
1017
}
1118
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jahia/cypress",
3-
"version": "3.21.2",
3+
"version": "3.22.0",
44
"scripts": {
55
"build": "tsc",
66
"lint": "eslint src -c .eslintrc.json --ext .ts"

src/utils/SAMHelper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => {
1212
let greenCount = 0;
13+
let lastGraphqlResponse = {};
1314
cy.waitUntil(() =>
1415
cy.apollo({
1516
fetchPolicy: 'no-cache',
@@ -19,13 +20,14 @@ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, in
1920
}
2021
}).then(result => {
2122
const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
23+
lastGraphqlResponse = result?.data?.admin?.jahia?.healthCheck;
2224
if (healthStatus) {
2325
greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
2426
return greenCount >= greenMatchCount;
2527
}
2628
}),
2729
{
28-
errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}`,
30+
errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}. Last GraphQL response: ${JSON.stringify(lastGraphqlResponse)}`,
2931
timeout: timeout,
3032
verbose: true,
3133
interval: interval

0 commit comments

Comments
 (0)