@jahia/cypress 3.3.0 → 3.5.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.
Files changed (50) hide show
  1. package/dist/page-object/baseComponent.js +1 -0
  2. package/dist/page-object/html/iframe.js +1 -0
  3. package/dist/page-object/moonstone/pagination.js +1 -0
  4. package/dist/page-object/utils.d.ts +1 -1
  5. package/dist/page-object/utils.js +4 -3
  6. package/dist/support/apollo/apollo.js +2 -3
  7. package/dist/support/apollo/apolloClient.js +1 -2
  8. package/dist/support/apollo/links.d.ts +1 -1
  9. package/dist/support/apollo/links.js +3 -3
  10. package/dist/support/fixture.d.ts +1 -1
  11. package/dist/support/fixture.js +3 -3
  12. package/dist/support/provisioning/runProvisioningScript.js +3 -0
  13. package/dist/support/repeatUntil.js +1 -2
  14. package/dist/utils/JCRHelper.d.ts +11 -0
  15. package/dist/utils/JCRHelper.js +58 -0
  16. package/dist/utils/PublicationAndWorkflowHelper.d.ts +4 -0
  17. package/dist/utils/PublicationAndWorkflowHelper.js +59 -0
  18. package/dist/utils/SiteHelper.d.ts +8 -0
  19. package/dist/utils/SiteHelper.js +27 -0
  20. package/dist/utils/UsersHelper.d.ts +6 -0
  21. package/dist/utils/UsersHelper.js +34 -0
  22. package/dist/utils/VanityUrlHelper.d.ts +3 -0
  23. package/dist/utils/VanityUrlHelper.js +34 -0
  24. package/dist/utils/index.d.ts +5 -1
  25. package/dist/utils/index.js +5 -1
  26. package/fixtures/graphql/jcr/mutation/setPropertyValues.graphql +9 -0
  27. package/fixtures/graphql/jcr/mutation/startWorkflow.graphql +7 -0
  28. package/fixtures/groovy/admin/completeWorkflows.groovy +16 -0
  29. package/fixtures/groovy/admin/createSite.groovy +2 -1
  30. package/package.json +1 -1
  31. package/src/custom.d.ts +1 -0
  32. package/src/page-object/baseComponent.ts +1 -0
  33. package/src/page-object/html/iframe.ts +1 -0
  34. package/src/page-object/moonstone/pagination.ts +1 -0
  35. package/src/page-object/utils.ts +4 -3
  36. package/src/support/apollo/apollo.ts +2 -5
  37. package/src/support/apollo/apolloClient.ts +4 -5
  38. package/src/support/apollo/links.ts +1 -1
  39. package/src/support/fixture.ts +3 -3
  40. package/src/support/provisioning/runProvisioningScript.ts +5 -1
  41. package/src/support/repeatUntil.ts +2 -5
  42. package/src/utils/JCRHelper.ts +55 -0
  43. package/src/utils/PublicationAndWorkflowHelper.ts +55 -0
  44. package/src/utils/SiteHelper.ts +23 -0
  45. package/src/utils/UsersHelper.ts +30 -0
  46. package/src/utils/VanityUrlHelper.ts +30 -0
  47. package/src/utils/index.ts +5 -1
  48. package/dist/utils/Utils.d.ts +0 -24
  49. package/dist/utils/Utils.js +0 -172
  50. package/src/utils/Utils.ts +0 -166
@@ -18,6 +18,7 @@ var BaseComponent = /** @class */ (function () {
18
18
  }
19
19
  return cy.get('@component' + this.id, { log: false });
20
20
  };
