@jahia/cypress 2.0.0 → 3.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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/page-object/html/iframe.d.ts +1 -1
  6. package/dist/page-object/material/muiinput.d.ts +1 -1
  7. package/dist/page-object/material/muiradio.d.ts +1 -1
  8. package/dist/page-object/moonstone/accordion.d.ts +1 -1
  9. package/dist/page-object/moonstone/button.d.ts +1 -1
  10. package/dist/page-object/moonstone/collapsible.d.ts +1 -1
  11. package/dist/page-object/moonstone/dropdown.d.ts +1 -1
  12. package/dist/page-object/moonstone/menu.d.ts +1 -1
  13. package/dist/page-object/moonstone/menu.js +1 -1
  14. package/dist/page-object/moonstone/pagination.d.ts +1 -1
  15. package/dist/page-object/moonstone/primaryNav.d.ts +1 -1
  16. package/dist/page-object/moonstone/primaryNav.js +1 -1
  17. package/dist/page-object/moonstone/secondaryNav.d.ts +1 -1
  18. package/dist/page-object/moonstone/table.d.ts +2 -2
  19. package/dist/page-object/utils.d.ts +2 -2
  20. package/dist/support/apollo/apollo.js +39 -41
  21. package/dist/support/apollo/apolloClient.js +1 -1
  22. package/dist/support/apollo/links.js +3 -5
  23. package/dist/support/commands.d.ts +1 -0
  24. package/dist/support/commands.js +3 -0
  25. package/dist/support/fixture.js +1 -1
  26. package/dist/support/logout.js +1 -1
  27. package/dist/support/provisioning/runProvisioningScript.js +6 -4
  28. package/dist/utils/Utils.d.ts +13 -0
  29. package/dist/utils/Utils.js +90 -0
  30. package/dist/utils/index.d.ts +1 -0
  31. package/dist/utils/index.js +13 -0
  32. package/fixtures/graphql/jcr/mutation/addNode.graphql +18 -0
  33. package/fixtures/graphql/jcr/{deleteNode.graphql → mutation/deleteNode.graphql} +1 -1
  34. package/fixtures/graphql/jcr/mutation/grantRoles.graphql +16 -0
  35. package/fixtures/graphql/jcr/mutation/setProperty.graphql +9 -0
  36. package/fixtures/graphql/jcr/query/getJobsWithStatus.graphql +13 -0
  37. package/fixtures/graphql/jcr/query/getNodeByPath.graphql +15 -0
  38. package/fixtures/groovy/admin/createSite.groovy +14 -3
  39. package/package.json +6 -1
  40. package/schema.graphql +941 -76
  41. package/src/custom.d.ts +1 -1
  42. package/src/index.ts +4 -3
  43. package/src/page-object/baseComponent.ts +7 -7
  44. package/src/page-object/basePage.ts +1 -1
  45. package/src/page-object/html/iframe.ts +12 -13
  46. package/src/page-object/html/index.ts +1 -1
  47. package/src/page-object/index.ts +6 -6
  48. package/src/page-object/material/index.ts +2 -2
  49. package/src/page-object/material/muiinput.ts +5 -7
  50. package/src/page-object/material/muiradio.ts +3 -5
  51. package/src/page-object/moonstone/accordion.ts +7 -8
  52. package/src/page-object/moonstone/button.ts +3 -5
  53. package/src/page-object/moonstone/collapsible.ts +9 -10
  54. package/src/page-object/moonstone/dropdown.ts +6 -8
  55. package/src/page-object/moonstone/index.ts +9 -9
  56. package/src/page-object/moonstone/menu.ts +8 -8
  57. package/src/page-object/moonstone/pagination.ts +8 -9
  58. package/src/page-object/moonstone/primaryNav.ts +5 -5
  59. package/src/page-object/moonstone/secondaryNav.ts +3 -3
  60. package/src/page-object/moonstone/table.ts +9 -10
  61. package/src/page-object/utils.ts +12 -10
  62. package/src/plugins/env.ts +13 -12
  63. package/src/plugins/index.ts +1 -1
  64. package/src/plugins/registerPlugins.ts +3 -3
  65. package/src/support/apollo/apollo.ts +47 -49
  66. package/src/support/apollo/apolloClient.ts +18 -18
  67. package/src/support/apollo/index.ts +2 -2
  68. package/src/support/apollo/links.ts +38 -37
  69. package/src/support/commands.ts +1 -0
  70. package/src/support/fixture.ts +8 -8
  71. package/src/support/index.ts +5 -5
  72. package/src/support/login.ts +8 -10
  73. package/src/support/logout.ts +7 -8
  74. package/src/support/provisioning/executeGroovy.ts +3 -5
  75. package/src/support/provisioning/index.ts +3 -3
  76. package/src/support/provisioning/installBundle.ts +3 -5
  77. package/src/support/provisioning/runProvisioningScript.ts +34 -33
  78. package/src/support/registerSupport.ts +16 -16
  79. package/src/support/repeatUntil.ts +19 -19
  80. package/src/utils/Utils.ts +86 -0
  81. package/src/utils/index.ts +1 -0
  82. package/fixtures/graphql/jcr/addNode.graphql +0 -16
  83. /package/fixtures/graphql/jcr/{mutateNode.graphql → mutation/mutateNode.graphql} +0 -0
