@jahia/cypress 3.19.4 → 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,5 +1,6 @@
1
+ declare type Workspace = 'EDIT' | 'LIVE';
1
2
  export declare const setNodeProperty: (pathOrId: string, property: string, value: string | Array<string>, language: string) => Cypress.Chainable;
2
- export declare const deleteNode: (pathOrId: string) => Cypress.Chainable;
3
+ export declare const deleteNode: (pathOrId: string, workspace?: Workspace) => Cypress.Chainable;
3
4
  export declare const deleteNodeProperty: (pathOrId: string, property: string, language: string) => Cypress.Chainable;
4
5
  export declare const addNode: (variables: {
5
6
  parentPathOrId: string;
@@ -9,7 +10,8 @@ export declare const addNode: (variables: {
9
10
  children?: any[];
10
11
  mixins?: any[];
11
12
  }) => Cypress.Chainable;
12
- export declare const getNodeByPath: (path: string, properties?: string[], language?: string, childrenTypes?: string[], workspace?: 'EDIT' | 'LIVE') => Cypress.Chainable;
13
+ export declare const getNodeByPath: (path: string, properties?: string[], language?: string, childrenTypes?: string[], workspace?: Workspace) => Cypress.Chainable;
13
14
  export declare const getNodeAcl: (path: string) => Cypress.Chainable;
14
15
  export declare const moveNode: (pathOrId: string, destParentPathOrId: string, destName?: string) => Cypress.Chainable;
15
16
  export declare const getNodeTypes: (filter?: {}) => Cypress.Chainable;
17
+ export {};
@@ -17,10 +17,12 @@ var setNodeProperty = function (pathOrId, property, value, language) {
17
17
  });
18
18
  };
19
19
  exports.setNodeProperty = setNodeProperty;
20
- var deleteNode = function (pathOrId) {
20
+ var deleteNode = function (pathOrId, workspace) {
21
+ if (workspace === void 0) { workspace = 'EDIT'; }
21
22
  return cy.apollo({
22
23
  variables: {
23
- pathOrId: pathOrId
24
+ pathOrId: pathOrId,
25
+ workspace: workspace
24
26
  },
25
27
  mutationFile: 'graphql/jcr/mutation/deleteNode.graphql'
26
28
  });
@@ -0,0 +1 @@
1
+ export declare const waitUntilSAMStatusGreen: (severity?: string, timeout?: number, interval?: number, greenMatchCount?: number) => void;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.waitUntilSAMStatusGreen = void 0;
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) {
15
+ if (severity === void 0) { severity = 'MEDIUM'; }
16
+ if (timeout === void 0) { timeout = 60000; }
17
+ if (interval === void 0) { interval = 500; }
18
+ if (greenMatchCount === void 0) { greenMatchCount = 10; }
19
+ var greenCount = 0;
20
+ cy.waitUntil(function () {
21
+ return cy.apollo({
22
+ fetchPolicy: 'no-cache',
23
+ queryFile: 'graphql/sam/healthStatus.graphql',
24
+ variables: {
25
+ severity: severity
26
+ }
27
+ }).then(function (result) {
28
+ var _a, _b, _c, _d;
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;
30
+ if (healthStatus) {
31
+ greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
32
+ return greenCount >= greenMatchCount;
33
+ }
34
+ });
35
+ }, {
36
+ errorMsg: "Timeout waiting for SAM to be green for severity: " + severity,
37
+ timeout: timeout,
38
+ verbose: true,
39
+ interval: interval
40
+ });
41
+ };
42
+ exports.waitUntilSAMStatusGreen = waitUntilSAMStatusGreen;
@@ -6,3 +6,4 @@ export * from './VanityUrlHelper';
6
6
  export * from './ClusterHelper';
7
7
  export * from './JahiaPlatformHelper';
8
8
  export * from './GraphQLHelper';
9
+ export * from './SAMHelper';
@@ -18,3 +18,4 @@ __exportStar(require("./VanityUrlHelper"), exports);
18
18
  __exportStar(require("./ClusterHelper"), exports);
19
19
  __exportStar(require("./JahiaPlatformHelper"), exports);
20
20
  __exportStar(require("./GraphQLHelper"), exports);
21
+ __exportStar(require("./SAMHelper"), exports);
@@ -1,5 +1,5 @@
1
- mutation deleteNode($pathOrId: String!) {
2
- jcr(workspace: EDIT) {
1
+ mutation deleteNode($pathOrId: String!, $workspace: Workspace!) {
2
+ jcr(workspace: $workspace) {
3
3
  deleteNode(pathOrId: $pathOrId)
4
4
  }
5
5
  }
@@ -0,0 +1,12 @@
1
+ query($severity: GqlProbeSeverity) {
2
+ admin {
3
+ jahia {
4
+ healthCheck(severity: $severity) {
5
+ status {
6
+ health
7
+ message
8
+ }
9
+ }
10
+ }
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.19.4",
3
+ "version": "3.20.1",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -1,3 +1,5 @@
1
+ type Workspace = 'EDIT' | 'LIVE';
2
+
1
3
  export const setNodeProperty = (pathOrId: string, property: string, value: string | Array<string>, language: string): Cypress.Chainable => {
2
4
  let mutationFile = 'graphql/jcr/mutation/setProperty.graphql';
3
5
  if (value instanceof Array) {
@@ -15,10 +17,11 @@ export const setNodeProperty = (pathOrId: string, property: string, value: strin
15
17
  });
16
18
  };
17
19
 
18
- export const deleteNode = (pathOrId: string): Cypress.Chainable => {
20
+ export const deleteNode = (pathOrId: string, workspace: Workspace = 'EDIT'): Cypress.Chainable => {
19
21
  return cy.apollo({
20
22
  variables: {
21
- pathOrId: pathOrId
23
+ pathOrId: pathOrId,
24
+ workspace
22
25
  },
23
26
  mutationFile: 'graphql/jcr/mutation/deleteNode.graphql'
24
27
  });
@@ -43,7 +46,7 @@ export const addNode = (variables: { parentPathOrId: string, primaryNodeType: st
43
46
  });
44
47
  };
45
48
 
46
- export const getNodeByPath = (path: string, properties?: string[], language?: string, childrenTypes: string[] = [], workspace: 'EDIT' | 'LIVE' = 'EDIT'): Cypress.Chainable => {
49
+ export const getNodeByPath = (path: string, properties?: string[], language?: string, childrenTypes: string[] = [], workspace: Workspace = 'EDIT'): Cypress.Chainable => {
47
50
  return cy.apollo({
48
51
  variables: {
49
52
  path: path,
@@ -0,0 +1,34 @@
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;
13
+ cy.waitUntil(() =>
14
+ cy.apollo({
15
+ fetchPolicy: 'no-cache',
16
+ queryFile: 'graphql/sam/healthStatus.graphql',
17
+ variables: {
18
+ severity: severity
19
+ }
20
+ }).then(result => {
21
+ const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
22
+ if (healthStatus) {
23
+ greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
24
+ return greenCount >= greenMatchCount;
25
+ }
26
+ }),
27
+ {
28
+ errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}`,
29
+ timeout: timeout,
30
+ verbose: true,
31
+ interval: interval
32
+ });
33
+ };
34
+
@@ -6,3 +6,4 @@ export * from './VanityUrlHelper';
6
6
  export * from './ClusterHelper';
7
7
  export * from './JahiaPlatformHelper';
8
8
  export * from './GraphQLHelper';
9
+ export * from './SAMHelper';