@jahia/cypress 3.25.0 → 3.27.0

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,9 +1,12 @@
1
1
  import { BaseComponent } from '../baseComponent';
2
+ import Chainable = Cypress.Chainable;
2
3
  export declare class Menu extends BaseComponent {
3
4
  static defaultSelector: string;
5
+ static overlaySelector: string;
4
6
  submenu(item: string, menu: string): Menu;
5
7
  shouldHaveItem(item: string): void;
6
8
  shouldNotHaveItem(item: string): void;
7
9
  select(item: string): Menu;
8
10
  selectByRole(item: string): Menu;
11
+ close(): Chainable<unknown>;
9
12
  }
@@ -44,7 +44,11 @@ var Menu = /** @class */ (function (_super) {
44
44
  this.get().find(".moonstone-menuItem[data-sel-role=\"" + item + "\"]").trigger('click');
45
45
  return this;
46
46
  };
47
+ Menu.prototype.close = function () {
48
+ return cy.get(Menu.overlaySelector).click('topRight');
49
+ };
47
50
  Menu.defaultSelector = '.moonstone-menu:not(.moonstone-hidden)';
51
+ Menu.overlaySelector = '.moonstone-menu_overlay';
48
52
  return Menu;
49
53
  }(baseComponent_1.BaseComponent));
50
54
  exports.Menu = Menu;