package/src/custom.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  interface String {
2
2
  replaceAll(input: string, output : string): any;
3
- }
3
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from './page-object'
2
- export * from './plugins'
3
- export * from './support'
1
+ export * from './page-object';
2
+ export * from './plugins';
3
+ export * from './support';
4
+ export * from './utils';
@@ -11,20 +11,20 @@ export class BaseComponent {
11
11
  assertion?: (s: JQuery) => void
12
12
 
13
13
  constructor(element: Chainable<JQuery>, assertion?: (s: JQuery) => void) {
14
- this.id = BaseComponent.count++
15
- this.element = element.as('component' + this.id)
16
- this.assertion = assertion
14
+ this.id = BaseComponent.count++;
15
+ this.element = element.as('component' + this.id);
16
+ this.assertion = assertion;
17
17
  }
18
18
 
19
19
  get(): Chainable<JQuery> {
20
20
  if (this.assertion) {
21
- return cy.get('@component' + this.id, {log: false}).should(this.assertion)
21
+ return cy.get('@component' + this.id, {log: false}).should(this.assertion);
22
22
  }
23
23
 
24
- return cy.get('@component' + this.id, {log: false})
24
+ return cy.get('@component' + this.id, {log: false});
25
25
  }
26
26
 
27
27
  should(arg, ...others) {
28
- return cy.get('@component' + this.id, {log: false}).should(arg, ...others)
28
+ return cy.get('@component' + this.id, {log: false}).should(arg, ...others);
29
29
  }
30
- }
30
+ }
@@ -1,2 +1,2 @@
1
1
  export class BasePage {
2
- }
2
+ }
@@ -1,4 +1,4 @@
1
- import {BaseComponent} from "../baseComponent"
1
+ import {BaseComponent} from '../baseComponent';
2
2
  import Chainable = Cypress.Chainable;
3
3
 
4
4
  export class IFrame extends BaseComponent {
@@ -7,26 +7,25 @@ export class IFrame extends BaseComponent {
7
7
  private body: JQuery<HTMLElement>
8
8
 
9
9
  constructor(element: Chainable<JQuery>, assertion?: (s: JQuery) => void) {
10
- super(element, assertion)
10
+ super(element, assertion);
11
11
  this.get()
12
12
  .should(f => {
13
- const fr: HTMLFrameElement = f[0] as HTMLFrameElement
14
- expect(fr.contentWindow.location.href).not.equals('about:blank')
15
- expect(fr.contentWindow.document.readyState).equals('complete')
16
- expect(fr.contentDocument.body).not.be.empty
13
+ const fr: HTMLFrameElement = f[0] as HTMLFrameElement;
14
+ expect(fr.contentWindow.location.href).not.equals('about:blank');
15
+ expect(fr.contentWindow.document.readyState).equals('complete');
16
+ expect(fr.contentDocument.body).not.be.empty;
17
17
  })
18
- .its('0.contentDocument.body').as('framebody' + this.id)
18
+ .its('0.contentDocument.body').as('framebody' + this.id);
19
19
  }
20
20
 
21
21
  getBody(): Chainable<JQuery> {
22
- return cy.get('@framebody' + this.id)
22
+ return cy.get('@framebody' + this.id);
23
23
  }
24
24
 
25
25
  enter(): void {
26
26
  this.get().then(f => {
27
- const fr: HTMLFrameElement = f[0] as HTMLFrameElement
28
- cy.visit(fr.contentWindow.location.href)
29
- })
27
+ const fr: HTMLFrameElement = f[0] as HTMLFrameElement;
28
+ cy.visit(fr.contentWindow.location.href);
29
+ });
30
30
  }
