Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QABACKLOG-1610: Return the last SAM response when waitUntilSAMStatusGreen fails on timeout #80

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions fixtures/graphql/sam/healthStatus.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ query($severity: GqlProbeSeverity) {
health
message
}
probes(health: YELLOW) {
name
status {
health
message
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jahia/cypress",
"version": "3.21.2",
"version": "3.22.0",
"scripts": {
"build": "tsc",
"lint": "eslint src -c .eslintrc.json --ext .ts"
Expand Down
4 changes: 3 additions & 1 deletion src/utils/SAMHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => {
let greenCount = 0;
let lastGraphqlResponse = {};
cy.waitUntil(() =>
cy.apollo({
fetchPolicy: 'no-cache',
Expand All @@ -19,13 +20,14 @@ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, in
}
}).then(result => {
const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
lastGraphqlResponse = result?.data?.admin?.jahia?.healthCheck;
if (healthStatus) {
greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
return greenCount >= greenMatchCount;
}
}),
{
errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}`,
errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}. Last GraphQL response: ${JSON.stringify(lastGraphqlResponse)}`,
timeout: timeout,
verbose: true,
interval: interval
Expand Down
Loading