@jahia/cypress 1.0.10 → 1.1.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.
@@ -3,10 +3,16 @@ declare global {
3
3
  interface Chainable<Subject> {
4
4
  executeGroovy(scriptFile: string, replacements?: {
5
5
  [key: string]: string;
6
- }): Chainable<any>;
6
+ }, jahiaServer?: JahiaServer): Chainable<any>;
7
7
  }
8
8
  }
9
9
  }
10
+ declare type JahiaServer = {
11
+ url: string;
12
+ username: string;
13
+ password: string;
14
+ };
10
15
  export declare const executeGroovy: (scriptFile: string, replacements?: {
11
16
  [key: string]: string;
12
- }) => void;
17
+ }, jahiaServer?: JahiaServer) => void;
18
+ export {};
@@ -3,7 +3,13 @@
3
3
  exports.__esModule = true;
4
4
  exports.executeGroovy = void 0;
5
5
  /// <reference types="cypress" />
6
- var executeGroovy = function (scriptFile, replacements) {
6
+ var serverDefaults = {
7
+ url: Cypress.config().baseUrl,
8
+ username: 'root',
9
+ password: Cypress.env('SUPER_USER_PASSWORD')
10
+ };
11
+ var executeGroovy = function (scriptFile, replacements, jahiaServer) {
12
+ if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
7
13
  cy.runProvisioningScript({
8
14
  fileContent: '- executeScript: "' + scriptFile + '"',
9
15
  type: 'application/yaml'
@@ -11,6 +17,6 @@ var executeGroovy = function (scriptFile, replacements) {
11
17
  fileName: scriptFile,
12
18
  replacements: replacements,
13
19
  type: 'text/plain'
14
- }]).then(function (r) { return r[0]; });
20
+ }], jahiaServer).then(function (r) { return r[0]; });
15
21
  };
16
22
  exports.executeGroovy = executeGroovy;
@@ -2,7 +2,7 @@
2
2
  declare global {
3
3
  namespace Cypress {
4
4
  interface Chainable<Subject> {
5
- runProvisioningScript(script: FormFile, files?: FormFile[]): Chainable<any>;
5
+ runProvisioningScript(script: FormFile, files?: FormFile[], jahiaServer?: JahiaServer): Chainable<any>;
6
6
  }
7
7
  }
8
8
  }
@@ -15,5 +15,10 @@ declare type FormFile = {
15
15
  [key: string]: string;
16
16
  };
17
17
  };
18
- export declare const runProvisioningScript: (script: FormFile, files?: FormFile[], options?: Cypress.Loggable) => void;
18
+ declare type JahiaServer = {
19
+ url: string;
20
+ username: string;
21
+ password: string;
22
+ };
23
+ export declare const runProvisioningScript: (script: FormFile, files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable) => void;
19
24
  export {};
@@ -27,7 +27,13 @@ function append(formFile, formData, key) {
27
27
  });
28
28
  }
29
29
  }
30
- var runProvisioningScript = function (script, files, options) {
30
+ var serverDefaults = {
31
+ url: Cypress.config().baseUrl,
32
+ username: 'root',
33
+ password: Cypress.env('SUPER_USER_PASSWORD')
34
+ };
35
+ var runProvisioningScript = function (script, files, jahiaServer, options) {
36
+ if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
31
37
  if (options === void 0) { options = { log: true }; }
32
38
  var formData = new FormData();
33
39
  append(script, formData, "script");
@@ -56,11 +62,11 @@ var runProvisioningScript = function (script, files, options) {
56
62
  });
57
63
  }