31
-
32
- }
31
+ }
@@ -1 +1 @@
1
- export * from './iframe'
1
+ export * from './iframe';
@@ -1,6 +1,6 @@
1
- export * from './baseComponent'
2
- export * from './basePage'
3
- export * from './html'
4
- export * from './material'
5
- export * from './moonstone'
6
- export * from './utils'
1
+ export * from './baseComponent';
2
+ export * from './basePage';
3
+ export * from './html';
4
+ export * from './material';
5
+ export * from './moonstone';
6
+ export * from './utils';
@@ -1,2 +1,2 @@
1
- export * from './muiinput'
2
- export * from './muiradio'
1
+ export * from './muiinput';
2
+ export * from './muiradio';
@@ -1,19 +1,17 @@
1
- import {BaseComponent} from "../baseComponent"
1
+ import {BaseComponent} from '../baseComponent';
2
2
  import TypeOptions = Cypress.TypeOptions;
3
3
 
4
4
  export class MUIInput extends BaseComponent {
5
5
  static defaultSelector = 'div'
6
6
 
7
7
  clear(): MUIInput {
8
- this.get().clear()
9
- return this
8
+ this.get().clear();
9
+ return this;
10
10
  }
11
11
 
12
12
  type(text: string, options?: Partial<TypeOptions>): MUIInput {
13
- this.get().type(text, options)
14
- return this
13
+ this.get().type(text, options);
14
+ return this;
15
15
  }
16
-
17
16
  }
18
17
 
19
-
@@ -1,13 +1,11 @@
1
- import {BaseComponent} from "../baseComponent"
2
-
1
+ import {BaseComponent} from '../baseComponent';
3
2
 
4
3
  export class MUIRadio extends BaseComponent {
5
4
  static defaultSelector = 'label'
6
5
 
7
6
  click(): MUIRadio {
8
- this.get().click()
9
- return this
7
+ this.get().click();
8
+ return this;
10
9
  }
11
-
12
10
  }
13
11
 
@@ -1,22 +1,21 @@
1
- import {BaseComponent} from "../baseComponent"
1
+ import {BaseComponent} from '../baseComponent';
2
2
  import Chainable = Cypress.Chainable;
3
3
 
4
4
  export class Accordion extends BaseComponent {
5
5
  static defaultSelector = '.moonstone-accordion'
6
6
 
7
7
  click(itemName: string): Accordion {
8
- this.get().find(`section.moonstone-accordionItem header[aria-controls="${itemName}"]`).click()
9
- return this
8
+ this.get().find(`section.moonstone-accordionItem header[aria-controls="${itemName}"]`).click();
9
+ return this;
10
10
  }
11
11
 
12
12
  listItems(): Chainable<string[]> {
13
13
  return this.get().find('section.moonstone-accordionItem header').then(items => {
14
- return Array.prototype.slice.call(items, 0).map(i => i.attributes['aria-controls'] ? i.attributes['aria-controls'].value : null).filter(i => i !== null)
15
- })
14
+ return Array.prototype.slice.call(items, 0).map(i => i.attributes['aria-controls'] ? i.attributes['aria-controls'].value : null).filter(i => i !== null);
15
+ });
16
16
  }
