@jahia/cypress 3.20.0 → 3.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export declare const waitUntilSAMStatusGreen: (severity?: string, timeout?: number, interval?: number) => void;
1
+ export declare const waitUntilSAMStatusGreen: (severity?: string, timeout?: number, interval?: number, greenMatchCount?: number) => void;
@@ -1,10 +1,22 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
3
  exports.waitUntilSAMStatusGreen = void 0;
4
- var waitUntilSAMStatusGreen = function (severity, timeout, interval) {
4
+ /*
5
+ When Jahia is starting or performing provisioning operations
6
+ it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.
7
+
8
+ The primary use of this method is to wait until a Jahia platform stabilizes after a startup or
9
+ provisioning operation.
10
+
11
+ Instead of waiting only for one occurence of a GREEN status, this function will wait until the a
12
+ GREEN status was returned a number of consecutive times (greenMatchCount).
13
+ */
14
+ var waitUntilSAMStatusGreen = function (severity, timeout, interval, greenMatchCount) {
5
15
  if (severity === void 0) { severity = 'MEDIUM'; }
6
16
  if (timeout === void 0) { timeout = 60000; }
7
- if (interval === void 0) { interval = 1000; }
17
+ if (interval === void 0) { interval = 500; }
18
+ if (greenMatchCount === void 0) { greenMatchCount = 10; }
19
+ var greenCount = 0;
8
20
  cy.waitUntil(function () {
9
21
  return cy.apollo({
10
22
  fetchPolicy: 'no-cache',
@@ -16,7 +28,8 @@ var waitUntilSAMStatusGreen = function (severity, timeout, interval) {
16
28
  var _a, _b, _c, _d;
17
29
  var healthStatus = (_d = (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.admin) === null || _b === void 0 ? void 0 : _b.jahia) === null || _c === void 0 ? void 0 : _c.healthCheck) === null || _d === void 0 ? void 0 : _d.status;
18
30
  if (healthStatus) {
19
- return healthStatus.health === 'GREEN';
31
+ greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
32
+ return greenCount >= greenMatchCount;
20
33
  }
21
34
  });
22
35
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.20.0",
3
+ "version": "3.20.1",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -1,4 +1,15 @@
1
- export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 1000) : void => {
1
+ /*
2
+ When Jahia is starting or performing provisioning operations
3
+ it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.
4
+
5
+ The primary use of this method is to wait until a Jahia platform stabilizes after a startup or
6
+ provisioning operation.
7
+
8
+ Instead of waiting only for one occurence of a GREEN status, this function will wait until the a
9
+ GREEN status was returned a number of consecutive times (greenMatchCount).
10
+ */
11
+ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => {
12
+ let greenCount = 0;
2
13
  cy.waitUntil(() =>
3
14
  cy.apollo({
4
15
  fetchPolicy: 'no-cache',
@@ -9,7 +20,8 @@ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, in
9
20
  }).then(result => {
10
21
  const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
11
22
  if (healthStatus) {
12
- return healthStatus.health === 'GREEN';
23
+ greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
24
+ return greenCount >= greenMatchCount;
13
25
  }
14
26
  }),
15
27
  {