Skip to content

Commit

Permalink
TECH-1844: Added a method to wait until SAM returns green (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fgerthoffert committed Jun 13, 2024
1 parent 130a1c0 commit 9847d87
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
12 changes: 12 additions & 0 deletions fixtures/graphql/sam/healthStatus.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query($severity: GqlProbeSeverity) {
admin {
jahia {
healthCheck(severity: $severity) {
status {
health
message
}
}
}
}
}
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.19.4",
"version": "3.20.0",
"scripts": {
"build": "tsc",
"lint": "eslint src -c .eslintrc.json --ext .ts"
Expand Down
22 changes: 22 additions & 0 deletions src/utils/SAMHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 1000) : void => {
cy.waitUntil(() =>
cy.apollo({
fetchPolicy: 'no-cache',
queryFile: 'graphql/sam/healthStatus.graphql',
variables: {
severity: severity
}
}).then(result => {
const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
if (healthStatus) {
return healthStatus.health === 'GREEN';
}
}),
{
errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}`,
timeout: timeout,
verbose: true,
interval: interval
});
};

1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './VanityUrlHelper';
export * from './ClusterHelper';
export * from './JahiaPlatformHelper';
export * from './GraphQLHelper';
export * from './SAMHelper';

0 comments on commit 9847d87

Please sign in to comment.