17
17
 
18
18
  getContent(): Chainable<JQuery> {
19
- return this.get().find('section.moonstone-accordionItem .moonstone-accordionItem_content')
19
+ return this.get().find('section.moonstone-accordionItem .moonstone-accordionItem_content');
20
20
  }
21
-
22
- }
21
+ }
@@ -1,13 +1,11 @@
1
- import {BaseComponent} from "../baseComponent"
2
-
1
+ import {BaseComponent} from '../baseComponent';
3
2
 
4
3
  export class Button extends BaseComponent {
5
4
  static defaultSelector = '.moonstone-button'
6
5
 
7
6
  click(): Button {
8
- this.get().click()
9
- return this
7
+ this.get().click();
8
+ return this;
10
9
  }
11
-
12
10
  }
13
11
 
@@ -1,24 +1,23 @@
1
- import {BaseComponent} from "../baseComponent"
2
-
1
+ import {BaseComponent} from '../baseComponent';
3
2
 
4
3
  export class Collapsible extends BaseComponent {
5
4
  static defaultSelector = '.moonstone-collapsible'
6
5
 
7
6
  collapse(): Collapsible {
8
- this.get().children('div').then(($child) => {
7
+ this.get().children('div').then($child => {
9
8
  if ($child.hasClass('moonstone-collapsible_content_expanded')) {
10
- this.get().find('.moonstone-collapsible_button').click()
9
+ this.get().find('.moonstone-collapsible_button').click();
11
10
  }
12
- })
13
- return this
11
+ });
12
+ return this;
14
13
  }
15
14
 
16
15
  expand(): Collapsible {
17
- this.get().children('div').then(($child) => {
16
+ this.get().children('div').then($child => {
18
17
  if ($child.hasClass('moonstone-collapsible_content_collapsed')) {
19
- this.get().find('.moonstone-collapsible_button').click().scrollIntoView()
18
+ this.get().find('.moonstone-collapsible_button').click().scrollIntoView();
20
19
  }
21
- })
22
- return this
20
+ });
21
+ return this;
23
22
  }
24
23
  }
@@ -1,16 +1,14 @@
1
- import {BaseComponent} from "../baseComponent"
2
- import {Menu} from "./menu";
3
- import {getComponent} from "../utils";
4
-
1
+ import {BaseComponent} from '../baseComponent';
2
+ import {Menu} from './menu';
3
+ import {getComponent} from '../utils';
5
4
 
6
5
  export class Dropdown extends BaseComponent {
7
6
  static defaultSelector = '.moonstone-dropdown_container'
8
7
 
9
8
  select(item: string): Dropdown {
10
- this.get().click()
11
- getComponent(Menu).select(item)
12
- return this
9
+ this.get().click();
10
+ getComponent(Menu).select(item);
11
+ return this;
13
12
  }
14
-
15
13
  }
16
14
 
@@ -1,9 +1,9 @@
1
- export * from './accordion'
2
- export * from './button'
3
- export * from './collapsible'
4
- export * from './dropdown'
5
- export * from './menu'
6
- export * from './pagination'
7
- export * from './primaryNav'
8
- export * from './secondaryNav'
9
- export * from './table'
1
+ export * from './accordion';
2
+ export * from './button';
3
+ export * from './collapsible';
4
+ export * from './dropdown';
5
+ export * from './menu';
6
+ export * from './pagination';
7
+ export * from './primaryNav';
8
+ export * from './secondaryNav';
9
+ export * from './table';
@@ -1,19 +1,19 @@
1
- import {BaseComponent} from "../baseComponent"
1
+ import {BaseComponent} from '../baseComponent';
2
2
 
