diff --git a/package.json b/package.json index c7532ad..c76adf1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jahia/cypress", - "version": "3.20.0", + "version": "3.20.1", "scripts": { "build": "tsc", "lint": "eslint src -c .eslintrc.json --ext .ts" diff --git a/src/utils/SAMHelper.ts b/src/utils/SAMHelper.ts index c067d20..50ea47b 100644 --- a/src/utils/SAMHelper.ts +++ b/src/utils/SAMHelper.ts @@ -1,4 +1,15 @@ -export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 1000) : void => { +/* + When Jahia is starting or performing provisioning operations + it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses. + + The primary use of this method is to wait until a Jahia platform stabilizes after a startup or + provisioning operation. + + Instead of waiting only for one occurence of a GREEN status, this function will wait until the a + GREEN status was returned a number of consecutive times (greenMatchCount). +*/ +export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => { + let greenCount = 0; cy.waitUntil(() => cy.apollo({ fetchPolicy: 'no-cache', @@ -9,7 +20,8 @@ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, in }).then(result => { const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status; if (healthStatus) { - return healthStatus.health === 'GREEN'; + greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0; + return greenCount >= greenMatchCount; } }), {