21
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
21
22
  BaseComponent.prototype.should = function (arg) {
22
23
  var _a;
23
24
  var others = [];
@@ -26,6 +26,7 @@ var IFrame = /** @class */ (function (_super) {
26
26
  var fr = f[0];
27
27
  expect(fr.contentWindow.location.href).not.equals('about:blank');
28
28
  expect(fr.contentWindow.document.readyState).equals('complete');
29
+ // eslint-disable-next-line no-unused-expressions
29
30
  expect(fr.contentDocument.body).not.be.empty;
30
31
  })
31
32
  .its('0.contentDocument.body').as('framebody' + _this.id);
@@ -33,6 +33,7 @@ var Pagination = /** @class */ (function (_super) {
33
33
  return this;
34
34
  };
35
35
  Pagination.prototype.getTotalRows = function () {
36
+ // eslint-disable-next-line radix
36
37
  return this.get().contains('of').then(function (el) { return Number.parseInt(el.text().substr(el.text().indexOf('of') + 3)); });
37
38
  };
38
39
  Pagination.defaultSelector = '.moonstone-tablePagination';
@@ -8,4 +8,4 @@ export declare function getComponent<Component>(C: ComponentType<Component>, par
8
8
  export declare function getComponentByIndex<Component>(C: ComponentType<Component>, i: number, parent: Table, assertion?: (s: JQuery) => void): Component;
9
9
  export declare function getComponentByRole<Component>(C: ComponentType<Component>, role: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component;
10
10
  export declare function getComponentByAttr<Component>(C: ComponentType<Component>, attr: string, value: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component;
11
- export declare function getComponentByContent<Component>(c: ComponentType<Component>, content: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component;
11
+ export declare function getComponentByContent<Component>(C: ComponentType<Component>, content: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component;
@@ -25,15 +25,16 @@ function getComponentByRole(C, role, parent, assertion) {
25
25
  return getComponentBySelector(C, C.defaultSelector + "[data-sel-role=\"" + role + "\"]", parent, assertion);
26
26
  }
27
27
  exports.getComponentByRole = getComponentByRole;
28
+ // eslint-disable-next-line max-params
28
29
  function getComponentByAttr(C, attr, value, parent, assertion) {
29
30
  return getComponentBySelector(C, C.defaultSelector + "[" + attr + "=\"" + value + "\"]", parent, assertion);
30
31
  }
31
32
  exports.getComponentByAttr = getComponentByAttr;
32
- function getComponentByContent(c, content, parent, assertion) {
33
- var chainable = getElement(c.defaultSelector, parent).should('contains', content).contains(content);
33
+ function getComponentByContent(C, content, parent, assertion) {
34
+ var chainable = getElement(C.defaultSelector, parent).should('contains', content).contains(content);
34
35
  if (assertion) {
35
36
  chainable = chainable.should(assertion);
36
37
  }
37
- return new c(chainable, assertion);
38
+ return new C(chainable, assertion);
38
39
  }
39
40
  exports.getComponentByContent = getComponentByContent;
@@ -37,10 +37,9 @@ function isQueryFile(options) {
37
37
  function isMutationFile(options) {
38
38
  return options.mutationFile !== undefined;
39
39
  }
40
+ // eslint-disable-next-line default-param-last, @typescript-eslint/no-shadow
40
41
  var apollo = function (apollo, options) {
41
- if (!apollo) {
42
- apollo = this.currentApolloClient;
43
- }
42
+ if (apollo === void 0) { apollo = this.currentApolloClient; }
44
43
  var result;
45
44
  var logger;
46
45
  var optionsWithDefaultCache = __assign({ fetchPolicy: 'no-cache' }, options);
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
3
2
  exports.__esModule = true;
4
3
  exports.apolloClient = void 0;
5
4
  var core_1 = require("@apollo/client/core");
@@ -19,7 +18,7 @@ var apolloClient = function (authMethod, options) {
19
18
  else if (authMethod.username !== undefined && authMethod.password !== undefined) {
20
19
  headers.authorization = "Basic " + btoa(authMethod.username + ':' + authMethod.password);
21
20
  }
22
- var links = [links_1.uploadLink, links_1.FormDataHttpLink(Cypress.config().baseUrl, headers)];
21
+ var links = [links_1.uploadLink, links_1.formDataHttpLink(Cypress.config().baseUrl, headers)];
23
22
  var client = new core_1.ApolloClient({
24
23
  link: core_1.from(links),
25
24
  cache: new core_1.InMemoryCache(),
@@ -1,3 +1,3 @@
1
1
  import { HttpLink } from '@apollo/client/link/http';
2
- export declare const FormDataHttpLink: (baseUrl: string, headers: Object) => HttpLink;
2
+ export declare const formDataHttpLink: (baseUrl: string, headers: unknown) => HttpLink;
3
3
  export declare const uploadLink: import("@apollo/client/core").ApolloLink;
@@ -14,12 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  exports.__esModule = true;
17
- exports.uploadLink = exports.FormDataHttpLink = void 0;
17
+ exports.uploadLink = exports.formDataHttpLink = void 0;
18
18
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
19
19
  var http_1 = require("@apollo/client/link/http");
20
20
  var cross_fetch_1 = __importDefault(require("cross-fetch"));
21
21
  var context_1 = require("@apollo/client/link/context");
22
- var FormDataHttpLink = function (baseUrl, headers) {
22
+ var formDataHttpLink = function (baseUrl, headers) {
23
23
  return new http_1.HttpLink({
24
24
  uri: baseUrl + "/modules/graphql",
25
25
  headers: headers,
@@ -44,7 +44,7 @@ var FormDataHttpLink = function (baseUrl, headers) {
44
44
  }
45
45
  });
46
46
  };
47
- exports.FormDataHttpLink = FormDataHttpLink;
47
+ exports.formDataHttpLink = formDataHttpLink;
48
48
  exports.uploadLink = context_1.setContext(function (operation, _a) {
49
49
  var fetchOptions = _a.fetchOptions;
50
50
  var variables = operation.variables;
@@ -1,2 +1,2 @@
1
1
  import Chainable = Cypress.Chainable;
2
- export declare const fixture: (originalCommand: (...args: any[]) => any, fixture: string, ...args: any[]) => Chainable<any>;
2
+ export declare const fixture: (originalCommand: (...args: any[]) => any, fixtureParam: string, ...args: any[]) => Chainable<any>;
@@ -7,13 +7,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
7
7
  exports.__esModule = true;
8
8
  exports.fixture = void 0;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- var fixture = function (originalCommand, fixture) {
10
+ var fixture = function (originalCommand, fixtureParam) {
11
11
  var args = [];
12
12
  for (var _i = 2; _i < arguments.length; _i++) {
13
13
  args[_i - 2] = arguments[_i];
14
14
  }
15
15
  return cy.wrap({}, { log: false }).then(function () {
16
- return originalCommand.apply(void 0, __spreadArray([fixture], args)).then(function (f) {
16
+ return originalCommand.apply(void 0, __spreadArray([fixtureParam], args)).then(function (f) {
17
17
  return f;
18
18
  })["catch"](function () {
19
19
  return null;
@@ -25,7 +25,7 @@ var fixture = function (originalCommand, fixture) {
25
25
  encoding = args[0];
26
26
  }
27
27
  try {
28
- cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, { log: false, timeout: 200 });
28
+ cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixtureParam, encoding, { log: false, timeout: 200 });
29
29
  }
30
30
  catch (e) {
31
31
  console.log(e);
@@ -35,6 +35,7 @@ var serverDefaults = {
35
35
  function isFormFile(script) {
36
36
  return Boolean(script.fileContent || script.fileName);
37
37
  }
38
+ // eslint-disable-next-line default-param-last, max-params
38
39
  var runProvisioningScript = function (script, files, jahiaServer, options, timeout) {
39
40
  if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
40
41
  if (options === void 0) { options = { log: true }; }
@@ -53,7 +54,9 @@ var runProvisioningScript = function (script, files, jahiaServer, options, timeo
53
54
  append(f, formData, 'file');
54
55
  });
55
56
  }
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
58
  var response;
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
60
  var result;
58
61
  var logger;
59
62
  if (options.log) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
2
+ // Load type definitions that come with Cypress module <reference types="cypress" />
3
3
  var __assign = (this && this.__assign) || function () {
4
4
  __assign = Object.assign || function(t) {
5
5
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -39,7 +39,6 @@ var repeatUntil = function (selector, options) {
39
39
  if (options.attempts > 1) {
40
40
  log.end();
41
41
  options.callback();
42
- // eslint-disable-next-line cypress/no-unnecessary-waiting
43
42
  cy.wait(options.delay);
44
43
  cy.repeatUntil(selector, __assign(__assign({}, options), { attempts: options.attempts - 1 }));
45
44
  }
@@ -0,0 +1,11 @@
1
+ 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 deleteNodeProperty: (pathOrId: string, property: string, language: string) => Cypress.Chainable;
4
+ export declare const addNode: (variables: {
5
+ parentPathOrId: string;
6
+ primaryNodeType: string;
7
+ name: string;
8
+ properties?: any[];
9
+ children?: any[];
10
+ }) => Cypress.Chainable;
11
+ export declare const getNodeByPath: (path: string, properties?: string[], language?: string) => Cypress.Chainable;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.getNodeByPath = exports.addNode = exports.deleteNodeProperty = exports.deleteNode = exports.setNodeProperty = void 0;
4
+ var setNodeProperty = function (pathOrId, property, value, language) {
5
+ var mutationFile = 'graphql/jcr/mutation/setProperty.graphql';
6
+ if (value instanceof Array) {
7
+ mutationFile = 'graphql/jcr/mutation/setPropertyValues.graphql';
8
+ }
9
+ return cy.apollo({
10
+ variables: {
11
+ pathOrId: pathOrId,
12
+ property: property,
13
+ language: language,
14
+ value: value
15
+ },
16
+ mutationFile: mutationFile
17
+ });
18
+ };
19
+ exports.setNodeProperty = setNodeProperty;
20
+ var deleteNode = function (pathOrId) {
21
+ return cy.apollo({
22
+ variables: {
23
+ pathOrId: pathOrId
24
+ },
25
+ mutationFile: 'graphql/jcr/mutation/deleteNode.graphql'
26
+ });
27
+ };
28
+ exports.deleteNode = deleteNode;
29
+ var deleteNodeProperty = function (pathOrId, property, language) {
30
+ return cy.apollo({
31
+ variables: {
32
+ pathOrId: pathOrId,
33
+ property: property,
34
+ language: language
35
+ },
36
+ mutationFile: 'graphql/jcr/mutation/deleteNodeProperty.graphql'
37
+ });
38
+ };
39
+ exports.deleteNodeProperty = deleteNodeProperty;
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ var addNode = function (variables) {
42
+ return cy.apollo({
43
+ variables: variables,
44
+ mutationFile: 'graphql/jcr/mutation/addNode.graphql'
45
+ });
46
+ };
47
+ exports.addNode = addNode;
48
+ var getNodeByPath = function (path, properties, language) {
49
+ return cy.apollo({
50
+ variables: {
51
+ path: path,
52
+ properties: properties,
53
+ language: language
54
+ },
55
+ queryFile: 'graphql/jcr/query/getNodeByPath.graphql'
56
+ });
57
+ };
58
+ exports.getNodeByPath = getNodeByPath;
@@ -0,0 +1,4 @@
1
+ export declare const publishAndWaitJobEnding: (path: string, languages?: string[]) => void;
2
+ export declare const startWorkflow: (pathOrId: string, definition: string, language: string) => Cypress.Chainable;
3
+ export declare const validateAllWorkflows: () => void;
4
+ export declare const waitAllJobsFinished: (errorMessage?: string, timeout?: number) => void;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.waitAllJobsFinished = exports.validateAllWorkflows = exports.startWorkflow = exports.publishAndWaitJobEnding = void 0;
4
+ var publishAndWaitJobEnding = function (path, languages) {
5
+ if (languages === void 0) { languages = ['en']; }
6
+ cy.apollo({
7
+ variables: {
8
+ pathOrId: path,
9
+ languages: languages,
10
+ publishSubNodes: true,
11
+ includeSubTree: true
12
+ },
13
+ mutationFile: 'graphql/jcr/mutation/publishNode.graphql'
14
+ });
15
+ exports.waitAllJobsFinished('Publication timeout for node: ' + path, 60000);
16
+ };
17
+ exports.publishAndWaitJobEnding = publishAndWaitJobEnding;
18
+ var startWorkflow = function (pathOrId, definition, language) {
19
+ return cy.apollo({
20
+ variables: {
21
+ pathOrId: pathOrId,
22
+ definition: definition,
23
+ language: language
24
+ },
25
+ mutationFile: 'graphql/jcr/mutation/startWorkflow.graphql'
26
+ });
27
+ };
28
+ exports.startWorkflow = startWorkflow;
29
+ var validateAllWorkflows = function () {
30
+ cy.executeGroovy('groovy/admin/completeWorkflows.groovy');
31
+ exports.waitAllJobsFinished('All workflows validated but some jobs are still running after a minute', 60000);
32
+ };
33
+ exports.validateAllWorkflows = validateAllWorkflows;
34
+ var waitAllJobsFinished = function (errorMessage, timeout) {
35
+ if (timeout === void 0) { timeout = 60000; }
36
+ cy.waitUntil(function () {
37
+ return cy
38
+ .apollo({
39
+ fetchPolicy: 'no-cache',
40
+ queryFile: 'graphql/jcr/query/getJobsWithStatus.graphql'
41
+ })
42
+ .then(function (response) {
43
+ var _a, _b, _c, _d;
44
+ var jobs = (_d = (_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.scheduler) === null || _d === void 0 ? void 0 : _d.jobs;
45
+ var publicationJobs = jobs.filter(function (job) { return job.group === 'PublicationJob'; });
46
+ var hasActivePublicationJobs = publicationJobs.some(function (job) { return job.jobStatus === 'EXECUTING'; });
47
+ return !hasActivePublicationJobs;
48
+ });
49
+ }, {
50
+ errorMsg: errorMessage ? errorMessage : 'Jobs are still running before the end of timeout',
51
+ timeout: timeout,
52
+ verbose: true,
53
+ interval: 500
54
+ });
55
+ // Wait 0.5 seconds for server sync after publication
56
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
57
+ cy.wait(500);
58
+ };
59
+ exports.waitAllJobsFinished = waitAllJobsFinished;
@@ -0,0 +1,8 @@
1
+ export declare const createSite: (siteKey: string, config?: {
2
+ languages?: string;
3
+ templateSet: string;
4
+ serverName: string;
5
+ locale: string;
6
+ }) => void;
7
+ export declare const deleteSite: (siteKey: string) => void;
8
+ export declare const enableModule: (moduleName: string, siteKey: string) => void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.enableModule = exports.deleteSite = exports.createSite = void 0;
4
+ var createSite = function (siteKey, config) {
5
+ if (config === void 0) { config = { templateSet: 'dx-base-demo-templates', serverName: 'localhost', locale: 'en' }; }
6
+ cy.executeGroovy('groovy/admin/createSite.groovy', {
7
+ SITEKEY: siteKey,
8
+ TEMPLATES_SET: config.templateSet,
9
+ SERVERNAME: config.serverName,
10
+ LOCALE: config.locale,
11
+ LANGUAGES: config.languages || config.locale
12
+ });
13
+ };
14
+ exports.createSite = createSite;
15
+ var deleteSite = function (siteKey) {
16
+ cy.executeGroovy('groovy/admin/deleteSite.groovy', {
17
+ SITEKEY: siteKey
18
+ });
19
+ };
20
+ exports.deleteSite = deleteSite;
21
+ var enableModule = function (moduleName, siteKey) {
22
+ cy.runProvisioningScript({
23
+ fileContent: '- enable: "' + moduleName + '"\n site: "' + siteKey + '"',
24
+ type: 'application/yaml'
25
+ });
26
+ };
27
+ exports.enableModule = enableModule;
@@ -0,0 +1,6 @@
1
+ export declare const grantRoles: (pathOrId: string, roleNames: Array<string>, principalName: string, principalType: string) => Cypress.Chainable;
2
+ export declare const createUser: (userName: string, password: string, properties?: {
3
+ name: string;
4
+ value: string;
5
+ }[]) => void;
6
+ export declare const deleteUser: (userName: string) => void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.deleteUser = exports.createUser = exports.grantRoles = void 0;
4
+ var grantRoles = function (pathOrId, roleNames, principalName, principalType) {
5
+ cy.log('Grant role(s) ' + roleNames + ' with principal type ' + principalType + ' to ' + principalName + ' on node ' + pathOrId);
6
+ return cy.apollo({
7
+ variables: {
8
+ pathOrId: pathOrId,
9
+ roleNames: roleNames,
10
+ principalName: principalName,
11
+ principalType: principalType
12
+ },
13
+ mutationFile: 'graphql/jcr/mutation/grantRoles.graphql'
14
+ });
15
+ };
16
+ exports.grantRoles = grantRoles;
17
+ var createUser = function (userName, password, properties) {
18
+ if (properties === void 0) { properties = []; }
19
+ var userProperties = properties.map(function (property) {
20
+ return 'properties.setProperty("' + property.name + '", "' + property.value + '")';
21
+ });
22
+ cy.executeGroovy('groovy/admin/createUser.groovy', {
23
+ USER_NAME: userName,
24
+ PASSWORD: password ? password : 'password',
25
+ USER_PROPERTIES: userProperties ? userProperties.join('\n') : ''
26
+ });
27
+ };
28
+ exports.createUser = createUser;
29
+ var deleteUser = function (userName) {
30
+ cy.executeGroovy('groovy/admin/deleteUser.groovy', {
31
+ USER_NAME: userName
32
+ });
33
+ };
34
+ exports.deleteUser = deleteUser;
@@ -0,0 +1,3 @@
1
+ export declare const addVanityUrl: (pathOrId: string, language: string, url: string) => Cypress.Chainable;
2
+ export declare const getVanityUrl: (path: string, languages: Array<string>) => Cypress.Chainable;
3
+ export declare const removeVanityUrl: (pathOrId: string, url: string) => Cypress.Chainable;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.removeVanityUrl = exports.getVanityUrl = exports.addVanityUrl = void 0;
4
+ var addVanityUrl = function (pathOrId, language, url) {
5
+ return cy.apollo({
6
+ variables: {
7
+ pathOrId: pathOrId,
8
+ language: language,
9
+ url: url
10
+ },
11
+ mutationFile: 'graphql/jcr/mutation/addVanityUrl.graphql'
12
+ });
13
+ };
14
+ exports.addVanityUrl = addVanityUrl;
15
+ var getVanityUrl = function (path, languages) {
16
+ return cy.apollo({
17
+ variables: {
18
+ path: path,
19
+ languages: languages
20
+ },
21
+ queryFile: 'graphql/jcr/query/getVanityUrls.graphql'
22
+ });
23
+ };
24
+ exports.getVanityUrl = getVanityUrl;
25
+ var removeVanityUrl = function (pathOrId, url) {
26
+ return cy.apollo({
27
+ variables: {
28
+ pathOrId: pathOrId,
29
+ url: url
30
+ },
31
+ mutationFile: 'graphql/jcr/mutation/removeVanityUrl.graphql'
32
+ });
33
+ };
34
+ exports.removeVanityUrl = removeVanityUrl;
@@ -1 +1,5 @@
1
- export * from './Utils';
1
+ export * from './JCRHelper';
2
+ export * from './PublicationAndWorkflowHelper';
3
+ export * from './SiteHelper';
4
+ export * from './UsersHelper';
5
+ export * from './VanityUrlHelper';
@@ -10,4 +10,8 @@ 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("./Utils"), exports);
13
+ __exportStar(require("./JCRHelper"), exports);
14
+ __exportStar(require("./PublicationAndWorkflowHelper"), exports);
15
+ __exportStar(require("./SiteHelper"), exports);
16
+ __exportStar(require("./UsersHelper"), exports);
17
+ __exportStar(require("./VanityUrlHelper"), exports);
@@ -0,0 +1,9 @@
1
+ mutation setProperty($pathOrId: String!, $property: String!, $value: [String]!, $language: String!){
2
+ jcr{
3
+ mutateNode(pathOrId: $pathOrId){
4
+ mutateProperty(name: $property){
5
+ setValues(values: $value, language: $language)
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ mutation startWorkflow($pathOrId: String!, $definition: String!, $language: String!) {
2
+ jcr {
3
+ mutateNode(pathOrId:$pathOrId) {
4
+ startWorkflow(definition:$definition, language: $language)
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,16 @@
1
+ import org.jahia.api.Constants
2
+ import org.jahia.services.content.JCRTemplate
3
+ import org.jahia.services.usermanager.JahiaUserManagerService
4
+ import org.jahia.services.workflow.WorkflowService
5
+ import org.jahia.services.workflow.WorkflowTask
6
+
7
+
8
+ def rootUser = JahiaUserManagerService.instance.lookupUser("root").getJahiaUser()
9
+ def workflowService = WorkflowService.getInstance();
10
+ JCRTemplate.instance.doExecuteWithSystemSessionAsUser(rootUser,
11
+ Constants.EDIT_WORKSPACE, Locale.ENGLISH, jcrsession -> {
12
+ List<WorkflowTask> tasks = workflowService.getTasksForUser(rootUser, Locale.ENGLISH)
13
+ tasks.forEach(task -> workflowService.assignAndCompleteTask(task.getId(), task.getProvider(), "accept", null, rootUser))
14
+ log.info("Validate {} workflows task(s)", tasks.size());
15
+ return null;
16
+ });
@@ -5,6 +5,7 @@ import org.jahia.services.sites.JahiaSite
5
5
  import org.jahia.services.sites.JahiaSitesService
6
6
  import org.jahia.services.sites.SiteCreationInfo
7
7
  import org.jahia.services.usermanager.JahiaUserManagerService
8
+ import java.util.stream.Collectors
8
9
 
9
10
  JahiaSitesService sitesService = JahiaSitesService.getInstance();
10
11
  if (sitesService.getSiteByKey("SITEKEY") == null) {
@@ -18,7 +19,7 @@ if (sitesService.getSiteByKey("SITEKEY") == null) {
18
19
  JCRTemplate.instance.doExecuteWithSystemSessionAsUser(JahiaUserManagerService.instance.lookupUser("root").jahiaUser,
19
20
  Constants.EDIT_WORKSPACE, Locale.ENGLISH, jcrsession -> {
20
21
  JCRSiteNode siteByKey = sitesService.getSiteByKey("SITEKEY", jcrsession)
21
- siteByKey.setLanguages(new HashSet<String>(LANGUAGES))
22
+ siteByKey.setLanguages(Arrays.stream("LANGUAGES".split(",")).map(String::trim).collect(Collectors.toSet()))
22
23
  jcrsession.save()
23
24
  return null
24
25
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
package/src/custom.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  interface String {
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
3
  replaceAll(input: string, output : string): any;
3
4
  }
@@ -24,6 +24,7 @@ export class BaseComponent {
24
24
  return cy.get('@component' + this.id, {log: false});
25
25
  }
26
26
 
27
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
27
28
  should(arg, ...others) {
28
29
  return cy.get('@component' + this.id, {log: false}).should(arg, ...others);
29
30
  }
@@ -13,6 +13,7 @@ export class IFrame extends BaseComponent {
13
13
  const fr: HTMLFrameElement = f[0] as HTMLFrameElement;
14
14
  expect(fr.contentWindow.location.href).not.equals('about:blank');
15
15
  expect(fr.contentWindow.document.readyState).equals('complete');
16
+ // eslint-disable-next-line no-unused-expressions
16
17
  expect(fr.contentDocument.body).not.be.empty;
17
18
  })
18
19
  .its('0.contentDocument.body').as('framebody' + this.id);
@@ -17,6 +17,7 @@ export class Pagination extends BaseComponent {
17
17
  }
18
18
 
19
19
  getTotalRows(): Chainable<number> {
20
+ // eslint-disable-next-line radix
20
21
  return this.get().contains('of').then(el => Number.parseInt(el.text().substr(el.text().indexOf('of') + 3)));
21
22
  }
22
23
  }
@@ -27,15 +27,16 @@ export function getComponentByRole<Component >(C: ComponentType<Component>, role
27
27
  return getComponentBySelector(C, `${C.defaultSelector}[data-sel-role="${role}"]`, parent, assertion);
28
28
  }
29
29
 
30
+ // eslint-disable-next-line max-params
30
31
  export function getComponentByAttr<Component>(C: ComponentType<Component>, attr: string, value: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
31
32
  return getComponentBySelector(C, `${C.defaultSelector}[${attr}="${value}"]`, parent, assertion);
32
33
  }
33
34
 
34
- export function getComponentByContent<Component>(c: ComponentType<Component>, content: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
35
- let chainable = getElement(c.defaultSelector, parent).should('contains', content).contains(content);
35
+ export function getComponentByContent<Component>(C: ComponentType<Component>, content: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
36
+ let chainable = getElement(C.defaultSelector, parent).should('contains', content).contains(content);
36
37
  if (assertion) {
37
38
  chainable = chainable.should(assertion);
38
39
  }
39
40
 
40
- return new c(chainable, assertion);
41
+ return new C(chainable, assertion);
41
42
  }
@@ -31,11 +31,8 @@ function isMutationFile(options: ApolloOptions): options is FileMutationOptions
31
31
  return (<FileMutationOptions>options).mutationFile !== undefined;
32
32
  }
33
33
 
34
- export const apollo = function (apollo: ApolloClient<any>, options: ApolloOptions): void {
35
- if (!apollo) {
36
- apollo = this.currentApolloClient;
37
- }
38
-
34
+ // eslint-disable-next-line default-param-last, @typescript-eslint/no-shadow
35
+ export const apollo = function (apollo: ApolloClient<any> = this.currentApolloClient, options: ApolloOptions): void {
39
36
  let result : ApolloQueryResult<any> | FetchResult;
40
37
  let logger : Cypress.Log;
41
38
  const optionsWithDefaultCache: ApolloOptions = {fetchPolicy: 'no-cache', ...options};
@@ -1,7 +1,5 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
2
-
3
- import {ApolloClient, from, HttpLink, InMemoryCache, NormalizedCacheObject} from '@apollo/client/core';
4
- import {FormDataHttpLink, uploadLink} from './links';
1
+ import {ApolloClient, from, InMemoryCache, NormalizedCacheObject} from '@apollo/client/core';
2
+ import {formDataHttpLink, uploadLink} from './links';
5
3
 
6
4
  interface AuthMethod {
7
5
  token?: string
@@ -10,6 +8,7 @@ interface AuthMethod {
10
8
  }
11
9
 
12
10
  declare global {
11
+ // eslint-disable-next-line @typescript-eslint/no-namespace
13
12
  namespace Cypress {
14
13
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
14
  interface Chainable<Subject> {
@@ -35,7 +34,7 @@ export const apolloClient = function (authMethod?: AuthMethod, options: ApolloCl
35
34
  headers.authorization = `Basic ${btoa(authMethod.username + ':' + authMethod.password)}`;
36
35
  }
37
36
 
38
- const links = [uploadLink, FormDataHttpLink(Cypress.config().baseUrl, headers)];
37
+ const links = [uploadLink, formDataHttpLink(Cypress.config().baseUrl, headers)];
39
38
 
40
39
  const client = new ApolloClient({
41
40
  link: from(links),
@@ -7,7 +7,7 @@ interface ApolloRequestInit extends RequestInit {
7
7
  formData?: FormData
8
8
  }
9
9
 
10
- export const FormDataHttpLink = (baseUrl: string, headers: Object) => {
10
+ export const formDataHttpLink = (baseUrl: string, headers: unknown) => {
11
11
  return new HttpLink({
12
12
  uri: `${baseUrl}/modules/graphql`,
13
13
  headers,