3
3
  export class Menu extends BaseComponent {
4
4
  static defaultSelector = '.moonstone-menu:visible'
5
5
 
6
6
  select(item: string): Menu {
7
7
  // eslint-disable-next-line cypress/no-unnecessary-waiting
8
- cy.wait(500)
9
- this.get().find(`.moonstone-menuItem`).should("contain", item).contains(item).trigger('click')
10
- return this
8
+ cy.wait(500);
9
+ this.get().find('.moonstone-menuItem').should('contain', item).contains(item).trigger('click');
10
+ return this;
11
11
  }
12
12
 
13
13
  selectByRole(item: string): Menu {
14
14
  // eslint-disable-next-line cypress/no-unnecessary-waiting
15
- cy.wait(500)
16
- this.get().find(`.moonstone-menuItem[data-sel-role="${item}"]`).trigger('click')
17
- return this
15
+ cy.wait(500);
16
+ this.get().find(`.moonstone-menuItem[data-sel-role="${item}"]`).trigger('click');
17
+ return this;
18
18
  }
19
- }
19
+ }
@@ -1,24 +1,23 @@
1
- import {BaseComponent} from "../baseComponent"
2
- import {Button} from "./button";
1
+ import {BaseComponent} from '../baseComponent';
2
+ import {Button} from './button';
3
3
  import Chainable = Cypress.Chainable;
4
- import {getComponentByRole} from "../utils";
4
+ import {getComponentByRole} from '../utils';
5
5
 
6
6
  export class Pagination extends BaseComponent {
7
7
  static defaultSelector = '.moonstone-tablePagination'
8
8
 
9
9
  clickNextPage(): Pagination {
10
- getComponentByRole(Button, 'table-pagination-button-next-page', this).click()
11
- return this
10
+ getComponentByRole(Button, 'table-pagination-button-next-page', this).click();
11
+ return this;
12
12
  }
13
13
 
14
14
  clickPreviousPage(): Pagination {
15
- getComponentByRole(Button, 'table-pagination-button-previous-page', this).click()
16
- return this
15
+ getComponentByRole(Button, 'table-pagination-button-previous-page', this).click();
16
+ return this;
17
17
  }
18
18
 
19
19
  getTotalRows(): Chainable<number> {
20
- return this.get().contains('of').then(el => Number.parseInt(el.text().substr(el.text().indexOf('of') +3)))
20
+ return this.get().contains('of').then(el => Number.parseInt(el.text().substr(el.text().indexOf('of') + 3)));
21
21
  }
22
-
23
22
  }
24
23
 
@@ -1,16 +1,16 @@
1
- import {BaseComponent} from "../baseComponent"
1
+ import {BaseComponent} from '../baseComponent';
2
2
  import Chainable = Cypress.Chainable;
3
3
 
4
4
  export class PrimaryNav extends BaseComponent {
5
5
  static defaultSelector = '.moonstone-primaryNav'
6
6
 
7
7
  click(itemName: string): void {
8
- this.get().find(`.moonstone-primaryNavItem[role="${itemName}"]`).click()
8
+ this.get().find(`.moonstone-primaryNavItem[role="${itemName}"]`).click();
9
9
  }
10
10
 
11
11
  listItems(): Chainable<string[]> {
12
12
  return this.get().find('.moonstone-primaryNavItem').then(items => {
13
- return Array.prototype.slice.call(items, 0).map(i => i.attributes['role'] ? i.attributes['role'].value : null).filter(i => i !== null)
14
- })
13
+ return Array.prototype.slice.call(items, 0).map(i => i.attributes.role ? i.attributes.role.value : null).filter(i => i !== null);
14
+ });
15
15
  }
16
- }
16
+ }
@@ -1,5 +1,5 @@
1
- import {BaseComponent} from "../baseComponent"
1
+ import {BaseComponent} from '../baseComponent';
2
2
 
3
- export class SecondaryNav extends BaseComponent{
3
+ export class SecondaryNav extends BaseComponent {
4
4
  static defaultSelector = '.moonstone-secondaryNav_wrapper'
5
- }
5
+ }
@@ -1,20 +1,20 @@
1
- import {BaseComponent} from "../baseComponent"
2
- import {Menu} from "./menu"
3
- import {getComponent, getComponentByContent, getComponentByIndex, getComponentBySelector} from "../utils";
1
+ import {BaseComponent} from '../baseComponent';
2
+ import {Menu} from './menu';
3
+ import {getComponent, getComponentByContent, getComponentByIndex, getComponentBySelector} from '../utils';
4
4
 