58
64
  cy.request({
59
- url: Cypress.config().baseUrl + "/modules/api/provisioning",
65
+ url: jahiaServer.url + "/modules/api/provisioning",
60
66
  method: 'POST',
61
67
  auth: {
62
- user: 'root',
63
- pass: Cypress.env('SUPER_USER_PASSWORD'),
68
+ user: jahiaServer.username,
69
+ pass: jahiaServer.password,
64
70
  sendImmediately: true
65
71
  },
66
72
  body: formData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "1.0.10",
3
+ "version": "1.1.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@apollo/client": "^3.4.9",
21
- "cypress-terminal-report": "^3.3.2",
21
+ "cypress-terminal-report": "^3.4.2",
22
22
  "graphql": "^15.5.0",
23
23
  "graphql-tag": "^2.11.0"
24
24
  }
@@ -10,6 +10,7 @@ This commands execute a groovy script from fixtures folder
10
10
 
11
11
  ```
12
12
  cy.executeGroovy('script.groovy')
13
+ cy.executeGroovy('script.groovy', null, {url: 'http://jahia-processing.jahia.net:8080', username: 'root', password: 'root1234'})
13
14
  ```
14
15
 
15
16
  ### Arguments
@@ -18,6 +19,14 @@ cy.executeGroovy('script.groovy')
18
19
 
19
20
  The name of the script file, in fixtures folder
20
21
 
22
+ #### &gt; jahiaServer (`JahiaServer`)
23
+
24
+ A Jahia server can be specified if there is a need to use something other than default. This is useful when using Jahia in cluster, if there is a need to redirect a provisioning script to a specific Jahia server (for example a processig node).
25
+
26
+ - url: (`string`) : The url of the server (for example: http://processing.jahia.net:8080)
27
+ - username: (`string`) : Root user
28
+ - password: (`string`) : Password for the root user
29
+
21
30
  ### Yields
22
31
 
23
32
  The groovy script result (set with `setResult()` within groovy code)
@@ -9,12 +9,24 @@ declare global {
9
9
  namespace Cypress {
10
10
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
11
  interface Chainable<Subject> {
12
- executeGroovy(scriptFile: string, replacements?: { [key: string]: string }): Chainable<any>
12
+ executeGroovy(scriptFile: string, replacements?: { [key: string]: string }, jahiaServer?: JahiaServer): Chainable<any>
13
13
  }
14
14
  }
15
15
  }
16
16
 
17
- export const executeGroovy = function (scriptFile: string, replacements?: { [key: string]: string }): void {
17
+ type JahiaServer = {
18
+ url: string;
19
+ username: string;
20
+ password: string
21
+ }
22
+
23
+ const serverDefaults = {
24
+ url: Cypress.config().baseUrl,
25
+ username: 'root',
26
+ password: Cypress.env('SUPER_USER_PASSWORD')
27
+ }
28
+
29
+ export const executeGroovy = function (scriptFile: string, replacements?: { [key: string]: string }, jahiaServer: JahiaServer = serverDefaults): void {
18
30
  cy.runProvisioningScript({
19
31
  fileContent: '- executeScript: "' + scriptFile + '"',
20
32
  type: 'application/yaml'
@@ -22,5 +34,5 @@ export const executeGroovy = function (scriptFile: string, replacements?: { [key
22
34
  fileName: scriptFile,
23
35
  replacements,
24
36
  type: 'text/plain'
25
- }]).then(r => r[0])
37
+ }], jahiaServer).then(r => r[0])
26
38
  }
@@ -12,6 +12,7 @@ This commands execute a provisioning script
12
12
  cy.runProvisioningScript({fileName:'prov.yaml', type:'application/yaml'})
13
13
  cy.runProvisioningScript({fileName:'prov.yaml', type:'application/yaml'}, [{fileName: 'file1.zip'}])
14
14
  cy.runProvisioningScript({fileContent:'- startBundle: "module"', type:'application/yaml'})
15
+ cy.runProvisioningScript({fileContent:'- startBundle: "module"', type:'application/yaml'}, null, {url: 'http://jahia-processing.jahia.net:8080', username: 'root', password: 'root1234'})
15
16
  ```
16
17
 
17
18
  ### Arguments
@@ -24,6 +25,14 @@ The script can be specified either from an external file (using fileName) or inl
24
25
  - fileContent: (`string`) : The content of the script. If specified, fileName is ignored.
25
26
  - type: (`string`) : Content type, either `application/yaml` or `application/json`
26
27
 
28
+ #### &gt; jahiaServer (`JahiaServer`)
29
+
30
+ A Jahia server can be specified if there is a need to use something other than default. This is useful when using Jahia in cluster, if there is a need to redirect a provisioning script to a specific Jahia server (for example a processig node).
31
+
32
+ - url: (`string`) : The url of the server (for example: http://processing.jahia.net:8080)
33
+ - username: (`string`) : Root user
34
+ - password: (`string`) : Password for the root user
35
+
27
36
  #### &gt; files (`FormFile[]`)
28
37
 
29
38
  Additional files that can be referenced in the script. When an operation requires a URL, directly specify the file name (without protocol) to use one these files
@@ -9,7 +9,7 @@ declare global {
9
9
  namespace Cypress {
10
10
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
11
  interface Chainable<Subject> {
12
- runProvisioningScript(script: FormFile, files?: FormFile[]): Chainable<any>
12
+ runProvisioningScript(script: FormFile, files?: FormFile[], jahiaServer?: JahiaServer): Chainable<any>
13
13
  }
14
14
  }
15
15
  }
@@ -22,6 +22,12 @@ type FormFile = {
22
22
  replacements?: { [key: string]: string }
23
23
  }
24
24
 
25
+ type JahiaServer = {
26
+ url: string;
27
+ username: string;
28
+ password: string
29
+ }
30
+
25
31
  function processContent(formFile: FormFile) {
26
32
  let content = formFile.fileContent;
27
33
  if (formFile.replacements) {
@@ -46,7 +52,13 @@ function append(formFile: FormFile, formData: FormData, key: string) {
46
52
  }
47
53
  }
48
54
 
49
- export const runProvisioningScript = (script: FormFile, files?: FormFile[], options: Cypress.Loggable = {log:true}): void => {
55
+ const serverDefaults: JahiaServer = {
56
+ url: Cypress.config().baseUrl,
57
+ username: 'root',
58
+ password: Cypress.env('SUPER_USER_PASSWORD')
59
+ }
60
+
61
+ export const runProvisioningScript = (script: FormFile, files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log:true}): void => {
50
62
  const formData = new FormData()
51
63
 
52
64
  append(script, formData, "script")
@@ -78,11 +90,11 @@ export const runProvisioningScript = (script: FormFile, files?: FormFile[], opti
78
90
  }
79
91
 
80
92
  cy.request({
81
- url: `${Cypress.config().baseUrl}/modules/api/provisioning`,
93
+ url: `${jahiaServer.url}/modules/api/provisioning`,
82
94
  method: 'POST',
83
95
  auth: {
84
- user: 'root',
85
- pass: Cypress.env('SUPER_USER_PASSWORD'),
96
+ user: jahiaServer.username,
97
+ pass: jahiaServer.password,
86
98
  sendImmediately: true,
87
99
  },
88
100
  body: formData,
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="JAVA_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$" />
6
- <orderEntry type="inheritedJdk" />
7
- <orderEntry type="sourceFolder" forTests="false" />
8
- </component>
9
- </module>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/jahia-cypress.iml" filepath="$PROJECT_DIR$/.idea/jahia-cypress.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,3 +0,0 @@
1
-
2
- Otypescript:S1117".'args' is already declared in the upper scope.(��������
3
- Rtypescript:S1117"1'fixture' is already declared in the upper scope.(��������
@@ -1,3 +0,0 @@
1
-
2
- F
3
- src/support/fixture.ts,8/9/8995cd54601f633e8bca96b4e0b06ae4272afe02
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,10 +0,0 @@
1
- /// <reference types="cypress" />
2
- import { BaseComponent } from "./baseComponent";
3
- import Chainable = Cypress.Chainable;
4
- export declare class IFrame extends BaseComponent {
5
- static defaultSelector: string;
6
- private body;
7
- constructor(element: Chainable<JQuery>, assertion?: (s: JQuery) => void);
8
- getBody(): Chainable<JQuery>;
9
- enter(): void;
10
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- exports.__esModule = true;
18
- exports.IFrame = void 0;
19
- var baseComponent_1 = require("./baseComponent");
20
- var IFrame = /** @class */ (function (_super) {
21
- __extends(IFrame, _super);
22
- function IFrame(element, assertion) {
23
- var _this = _super.call(this, element, assertion) || this;
24
- _this.get()
25
- .should(function (f) {
26
- var fr = f[0];
27
- expect(fr.contentWindow.location.href).not.equals('about:blank');
28
- expect(fr.contentWindow.document.readyState).equals('complete');
29
- expect(fr.contentDocument.body).not.be.empty;
30
- })
31
- .its('0.contentDocument.body').as('framebody' + _this.id);
32
- return _this;
33
- }
34
- IFrame.prototype.getBody = function () {
35
- return cy.get('@framebody' + this.id);
36
- };
37
- IFrame.prototype.enter = function () {
38
- this.get().then(function (f) {
39
- var fr = f[0];
40
- cy.visit(fr.contentWindow.location.href);
41
- });
42
- };
43
- IFrame.defaultSelector = 'iframe';
44
- return IFrame;
45
- }(baseComponent_1.BaseComponent));
46
- exports.IFrame = IFrame;
@@ -1,8 +0,0 @@
1
- /// <reference types="cypress" />
2
- import { BaseComponent } from "../baseComponent";
3
- import TypeOptions = Cypress.TypeOptions;
4
- export declare class MUIInput extends BaseComponent {
5
- static defaultSelector: string;
6
- clear(): MUIInput;
7
- type(text: string, options?: Partial<TypeOptions>): MUIInput;
8
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- exports.__esModule = true;
18
- exports.MUIInput = void 0;
19
- var baseComponent_1 = require("../baseComponent");
20
- var MUIInput = /** @class */ (function (_super) {
21
- __extends(MUIInput, _super);
22
- function MUIInput() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- MUIInput.prototype.clear = function () {
26
- this.get().clear();
27
- return this;
28
- };
29
- MUIInput.prototype.type = function (text, options) {
30
- this.get().type(text, options);
31
- return this;
32
- };
33
- MUIInput.defaultSelector = 'div';
34
- return MUIInput;
35
- }(baseComponent_1.BaseComponent));
36
- exports.MUIInput = MUIInput;
@@ -1,5 +0,0 @@
1
- import { BaseComponent } from "../baseComponent";
2
- export declare class MUIRadio extends BaseComponent {
3
- static defaultSelector: string;
4
- click(): MUIRadio;
5
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- exports.__esModule = true;
18
- exports.MUIRadio = void 0;
19
- var baseComponent_1 = require("../baseComponent");
20
- var MUIRadio = /** @class */ (function (_super) {
21
- __extends(MUIRadio, _super);
22
- function MUIRadio() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- MUIRadio.prototype.click = function () {
26
- this.get().click();
27
- return this;
28
- };
29
- MUIRadio.defaultSelector = 'label';
30
- return MUIRadio;
31
- }(baseComponent_1.BaseComponent));
32
- exports.MUIRadio = MUIRadio;
@@ -1,15 +0,0 @@
1
- /// <reference types="cypress" />
2
- declare type ReloadUntilOptions = {
3
- attempts: number;
4
- reloadCallback: () => void;
5
- delay: number;
6
- };
7
- declare global {
8
- namespace Cypress {
9
- interface Chainable<Subject> {
10
- reloadUntil(selector: string, options: Partial<ReloadUntilOptions>): Chainable<Cypress.Response<any>>;
11
- }
12
- }
13
- }
14
- export declare const reloadUntil: (selector: string, options: Partial<ReloadUntilOptions>) => void;
15
- export {};
@@ -1,50 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
3
- var __assign = (this && this.__assign) || function () {
4
- __assign = Object.assign || function(t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
- t[p] = s[p];
9
- }
10
- return t;
11
- };
12
- return __assign.apply(this, arguments);
13
- };
14
- exports.__esModule = true;
15
- exports.reloadUntil = void 0;
16
- var defaultOptions = {
17
- attempts: 10,
18
- reloadCallback: function () { return cy.reload({ log: false }); },
19
- delay: 1000
20
- };
21
- var reloadUntil = function (selector, options) {
22
- options = __assign(__assign({}, defaultOptions), options);
23
- var log = Cypress.log({
24
- name: 'reloadUntil',
25
- message: "Reload until " + selector + ", remaining attempts : " + options.attempts,
26
- consoleProps: function () {
27
- return {
28
- attempts: options.attempts
29
- };
30
- }
31
- });
32
- var items = Cypress.$(selector);
33
- if (items.length) {
34
- log.set({ $el: items });
35
- return;
36
- }
37
- if (options.attempts > 1) {
38
- log.end();
39
- options.reloadCallback();
40
- // eslint-disable-next-line cypress/no-unnecessary-waiting
41
- cy.wait(options.delay);
42
- cy.reloadUntil(selector, __assign(__assign({}, options), { attempts: options.attempts - 1 }));
43
- }
44
- else {
45
- var err = Error('Items not found.');
46
- log.error(err);
47
- throw err;
48
- }
49
- };
50
- exports.reloadUntil = reloadUntil;
@@ -1,15 +0,0 @@
1
- /// <reference types="cypress" />
2
- declare type ReloadUntilOptions = {
3
- attempts: number;
4
- reloadCallback: () => void;
5
- delay: number;
6
- };
7
- declare global {
8
- namespace Cypress {
9
- interface Chainable<Subject> {
10
- reloadUntil(selector: string, options: Partial<ReloadUntilOptions>): Chainable<Cypress.Response<any>>;
11
- }
12
- }
13
- }
14
- export declare const reloadUntil: (selector: string, options: Partial<ReloadUntilOptions>) => void;
15
- export {};
@@ -1,44 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
3
- var __assign = (this && this.__assign) || function () {
4
- __assign = Object.assign || function(t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
- t[p] = s[p];
9
- }
10
- return t;
11
- };
12
- return __assign.apply(this, arguments);
13
- };
14
- exports.__esModule = true;
15
- exports.reloadUntil = void 0;
16
- var defaultOptions = {
17
- attempts: 10,
18
- reloadCallback: function () { return cy.reload({ log: false }); },
19
- delay: 1000
20
- };
21
- var reloadUntil = function (selector, options) {
22
- options = __assign(__assign({}, defaultOptions), options);
23
- var log = Cypress.log({
24
- name: 'reloadUntil',
25
- message: "Reload until " + selector + ", remaining attempts : " + options.attempts
26
- });
27
- var $items = Cypress.$(selector);
28
- if ($items.length) {
29
- return;
30
- }
31
- if (options.attempts > 1) {
32
- log.finish();
33
- options.reloadCallback();
34
- // eslint-disable-next-line cypress/no-unnecessary-waiting
35
- cy.wait(1000, { log: false });
36
- cy.reloadUntil(selector, __assign(__assign({}, options), { attempts: options.attempts - 1 }));
37
- }
38
- else {
39
- var err = Error('Items not found.');
40
- log.error(err);
41
- throw err;
42
- }
43
- };
44
- exports.reloadUntil = reloadUntil;
package/yalc.lock DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "version": "v1",
3
- "packages": {
4
- "@jahia/cypress": {
5
- "signature": "1028ca2fa2d0700a1ab74a8ede774e57",
6
- "file": true
7
- }
8
- }
9
- }