@jahia/cypress 4.2.0 → 4.4.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.
package/ci.startup.sh CHANGED
@@ -27,12 +27,12 @@ if [[ -z ${JAHIA_LICENSE} ]]; then
27
27
  fi
28
28
 
29
29
  echo "$(date +'%d %B %Y - %k:%M') == Cluster enabled: ${JAHIA_CLUSTER_ENABLED} =="
30
- if [[ "${JAHIA_CLUSTER_ENABLED}" == "true" ]]; then
30
+ if [[ "${JAHIA_CLUSTER_ENABLED}" == "true" || ${JAHIA_CLUSTER_ENABLED} == true ]]; then
31
31
  export CLUSTER_PROFILE="--profile cluster"
32
32
  fi
33
33
 
34
34
  echo "$(date +'%d %B %Y - %k:%M') == Starting environment =="
35
- docker-compose up -d --renew-anon-volumes ${CLUSTER_PROFILE}
35
+ docker-compose ${CLUSTER_PROFILE} up -d --renew-anon-volumes
36
36
  if [[ "$1" != "notests" ]]; then
37
37
  docker ps -a
38
38
  docker stats --no-stream
@@ -33,8 +33,8 @@ var Menu = /** @class */ (function (_super) {
33
33
  this.get().find('.moonstone-menuItem').contains(item).should('be.visible');
34
34
  };
35
35
  Menu.prototype.shouldHaveRoleItem = function (role) {
36
- this.get().find(".moonstone-menuItem[data-sel-role=" + role + "]").scrollIntoView();
37
- this.get().find(".moonstone-menuItem[data-sel-role=" + role + "]").should('be.visible');
36
+ this.get().find(".moonstone-menuItem[data-sel-role=\"" + role + "\"]").scrollIntoView();
37
+ this.get().find(".moonstone-menuItem[data-sel-role=\"" + role + "\"]").should('be.visible');
38
38
  };
39
39
  Menu.prototype.shouldNotHaveItem = function (item) {
40
40
  this.get().find('.moonstone-menuItem').contains(item).should('not.exist');
@@ -2,10 +2,16 @@
2
2
  declare global {
3
3
  namespace Cypress {
4
4
  interface Chainable<Subject> {
5
- login(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>;
5
+ login(username?: string, password?: string, config?: string | {
6
+ url?: string;
7
+ rememberMe?: boolean;
8
+ }): Chainable<Cypress.Response<any>>;
6
9
  loginAndStoreSession(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>;
7
10
  }
8
11
  }
9
12
  }
10
- export declare const login: (username?: string, password?: string, url?: string) => void;
13
+ export declare const login: (username: string, password: string, config: string | {
14
+ url?: string;
15
+ rememberMe?: boolean;
16
+ }) => void;
11
17
  export declare const loginAndStoreSession: (username?: string, password?: string, url?: string) => void;
@@ -3,10 +3,12 @@
3
3
  exports.__esModule = true;
4
4
  exports.loginAndStoreSession = exports.login = void 0;
5
5
  /// <reference types="cypress" />
6
- var login = function (username, password, url) {
6
+ // Disable linter to keep as this for backward compatibility
7
+ // eslint-disable-next-line default-param-last
8
+ var login = function (username, password, config) {
9
+ var _a;
7
10
  if (username === void 0) { username = 'root'; }
8
11
  if (password === void 0) { password = Cypress.env('SUPER_USER_PASSWORD'); }
9
- if (url === void 0) { url = '/cms/login'; }
10
12
  Cypress.log({
11
13
  name: 'login',
12
14
  message: "Login with " + username,
@@ -16,10 +18,21 @@ var login = function (username, password, url) {
16
18
  };
17
19
  }
18
20
  });
21
+ var body = { username: username, password: password };
22
+ var url = '/cms/login';
23
+ if (typeof config === 'object') {
24
+ if (config.rememberMe) {
25
+ body.useCookie = 'on';
26
+ }
27
+ url = (_a = config.url) !== null && _a !== void 0 ? _a : url;
28
+ }
29
+ else {
30
+ url = config !== null && config !== void 0 ? config : url;
31
+ }
19
32
  cy.request({
20
33
  method: 'POST',
21
34
  form: true,
22
- body: { username: username, password: password },
35
+ body: body,
23
36
  followRedirect: false,
24
37
  log: false,
25
38
  url: url
@@ -1,4 +1,5 @@
1
1
  /// <reference types="cypress" />
2
+ import RequestOptions = Cypress.RequestOptions;
2
3
  declare global {
3
4
  namespace Cypress {
4
5
  interface Chainable<Subject> {
@@ -21,4 +22,4 @@ export declare type JahiaServer = {
21
22
  username: string;
22
23
  password: string;
23
24
  };
24
- export declare const runProvisioningScript: (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable, timeout?: number) => void;
25
+ export declare const runProvisioningScript: (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable, timeout?: number, requestOptions?: Partial<RequestOptions>) => void;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  exports.__esModule = true;
3
14
  exports.runProvisioningScript = void 0;
4
15
  function processContent(formFile) {
@@ -36,9 +47,10 @@ function isFormFile(script) {
36
47
  return Boolean(script.fileContent || script.fileName);
37
48
  }
38
49
  // eslint-disable-next-line default-param-last, max-params
39
- var runProvisioningScript = function (script, files, jahiaServer, options, timeout) {
50
+ var runProvisioningScript = function (script, files, jahiaServer, options, timeout, requestOptions) {
40
51
  if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
41
52
  if (options === void 0) { options = { log: true }; }
53
+ if (requestOptions === void 0) { requestOptions = {}; }
42
54
  var formData = new FormData();
43
55
  if (isFormFile(script)) {
44
56
  append(script, formData, 'script');
@@ -75,17 +87,11 @@ var runProvisioningScript = function (script, files, jahiaServer, options, timeo
75
87
  }
76
88
  });
77
89
  }
78
- var request = {
79
- url: jahiaServer.url + "/modules/api/provisioning",
80
- method: 'POST',
81
- auth: {
90
+ var request = __assign({ url: jahiaServer.url + "/modules/api/provisioning", method: 'POST', auth: {
82
91
  user: jahiaServer.username,
83
92
  pass: jahiaServer.password,
84
93
  sendImmediately: true
85
- },
86
- body: formData,
87
- log: false
88
- };
94
+ }, body: formData, log: false }, requestOptions);
89
95
  if (typeof timeout !== 'undefined') {
90
96
  request.timeout = timeout;
91
97
  }
@@ -6,9 +6,9 @@ export declare const addNode: (variables: {
6
6
  parentPathOrId: string;
7
7
  primaryNodeType: string;
8
8
  name: string;
9
- properties?: [];
10
- children?: [];
11
- mixins?: [];
9
+ properties?: any[];
10
+ children?: any[];
11
+ mixins?: string[];
12
12
  }) => Cypress.Chainable;
13
13
  export declare const addMixins: (pathOrId: string, mixins: string[]) => Cypress.Chainable;
14
14
  export declare const getNodeByPath: (path: string, properties?: string[], language?: string, childrenTypes?: string[], workspace?: Workspace) => Cypress.Chainable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts --max-warnings=0"
@@ -18,8 +18,8 @@ export class Menu extends BaseComponent {
18
18
  }
19
19
 
20
20
  shouldHaveRoleItem(role: string):void {
21
- this.get().find(`.moonstone-menuItem[data-sel-role=${role}]`).scrollIntoView();
22
- this.get().find(`.moonstone-menuItem[data-sel-role=${role}]`).should('be.visible');
21
+ this.get().find(`.moonstone-menuItem[data-sel-role="${role}"]`).scrollIntoView();
22
+ this.get().find(`.moonstone-menuItem[data-sel-role="${role}"]`).should('be.visible');
23
23
  }
24
24
 
25
25
  shouldNotHaveItem(item: string):void {
@@ -7,13 +7,14 @@ declare global {
7
7
  namespace Cypress {
8
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
9
  interface Chainable<Subject> {
10
- login(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>
10
+ login(username?: string, password?: string, config?: string| {url?: string; rememberMe?: boolean}): Chainable<Cypress.Response<any>>
11
11
  loginAndStoreSession(username?: string, password?: string, url?: string): Chainable<Cypress.Response<any>>
12
12
  }
13
13
  }
14
14
  }
15
-
16
- export const login = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD'), url = '/cms/login'): void => {
15
+ // Disable linter to keep as this for backward compatibility
16
+ // eslint-disable-next-line default-param-last
17
+ export const login = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD'), config: string | { url?: string, rememberMe?: boolean }): void => {
17
18
  Cypress.log({
18
19
  name: 'login',
19
20
  message: `Login with ${username}`,
@@ -23,11 +24,22 @@ export const login = (username = 'root', password: string = Cypress.env('SUPER_U
23
24
  };
24
25
  }
25
26
  });
27
+ const body: {username: string, password: string, useCookie?: string} = {username, password};
28
+ let url = '/cms/login';
29
+ if (typeof config === 'object') {
30
+ if (config.rememberMe) {
31
+ body.useCookie = 'on';
32
+ }
33
+
34
+ url = config.url ?? url;
35
+ } else {
36
+ url = config ?? url;
37
+ }
26
38
 
27
39
  cy.request({
28
40
  method: 'POST',
29
41
  form: true,
30
- body: {username, password},
42
+ body,
31
43
  followRedirect: false,
32
44
  log: false,
33
45
  url
@@ -45,6 +45,15 @@ Additional files that can be referenced in the script. When an operation require
45
45
 
46
46
  - `log` : should the command be logged or not
47
47
 
48
+ #### &gt; timeout (`number`)
49
+
50
+ the timeout in milliseconds
51
+
52
+ #### &gt; requestOptions (`RequestOptions`)
53
+
54
+ Addition options for the cypress request object, some useful ones are:
55
+ - `failOnStatusCode` : useful when you expect a 4xx or 5xx error and need to test it
56
+
48
57
  ### Yields
49
58
 
50
59
  The provisioning script result, as JSON object
@@ -69,7 +69,7 @@ function isFormFile(script: FormFile | StringDictionary[]): script is FormFile {
69
69
  }
70
70
 
71
71
  // eslint-disable-next-line default-param-last, max-params
72
- export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log: true}, timeout?: number): void => {
72
+ export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log: true}, timeout?: number, requestOptions: Partial<RequestOptions> = {}): void => {
73
73
  const formData = new FormData();
74
74
 
75
75
  if (isFormFile(script)) {
@@ -119,7 +119,8 @@ export const runProvisioningScript = (script: FormFile | StringDictionary[], fil
119
119
  sendImmediately: true
120
120
  },
121
121
  body: formData,
122
- log: false
122
+ log: false,
123
+ ...requestOptions
123
124
  };
124
125
 
125
126
  if (typeof timeout !== 'undefined') {
@@ -42,9 +42,11 @@ export const addNode = (variables: {
42
42
  parentPathOrId: string,
43
43
  primaryNodeType: string,
44
44
  name: string,
45
- properties?: [],
46
- children?: [],
47
- mixins?: []
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
+ properties?: any [],
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ children?: any [],
49
+ mixins?: string []
48
50
  }): Cypress.Chainable => {
49
51
  return cy.apollo({
50
52
  variables: variables,