5
5
  export class Table extends BaseComponent {
6
6
  static defaultSelector = '.moonstone-Table'
7
7
 
8
8
  getRows(assertion?: (s: JQuery) => void): TableRow {
9
- return getComponent(TableRow, this, assertion)
9
+ return getComponent(TableRow, this, assertion);
10
10
  }
11
11
 
12
12
  getRowByIndex(i: number, assertion?: (s: JQuery) => void): TableRow {
13
- return getComponentByIndex(TableRow, i, this, assertion)
13
+ return getComponentByIndex(TableRow, i, this, assertion);
14
14
  }
15
15
 
16
16
  getRowByContent(content: string, assertion?: (s: JQuery) => void): TableRow {
17
- return getComponentByContent(TableRow, content, this, assertion)
17
+ return getComponentByContent(TableRow, content, this, assertion);
18
18
  }
19
19
  }
20
20
 
@@ -22,8 +22,7 @@ export class TableRow extends BaseComponent {
22
22
  static defaultSelector = '.moonstone-TableBody .moonstone-TableRow'
23
23
 
24
24
  contextMenu(): Menu {
25
- this.get().rightclick()
26
- return getComponentBySelector(Menu, '#menuHolder .moonstone-menu:not(.moonstone-hidden)')
25
+ this.get().rightclick();
26
+ return getComponentBySelector(Menu, '#menuHolder .moonstone-menu:not(.moonstone-hidden)');
27
27
  }
28
-
29
- }
28
+ }
@@ -1,39 +1,41 @@
1
- import {Table} from "./moonstone";
2
- import {BaseComponent, ComponentType} from "./baseComponent";
1
+ import {Table} from './moonstone';
2
+ import {BaseComponent, ComponentType} from './baseComponent';
3
3
  import Chainable = Cypress.Chainable;
4
4
 