@@ -14,4 +14,5 @@ export declare const getNodeByPath: (path: string, properties?: string[], langua
14
14
  export declare const getNodeAcl: (path: string) => Cypress.Chainable;
15
15
  export declare const moveNode: (pathOrId: string, destParentPathOrId: string, destName?: string) => Cypress.Chainable;
16
16
  export declare const getNodeTypes: (filter?: {}) => Cypress.Chainable;
17
+ export declare const uploadFile: (fixturePath: string, parentPathOrId: string, name: string, mimeType: string) => Cypress.Chainable;
17
18
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.getNodeTypes = exports.moveNode = exports.getNodeAcl = exports.getNodeByPath = exports.addNode = exports.deleteNodeProperty = exports.deleteNode = exports.setNodeProperty = void 0;
3
+ exports.uploadFile = exports.getNodeTypes = exports.moveNode = exports.getNodeAcl = exports.getNodeByPath = exports.addNode = exports.deleteNodeProperty = exports.deleteNode = exports.setNodeProperty = void 0;
4
4
  var setNodeProperty = function (pathOrId, property, value, language) {
5
5
  var mutationFile = 'graphql/jcr/mutation/setProperty.graphql';
6
6
  if (value instanceof Array) {
@@ -92,3 +92,20 @@ var getNodeTypes = function (filter) {
92
92
  });
93
93
  };
94
94
  exports.getNodeTypes = getNodeTypes;
95
+ var uploadFile = function (fixturePath, parentPathOrId, name, mimeType) {
96
+ return cy.fixture(fixturePath, 'binary')
97
+ .then(function (image) {
98
+ var blob = Cypress.Blob.binaryStringToBlob(image, mimeType);
99
+ var file = new File([blob], name, { type: blob.type });
100
+ return cy.apollo({
101
+ mutationFile: 'graphql/jcr/mutation/uploadFile.graphql',
102
+ variables: {
103
+ parentPathOrId: parentPathOrId,
104
+ name: name,
105
+ mimeType: mimeType,
106
+ file: file
107
+ }
108
+ });
109
+ });
110
+ };
111
+ exports.uploadFile = uploadFile;
@@ -1 +1,35 @@
1
+ import Chainable = Cypress.Chainable;
2
+ /**
3
+ * Simple health check query
4
+ * @param severity the severity of the health check, default is MEDIUM
5
+ * @param probeHealthFilter the filter for the health check probes, default is GREEN
6
+ */
7
+ export declare const healthCheck: (severity?: string, probeHealthFilter?: string) => Chainable<any>;
8
+ /**
9
+ * Wait until the health check returns the expected health
10
+ * @param expectedHealth the expected health status
11
+ * @param severity the severity of the health check, default is MEDIUM
12
+ * @param probeHealthFilter the filter for the health check probes, default is GREEN
13
+ * @param timeout the timeout in milliseconds, default is 60000
14
+ * @param interval the interval in milliseconds, default is 500
15
+ * @param statusMatchCount the number of consecutive status matches before the waitUntil resolves, default is 1
16
+ */
17
+ export declare const waitUntilSAMStatus: ({ expectedHealth, severity, probeHealthFilter, timeout, interval, statusMatchCount }: {
18
+ expectedHealth: any;
19
+ severity?: string;
20
+ probeHealthFilter?: string;
21
+ timeout?: number;
22
+ interval?: number;
23
+ statusMatchCount?: number;
24
+ }) => void;
25
+ /**
26
+ When Jahia is starting or performing provisioning operations
27
+ it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.
28
+
29
+ The primary use of this method is to wait until a Jahia platform stabilizes after a startup or
30
+ provisioning operation.
31
+
32
+ Instead of waiting only for one occurence of a GREEN status, this function will wait until the a
33
+ GREEN status was returned a number of consecutive times (greenMatchCount).
34
+ */
1
35
  export declare const waitUntilSAMStatusGreen: (severity?: string, timeout?: number, interval?: number, greenMatchCount?: number) => void;
@@ -1,44 +1,75 @@
1
1
  "use strict";
2
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) {
3
+ exports.waitUntilSAMStatusGreen = exports.waitUntilSAMStatus = exports.healthCheck = void 0;
4
+ /**
5
+ * Simple health check query
6
+ * @param severity the severity of the health check, default is MEDIUM
7
+ * @param probeHealthFilter the filter for the health check probes, default is GREEN
8
+ */
9
+ var healthCheck = function (severity, probeHealthFilter) {
15
10
  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;
11
+ if (probeHealthFilter === void 0) { probeHealthFilter = 'GREEN'; }
12
+ return cy
13
+ .apollo({
14
+ fetchPolicy: 'no-cache',
15
+ queryFile: 'graphql/sam/healthStatus.graphql',
16
+ variables: {
17
+ severity: severity,
18
+ probeHealthFilter: probeHealthFilter
19
+ }
20
+ })
21
+ .then(function (response) {
22
+ var _a, _b, _c;
23
+ return (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.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;
24
+ });
25
+ };
26
+ exports.healthCheck = healthCheck;
27
+ /**
28
+ * Wait until the health check returns the expected health
29
+ * @param expectedHealth the expected health status
30
+ * @param severity the severity of the health check, default is MEDIUM
31
+ * @param probeHealthFilter the filter for the health check probes, default is GREEN
32
+ * @param timeout the timeout in milliseconds, default is 60000
33
+ * @param interval the interval in milliseconds, default is 500
34
+ * @param statusMatchCount the number of consecutive status matches before the waitUntil resolves, default is 1
35
+ */
36
+ var waitUntilSAMStatus = function (_a) {
37
+ var expectedHealth = _a.expectedHealth, _b = _a.severity, severity = _b === void 0 ? 'MEDIUM' : _b, _c = _a.probeHealthFilter, probeHealthFilter = _c === void 0 ? 'GREEN' : _c, _d = _a.timeout, timeout = _d === void 0 ? 60000 : _d, _e = _a.interval, interval = _e === void 0 ? 500 : _e, _f = _a.statusMatchCount, statusMatchCount = _f === void 0 ? 1 : _f;
38
+ var statusCount = 0;
20
39
  var lastGraphqlResponse = {};
21
40
  cy.waitUntil(function () {
22
- return cy.apollo({
23
- fetchPolicy: 'no-cache',
24
- queryFile: 'graphql/sam/healthStatus.graphql',
25
- variables: {
26
- severity: severity
27
- }
28
- }).then(function (result) {
29
- var _a, _b, _c, _d, _e, _f, _g;
30
- 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;
31
- lastGraphqlResponse = (_g = (_f = (_e = result === null || result === void 0 ? void 0 : result.data) === null || _e === void 0 ? void 0 : _e.admin) === null || _f === void 0 ? void 0 : _f.jahia) === null || _g === void 0 ? void 0 : _g.healthCheck;
41
+ return exports.healthCheck(severity, probeHealthFilter).then(function (result) {
42
+ lastGraphqlResponse = result;
43
+ var healthStatus = result === null || result === void 0 ? void 0 : result.status;
32
44
  if (healthStatus) {
33
- greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
34
- return greenCount >= greenMatchCount;
45
+ statusCount = healthStatus.health === expectedHealth ? statusCount + 1 : 0;
46
+ return statusCount >= statusMatchCount;
35
47
  }
36
48
  });
37
49
  }, {
38
- errorMsg: "Timeout waiting for SAM to be green for severity: " + severity + ". Last GraphQL response: " + JSON.stringify(lastGraphqlResponse),
50
+ errorMsg: "Timeout waiting for SAM to be " + expectedHealth + " for severity: " + severity + " and probeHealthFilter: " + probeHealthFilter + ". Last GraphQL response: " + JSON.stringify(lastGraphqlResponse),
39
51
  timeout: timeout,
40
52
  verbose: true,
41
53
  interval: interval
42
54
  });
43
55
  };
56
+ exports.waitUntilSAMStatus = waitUntilSAMStatus;
57
+ /**
58
+ When Jahia is starting or performing provisioning operations
59
+ it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.
60
+
61
+ The primary use of this method is to wait until a Jahia platform stabilizes after a startup or
62
+ provisioning operation.
63
+
64
+ Instead of waiting only for one occurence of a GREEN status, this function will wait until the a
65
+ GREEN status was returned a number of consecutive times (greenMatchCount).
66
+ */
67
+ var waitUntilSAMStatusGreen = function (severity, timeout, interval, greenMatchCount) {
68
+ if (severity === void 0) { severity = 'MEDIUM'; }
69
+ if (timeout === void 0) { timeout = 60000; }
70
+ if (interval === void 0) { interval = 500; }
71
+ if (greenMatchCount === void 0) { greenMatchCount = 10; }
72
+ // We use YELLOW as the probeHealthFilter because we are not interested in potential GREEN probes in the response
73
+ exports.waitUntilSAMStatus({ expectedHealth: 'GREEN', severity: severity, probeHealthFilter: 'YELLOW', timeout: timeout, interval: interval, statusMatchCount: greenMatchCount });
74
+ };
44
75
  exports.waitUntilSAMStatusGreen = waitUntilSAMStatusGreen;
@@ -0,0 +1,15 @@
1
+ import { SSHExecCommandResponse } from 'node-ssh';
2
+ interface connection {
3
+ hostname: string;
4
+ port: string;
5
+ username: string;
6
+ password: string;
7
+ }
8
+ /**
9
+ * Execute SSH commands on a specific host. Returns a promise that resolves to the command result.
10
+ * Rejects if the commands fail (exit code is not 0).
11
+ * @param commands Array of SSH commands to execute
12
+ * @param connection Connection details
13
+ */
14
+ export declare const sshCommands: (commands: Array<string>, connection: connection) => Promise<SSHExecCommandResponse>;
15
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.sshCommands = void 0;
4
+ var node_ssh_1 = require("node-ssh");
5
+ /**
6
+ * Execute SSH commands on a specific host. Returns a promise that resolves to the command result.
7
+ * Rejects if the commands fail (exit code is not 0).
8
+ * @param commands Array of SSH commands to execute
9
+ * @param connection Connection details
10
+ */
11
+ var sshCommands = function (commands, connection) {
12
+ return new Promise(function (resolve, reject) {
13
+ var ssh = new node_ssh_1.NodeSSH();
14
+ console.info('[SSH] connection to:', connection.hostname, ' (port: ', connection.port, ')');
15
+ console.info('[SSH] commands:', commands);
16
+ console.info('[SSH] ', connection);
17
+ ssh.connect({
18
+ host: connection.hostname,
19
+ port: parseInt(connection.port, 10),
20
+ username: connection.username,
21
+ password: connection.password
22
+ })
23
+ .then(function () {
24
+ ssh.exec(commands.join(';'), [], { stream: 'both' })
25
+ .then(function (result) {
26
+ console.info('[SSH] Successfully executed commands: ', commands);
27
+ console.info('[SSH] Result: ', result);
28
+ if (result.code === 0) {
29
+ resolve(result); // Resolve to command result
30
+ }
31
+ else {
32
+ reject(new Error("Commands \"" + commands + "\" failed with exit code " + result.code + " on host " + connection.hostname + ". Stdout:" + result.stdout + ", Stderr: " + result.stderr));
33
+ }
34
+ })["catch"](function (reason) {
35
+ console.error('[SSH] Failed to execute commands: ', commands);
36
+ reject(reason);
37
+ });
38
+ })["catch"](function (reason) {
39
+ console.error('[SSH] Failed to connect to: ', connection.hostname);
40
+ reject(reason);
41
+ });
42
+ });
43
+ };
44
+ exports.sshCommands = sshCommands;
@@ -1,9 +1,10 @@
1
+ export * from './ClusterHelper';
2
+ export * from './GraphQLHelper';
3
+ export * from './JahiaPlatformHelper';
1
4
  export * from './JCRHelper';
2
5
  export * from './PublicationAndWorkflowHelper';
6
+ export * from './SAMHelper';
3
7
  export * from './SiteHelper';
8
+ export * from './SSHHelper';
4
9
  export * from './UsersHelper';
5
10
  export * from './VanityUrlHelper';
6
- export * from './ClusterHelper';
7
- export * from './JahiaPlatformHelper';
8
- export * from './GraphQLHelper';
9
- export * from './SAMHelper';
@@ -10,12 +10,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  exports.__esModule = true;
13
+ __exportStar(require("./ClusterHelper"), exports);
14
+ __exportStar(require("./GraphQLHelper"), exports);
15
+ __exportStar(require("./JahiaPlatformHelper"), exports);
13
16
  __exportStar(require("./JCRHelper"), exports);
14
17
  __exportStar(require("./PublicationAndWorkflowHelper"), exports);
18
+ __exportStar(require("./SAMHelper"), exports);
15
19
  __exportStar(require("./SiteHelper"), exports);
20
+ __exportStar(require("./SSHHelper"), exports);
16
21
  __exportStar(require("./UsersHelper"), exports);
17
22
  __exportStar(require("./VanityUrlHelper"), exports);
18
- __exportStar(require("./ClusterHelper"), exports);
19
- __exportStar(require("./JahiaPlatformHelper"), exports);
20
- __exportStar(require("./GraphQLHelper"), exports);
21
- __exportStar(require("./SAMHelper"), exports);
@@ -0,0 +1,11 @@
1
+ mutation uploadFile($name: String!, $parentPathOrId: String!, $mimeType: String!, $file: String!) {
2
+ jcr {
3
+ addNode(name: $name, parentPathOrId: $parentPathOrId, primaryNodeType: "jnt:file") {
4
+ addChild(name: "jcr:content", primaryNodeType: "jnt:resource") {
5
+ content: mutateProperty(name: "jcr:data") { setValue(type: BINARY, value: $file)}
6
+ contentType: mutateProperty(name: "jcr:mimeType") { setValue(value: $mimeType)}
7
+ }
8
+ uuid
9
+ }
10
+ }
11
+ }
@@ -1,4 +1,4 @@
1
- query($severity: GqlProbeSeverity) {
1
+ query($severity: GqlProbeSeverity, $probeHealthFilter: GqlProbeHealth) {
2
2
  admin {
3
3
  jahia {
4
4
  healthCheck(severity: $severity) {
@@ -6,13 +6,15 @@ query($severity: GqlProbeSeverity) {
6
6
  health
7
7
  message
8
8
  }
9
- probes(health: YELLOW) {
9
+ probes(health: $probeHealthFilter) {
10
10
  name
11
+ severity
12
+ description
11
13
  status {
12
14
  health
13
15
  message
14
16
  }
15
- }
17
+ }
16
18
  }
17
19
  }
18
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.25.0",
3
+ "version": "3.27.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -8,8 +8,8 @@
8
8
  "bin": {
9
9
  "ci.build": "./ci.build.sh",
10
10
  "ci.startup": "./ci.startup.sh",
11
- "env.run": "./env.run.sh",
12
- "env.debug": "./env.debug.sh"
11
+ "env.debug": "./env.debug.sh",
12
+ "env.run": "./env.run.sh"
13
13
  },
14
14
  "main": "dist/index.js",
15
15
  "types": "dist/index.d.ts",
@@ -26,6 +26,7 @@
26
26
  "eslint-plugin-jest": "^27.2.1",
27
27
  "eslint-plugin-react": "^7.32.2",
28
28
  "eslint-plugin-react-hooks": "^4.6.0",
29
+ "node-ssh": "^13.2.0",
29
30
  "typescript": "^4.3.5"
30
31
  },
31
32
  "dependencies": {
@@ -33,5 +34,6 @@
33
34
  "cypress-real-events": "^1.11.0",
34
35
  "graphql": "^15.5.0",
35
36
  "graphql-tag": "^2.11.0"
36
- }
37
+ },
38
+ "packageManager": "yarn@4.5.0"
37
39
  }