From 1e9365692548288812abfdd7ffae0161579ab6f1 Mon Sep 17 00:00:00 2001 From: "Francois G." Date: Tue, 27 Aug 2024 19:14:08 +0200 Subject: [PATCH] QABACKLOG-1610: Return the last SAM response when waitUntilSAMStatusGreen fails on timeout --- fixtures/graphql/sam/healthStatus.graphql | 7 +++++++ package.json | 2 +- src/utils/SAMHelper.ts | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fixtures/graphql/sam/healthStatus.graphql b/fixtures/graphql/sam/healthStatus.graphql index c1983c2..b1e7a1c 100644 --- a/fixtures/graphql/sam/healthStatus.graphql +++ b/fixtures/graphql/sam/healthStatus.graphql @@ -6,6 +6,13 @@ query($severity: GqlProbeSeverity) { health message } + probes(health: YELLOW) { + name + status { + health + message + } + } } } } diff --git a/package.json b/package.json index 0f2f253..2b0d0e8 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/utils/SAMHelper.ts b/src/utils/SAMHelper.ts index 50ea47b..b76c5cc 100644 --- a/src/utils/SAMHelper.ts +++ b/src/utils/SAMHelper.ts @@ -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', @@ -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