5
5
  export function getElement(selector: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Chainable<JQuery> {
6
6
  const chainable = parent ? parent.get().find(selector) : cy.get(selector);
7
7
  if (assertion) {
8
- return chainable.should(assertion)
8
+ return chainable.should(assertion);
9
9
  }
10
+
10
11
  return chainable;
11
12
  }
12
13
 
13
14
  export function getComponentBySelector<Component>(C: ComponentType<Component>, selector: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
14
- return new C(getElement(selector, parent, assertion), assertion)
15
+ return new C(getElement(selector, parent, assertion), assertion);
15
16
  }
16
17
 
17
18
  export function getComponent<Component>(C: ComponentType<Component>, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
18
- return getComponentBySelector(C, C.defaultSelector, parent, assertion)
19
+ return getComponentBySelector(C, C.defaultSelector, parent, assertion);
19
20
  }
20
21
 
21
22
  export function getComponentByIndex<Component>(C: ComponentType<Component>, i: number, parent: Table, assertion?: (s: JQuery) => void): Component {
22
- return getComponentBySelector(C, `${C.defaultSelector}:nth-child(${i})`, parent, assertion)
23
+ return getComponentBySelector(C, `${C.defaultSelector}:nth-child(${i})`, parent, assertion);
23
24
  }
24
25
 
25
26
  export function getComponentByRole<Component >(C: ComponentType<Component>, role: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
26
- return getComponentBySelector(C, `${C.defaultSelector}[data-sel-role="${role}"]`, parent, assertion)
27
+ return getComponentBySelector(C, `${C.defaultSelector}[data-sel-role="${role}"]`, parent, assertion);
27
28
  }
28
29
 
29
30
  export function getComponentByAttr<Component>(C: ComponentType<Component>, attr: string, value: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
30
- return getComponentBySelector(C, `${C.defaultSelector}[${attr}="${value}"]`, parent, assertion)
31
+ return getComponentBySelector(C, `${C.defaultSelector}[${attr}="${value}"]`, parent, assertion);
31
32
  }
32
33
 
33
34
  export function getComponentByContent<Component>(c: ComponentType<Component>, content: string, parent?: BaseComponent, assertion?: (s: JQuery) => void): Component {
34
35
  let chainable = getElement(c.defaultSelector, parent).should('contains', content).contains(content);
35
36
  if (assertion) {
36
- chainable = chainable.should(assertion)
37
+ chainable = chainable.should(assertion);
37
38
  }
38
- return new c(chainable, assertion)
39
+
40
+ return new c(chainable, assertion);
39
41
  }
@@ -1,19 +1,20 @@
1
1
  const env = (on:Cypress.PluginEvents, config: Cypress.PluginConfigOptions):Cypress.PluginConfigOptions => {
2
2
  if (!process.env.JAHIA_URL && !process.env.SUPER_USER_PASSWORD) {
3
- console.warn('No environment set, will use default values')
4
- config.baseUrl = 'http://localhost:8080'
5
- config.env.JAHIA_URL = 'http://localhost:8080'
6
- config.env.SUPER_USER_PASSWORD = 'root1234'
3
+ console.warn('No environment set, will use default values');
4
+ config.baseUrl = 'http://localhost:8080';
5
+ config.env.JAHIA_URL = 'http://localhost:8080';
6
+ config.env.SUPER_USER_PASSWORD = 'root1234';
7
7
  } else {
8
8
  console.log('Setting environment');
9
- config.baseUrl = process.env.JAHIA_URL
10
- config.env.JAHIA_URL = process.env.JAHIA_URL
11
- config.env.SUPER_USER_PASSWORD = process.env.SUPER_USER_PASSWORD
9
+ config.baseUrl = process.env.JAHIA_URL;
10
+ config.env.JAHIA_URL = process.env.JAHIA_URL;
11
+ config.env.SUPER_USER_PASSWORD = process.env.SUPER_USER_PASSWORD;
12
12
  }
13
- console.log('JAHIA_URL =', config.env.JAHIA_URL)
14
- console.log('SUPER_USER_PASSWORD =', config.env.SUPER_USER_PASSWORD)
15
13
 
16
- return config
17
- }
14
+ console.log('JAHIA_URL =', config.env.JAHIA_URL);
15
+ console.log('SUPER_USER_PASSWORD =', config.env.SUPER_USER_PASSWORD);
18
16
 
19
- export default env
17
+ return config;
18
+ };
19
+
20
+ export default env;
@@ -1 +1 @@
1
- export * from './env'
1
+ export * from './env';
@@ -1,5 +1,5 @@
1
- import env from "./env"
1
+ import env from './env';
2
2
 
3
3
  export const registerPlugins = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions): void => {
4
- env(on, config)
5
- }
4
+ env(on, config);
5
+ };
@@ -3,8 +3,8 @@
3
3
  // Load type definitions that come with Cypress module
4
4
  /// <reference types="cypress" />
5
5
 
6
- import {ApolloClient, ApolloQueryResult, FetchResult, MutationOptions, QueryOptions} from '@apollo/client/core'
7
- import gql from "graphql-tag";
6
+ import {ApolloClient, ApolloQueryResult, FetchResult, MutationOptions, QueryOptions} from '@apollo/client/core';
7
+ import gql from 'graphql-tag';
8
8
 
9
9
  declare global {
10
10
  namespace Cypress {
@@ -33,57 +33,55 @@ function isMutationFile(options: ApolloOptions): options is FileMutationOptions
33
33
 
34
34
  export const apollo = function (apollo: ApolloClient<any>, options: ApolloOptions): void {
35
35
  if (!apollo) {
36
- apollo = this.currentApolloClient
36
+ apollo = this.currentApolloClient;
37
37
  }
38
38
 
39
- let result : ApolloQueryResult<any> | FetchResult
40
- let logger : Cypress.Log
41
- const optionsWithDefaultCache: ApolloOptions = {fetchPolicy: "no-cache", ...options}
39
+ let result : ApolloQueryResult<any> | FetchResult;
40
+ let logger : Cypress.Log;
41
+ const optionsWithDefaultCache: ApolloOptions = {fetchPolicy: 'no-cache', ...options};
42
42
 
43
43
  if (!apollo) {
44
- cy.apolloClient().apollo(optionsWithDefaultCache)
44
+ cy.apolloClient().apollo(optionsWithDefaultCache);
45
+ } else if (isQueryFile(optionsWithDefaultCache)) {
46
+ const {queryFile, ...apolloOptions} = optionsWithDefaultCache;
47
+ cy.fixture(queryFile).then(content => {
48
+ cy.apollo({query: gql(content), ...apolloOptions});
49
+ });
50
+ } else if (isMutationFile(optionsWithDefaultCache)) {
51
+ const {mutationFile, ...apolloOptions} = optionsWithDefaultCache;
52
+ cy.fixture(mutationFile).then(content => {
53
+ cy.apollo({mutation: gql(content), ...apolloOptions});
54
+ });
45
55
  } else {
46
- if (isQueryFile(optionsWithDefaultCache)) {
47
- const {queryFile, ...apolloOptions} = optionsWithDefaultCache
48
- cy.fixture(queryFile).then(content => {
49
- cy.apollo({query: gql(content), ...apolloOptions})
50
- })
51
- } else if (isMutationFile(optionsWithDefaultCache)) {
52
- const {mutationFile, ...apolloOptions} = optionsWithDefaultCache
53
- cy.fixture(mutationFile).then(content => {
54
- cy.apollo({mutation: gql(content), ...apolloOptions})
55
- })
56
- } else {
57
- const {log = true, ...apolloOptions} = optionsWithDefaultCache
58
- if (log) {
59
- logger = Cypress.log({
60
- autoEnd: false,
61
- name: 'apollo',
62
- displayName: 'apollo',
63
- message: isQuery(apolloOptions) ? `Execute Graphql Query: ${apolloOptions.query.loc.source.body}` : `Execute Graphql Mutation: ${apolloOptions.mutation.loc.source.body}`,
64
- consoleProps: () => {
65
- return {
66
- Options: apolloOptions,
67
- Yielded: result
68
- }
69
- },
70
- })
71
- }
72
-
73
- cy.wrap({}, {log: false})
74
- .then(() => (isQuery(optionsWithDefaultCache) ? apollo.query(optionsWithDefaultCache).catch(error => {
75
- cy.log(`Caught Graphql Query Error: ${JSON.stringify(error)}`);
76
- return error;
77
- }) : apollo.mutate(optionsWithDefaultCache).catch(error => {
78
- cy.log(`Caught Graphql Mutation Error: ${JSON.stringify(error)}`);
79
- return error;
80
- }))
81
- .then(r => {
82
- result = r
83
- logger?.end()
84
- return r
85
- })
86
- )
56
+ const {log = true, ...apolloOptions} = optionsWithDefaultCache;
57
+ if (log) {
58
+ logger = Cypress.log({
59
+ autoEnd: false,
60
+ name: 'apollo',
61
+ displayName: 'apollo',
62
+ message: isQuery(apolloOptions) ? `Execute Graphql Query: ${apolloOptions.query.loc.source.body}` : `Execute Graphql Mutation: ${apolloOptions.mutation.loc.source.body}`,
63
+ consoleProps: () => {
64
+ return {
65
+ Options: apolloOptions,
66
+ Yielded: result
67
+ };
68
+ }
69
+ });
87
70
  }
71
+
72
+ cy.wrap({}, {log: true})
73
+ .then(() => (isQuery(optionsWithDefaultCache) ? apollo.query(optionsWithDefaultCache).catch(error => {
74
+ cy.log(`Caught Graphql Query Error: ${JSON.stringify(error)}`);
75
+ return error;
76
+ }) : apollo.mutate(optionsWithDefaultCache).catch(error => {
77
+ cy.log(`Caught Graphql Mutation Error: ${JSON.stringify(error)}`);
78
+ return error;
79
+ }))
80
+ .then(r => {
81
+ result = r;
82
+ logger?.end();
83
+ return r;
84
+ })
85
+ );
88
86
  }
89
- }
87
+ };