@jahia/cypress 2.0.0 → 3.0.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 (82) 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 +12 -0
  29. package/dist/utils/Utils.js +79 -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/package.json +6 -1
  39. package/schema.graphql +941 -76
  40. package/src/custom.d.ts +1 -1
  41. package/src/index.ts +4 -3
  42. package/src/page-object/baseComponent.ts +7 -7
  43. package/src/page-object/basePage.ts +1 -1
  44. package/src/page-object/html/iframe.ts +12 -13
  45. package/src/page-object/html/index.ts +1 -1
  46. package/src/page-object/index.ts +6 -6
  47. package/src/page-object/material/index.ts +2 -2
  48. package/src/page-object/material/muiinput.ts +5 -7
  49. package/src/page-object/material/muiradio.ts +3 -5
  50. package/src/page-object/moonstone/accordion.ts +7 -8
  51. package/src/page-object/moonstone/button.ts +3 -5
  52. package/src/page-object/moonstone/collapsible.ts +9 -10
  53. package/src/page-object/moonstone/dropdown.ts +6 -8
  54. package/src/page-object/moonstone/index.ts +9 -9
  55. package/src/page-object/moonstone/menu.ts +8 -8
  56. package/src/page-object/moonstone/pagination.ts +8 -9
  57. package/src/page-object/moonstone/primaryNav.ts +5 -5
  58. package/src/page-object/moonstone/secondaryNav.ts +3 -3
  59. package/src/page-object/moonstone/table.ts +9 -10
  60. package/src/page-object/utils.ts +12 -10
  61. package/src/plugins/env.ts +13 -12
  62. package/src/plugins/index.ts +1 -1
  63. package/src/plugins/registerPlugins.ts +3 -3
  64. package/src/support/apollo/apollo.ts +47 -49
  65. package/src/support/apollo/apolloClient.ts +18 -18
  66. package/src/support/apollo/index.ts +2 -2
  67. package/src/support/apollo/links.ts +38 -37
  68. package/src/support/commands.ts +1 -0
  69. package/src/support/fixture.ts +8 -8
  70. package/src/support/index.ts +5 -5
  71. package/src/support/login.ts +8 -10
  72. package/src/support/logout.ts +7 -8
  73. package/src/support/provisioning/executeGroovy.ts +3 -5
  74. package/src/support/provisioning/index.ts +3 -3
  75. package/src/support/provisioning/installBundle.ts +3 -5
  76. package/src/support/provisioning/runProvisioningScript.ts +34 -33
  77. package/src/support/registerSupport.ts +16 -16
  78. package/src/support/repeatUntil.ts +19 -19
  79. package/src/utils/Utils.ts +75 -0
  80. package/src/utils/index.ts +1 -0
  81. package/fixtures/graphql/jcr/addNode.graphql +0 -16
  82. /package/fixtures/graphql/jcr/{mutateNode.graphql → mutation/mutateNode.graphql} +0 -0
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
2
2
 
3
- import {ApolloClient, from, HttpLink, InMemoryCache, NormalizedCacheObject} from '@apollo/client/core'
4
- import {FormDataHttpLink, uploadLink} from './links'
3
+ import {ApolloClient, from, HttpLink, InMemoryCache, NormalizedCacheObject} from '@apollo/client/core';
4
+ import {FormDataHttpLink, uploadLink} from './links';
5
5
 
6
6
  interface AuthMethod {
7
7
  token?: string
@@ -26,44 +26,44 @@ export const apolloClient = function (authMethod?: AuthMethod, options: ApolloCl
26
26
  log: true,
27
27
  setCurrentApolloClient: true
28
28
  }): void {
29
- const headers: { authorization?: string } = {}
29
+ const headers: { authorization?: string } = {};
30
30
  if (authMethod === undefined) {
31
- headers.authorization = `Basic ${btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'))}`
31
+ headers.authorization = `Basic ${btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'))}`;
32
32
  } else if (authMethod.token !== undefined) {
33
- headers.authorization = `APIToken ${authMethod.token}`
33
+ headers.authorization = `APIToken ${authMethod.token}`;
34
34
  } else if (authMethod.username !== undefined && authMethod.password !== undefined) {
35
- headers.authorization = `Basic ${btoa(authMethod.username + ':' + authMethod.password)}`
35
+ headers.authorization = `Basic ${btoa(authMethod.username + ':' + authMethod.password)}`;
36
36
  }
37
37
 
38
- const links = [ uploadLink, FormDataHttpLink(Cypress.config().baseUrl, headers)]
38
+ const links = [uploadLink, FormDataHttpLink(Cypress.config().baseUrl, headers)];
39
39
 
40
40
  const client = new ApolloClient({
41
41
  link: from(links),
42
42
  cache: new InMemoryCache(),
43
43
  defaultOptions: {
44
44
  query: {
45
- fetchPolicy: 'no-cache',
46
- },
47
- },
48
- })
45
+ fetchPolicy: 'no-cache'
46
+ }
47
+ }
48
+ });
49
49
 
50
50
  if (options.log) {
51
51
  Cypress.log({
52
52
  name: 'apolloClient',
53
53
  displayName: 'apClient',
54
- message: `Create new apollo client`,
54
+ message: 'Create new apollo client',
55
55
  consoleProps: () => {
56
56
  return {
57
57
  Auth: authMethod,
58
58
  Yielded: client
59
- }
60
- },
61
- })
59
+ };
60
+ }
61
+ });
62
62
  }
63
63
 
64
64
  if (options.setCurrentApolloClient) {
65
- cy.wrap(client, {log: false}).as('currentApolloClient')
65
+ cy.wrap(client, {log: false}).as('currentApolloClient');
66
66
  } else {
67
- cy.wrap(client, {log: false})
67
+ cy.wrap(client, {log: false});
68
68
  }
69
- }
69
+ };
@@ -1,2 +1,2 @@
1
- export * from './apolloClient'
2
- export * from './apollo'
1
+ export * from './apolloClient';
2
+ export * from './apollo';
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
- import { HttpLink } from '@apollo/client/link/http'
3
- import fetch from 'cross-fetch'
4
- import { setContext } from '@apollo/client/link/context'
2
+ import {HttpLink} from '@apollo/client/link/http';
3
+ import fetch from 'cross-fetch';
4
+ import {setContext} from '@apollo/client/link/context';
5
5
 
6
6
  interface ApolloRequestInit extends RequestInit {
7
7
  formData?: FormData
@@ -12,53 +12,54 @@ export const FormDataHttpLink = (baseUrl: string, headers: Object) => {
12
12
  uri: `${baseUrl}/modules/graphql`,
13
13
  headers,
14
14
  fetch: (uri, fetcherOptions) => {
15
- const options: ApolloRequestInit = { ...fetcherOptions }
15
+ const options: ApolloRequestInit = {...fetcherOptions};
16
16
  if (options.formData) {
17
- const formData = options.formData
18
- const body = JSON.parse(options.body.toString())
17
+ const formData = options.formData;
18
+ const body = JSON.parse(options.body.toString());
19
19
  if (Array.isArray(body)) {
20
- formData.append('query', options.body.toString())
20
+ formData.append('query', options.body.toString());
21
21
  } else {
22
- Object.keys(body).forEach((k) =>
23
- formData.append(k, typeof body[k] === 'string' ? body[k] : JSON.stringify(body[k])),
24
- )
22
+ Object.keys(body).forEach(k =>
23
+ formData.append(k, typeof body[k] === 'string' ? body[k] : JSON.stringify(body[k]))
24
+ );
25
25
  }
26
26
 
27
- fetcherOptions.body = formData
28
- delete fetcherOptions.headers['content-type']
29
- return fetch(uri, fetcherOptions)
27
+ fetcherOptions.body = formData;
28
+ delete fetcherOptions.headers['content-type'];
29
+ return fetch(uri, fetcherOptions);
30
30
  }
31
- return fetch(uri, fetcherOptions)
32
- },
33
- })
34
- }
35
31
 
36
- export const uploadLink = setContext((operation, { fetchOptions }) => {
37
- const { variables } = operation
38
- let fileFound = false
39
- const formData = new FormData()
40
- const id = Math.random().toString(36)
32
+ return fetch(uri, fetcherOptions);
33
+ }
34
+ });
35
+ };
36
+
37
+ export const uploadLink = setContext((operation, {fetchOptions}) => {
38
+ const {variables} = operation;
39
+ let fileFound = false;
40
+ const formData = new FormData();
41
+ const id = Math.random().toString(36);
41
42
  // Search for File objects on the request and set it as formData
42
43
  Object.keys(variables).forEach(function (k) {
43
- const variable = variables[k]
44
+ const variable = variables[k];
44
45
  if (variable instanceof File) {
45
- formData.append(id, variable)
46
- variables[k] = id
47
- fileFound = true
46
+ formData.append(id, variable);
47
+ variables[k] = id;
48
+ fileFound = true;
48
49
  }
49
- })
50
+ });
50
51
  if (fileFound) {
51
52
  return {
52
53
  fetchOptions: {
53
54
  ...fetchOptions,
54
- formData: formData,
55
- },
56
- }
57
- } else {
58
- return {
59
- fetchOptions: {
60
- ...fetchOptions,
61
- },
62
- }
55
+ formData: formData
56
+ }
57
+ };
63
58
  }
64
- })
59
+
60
+ return {
61
+ fetchOptions: {
62
+ ...fetchOptions
63
+ }
64
+ };
65
+ });
@@ -0,0 +1 @@
1
+ import 'cypress-wait-until';
@@ -1,25 +1,25 @@
1
1
  import Chainable = Cypress.Chainable;
2
2
 
3
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- export const fixture = function(originalCommand: ((...args: any[]) => any), fixture: string, ...args: any[]): Chainable<any> {
5
- return cy.wrap({}, {log:false}).then(() => {
4
+ export const fixture = function (originalCommand: ((...args: any[]) => any), fixture: string, ...args: any[]): Chainable<any> {
5
+ return cy.wrap({}, {log: false}).then(() => {
6
6
  return originalCommand(fixture, ...args).then(f => {
7
- return f
8
- }).catch((err) => {
7
+ return f;
8
+ }).catch(() => {
9
9
  return null;
10
10
  });
11
11
  }).then(file => {
12
12
  if (!file) {
13
13
  let encoding;
14
14
  if (typeof args[0] === 'string') {
15
- encoding = args[0]
15
+ encoding = args[0];
16
16
  }
17
17
 
18
18
  try {
19
- cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, {log: false, timeout: 200})
19
+ cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, {log: false, timeout: 200});
20
20
  } catch (e) {
21
- console.log(e)
21
+ console.log(e);
22
22
  }
23
23
  }
24
- })
24
+ });
25
25
  };
@@ -1,5 +1,5 @@
1
- export * from './apollo'
2
- export * from './provisioning'
3
- export * from './login'
4
- export * from './logout'
5
- export * from './repeatUntil'
1
+ export * from './apollo';
2
+ export * from './provisioning';
3
+ export * from './login';
4
+ export * from './logout';
5
+ export * from './repeatUntil';
@@ -3,8 +3,6 @@
3
3
  // Load type definitions that come with Cypress module
4
4
  /// <reference types="cypress" />
5
5
 
6
-
7
-
8
6
  declare global {
9
7
  namespace Cypress {
10
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -14,16 +12,16 @@ declare global {
14
12
  }
15
13
  }
16
14
 
17
- export const login = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD')): void => {
15
+ export const login = (username = 'root', password: string = Cypress.env('SUPER_USER_PASSWORD')): void => {
18
16
  Cypress.log({
19
17
  name: 'login',
20
18
  message: `Login with ${username}`,
21
19
  consoleProps: () => {
22
20
  return {
23
- User: username,
24
- }
25
- },
26
- })
21
+ User: username
22
+ };
23
+ }
24
+ });
27
25
 
28
26
  cy.request({
29
27
  method: 'POST',
@@ -33,7 +31,7 @@ export const login = (username = 'root', password: string = Cypress.env('SUPER_U
33
31
  followRedirect: false,
34
32
  log: false
35
33
  }).then(res => {
36
- expect(res.status, 'Login result').to.eq(302)
37
- })
38
- }
34
+ expect(res.status, 'Login result').to.eq(302);
35
+ });
36
+ };
39
37
 
@@ -3,7 +3,6 @@
3
3
  // Load type definitions that come with Cypress module
4
4
  /// <reference types="cypress" />
5
5
 
6
-
7
6
  declare global {
8
7
  namespace Cypress {
9
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -16,11 +15,11 @@ declare global {
16
15
  export const logout = (): void => {
17
16
  Cypress.log({
18
17
  name: 'logout',
19
- message: `Logout`,
18
+ message: 'Logout',
20
19
  consoleProps: () => {
21
- return {}
22
- },
23
- })
20
+ return {};
21
+ }
22
+ });
24
23
 
25
24
  cy.request({
26
25
  method: 'POST',
@@ -28,7 +27,7 @@ export const logout = (): void => {
28
27
  followRedirect: false,
29
28
  log: false
30
29
  }).then(res => {
31
- expect(res.status, 'Logout result').to.eq(302)
32
- })
33
- }
30
+ expect(res.status, 'Logout result').to.eq(302);
31
+ });
32
+ };
34
33
 
@@ -3,8 +3,6 @@
3
3
  // Load type definitions that come with Cypress module
4
4
  /// <reference types="cypress" />
5
5
 
6
-
7
-
8
6
  declare global {
9
7
  namespace Cypress {
10
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -24,7 +22,7 @@ const serverDefaults = {
24
22
  url: Cypress.config().baseUrl,
25
23
  username: 'root',
26
24
  password: Cypress.env('SUPER_USER_PASSWORD')
27
- }
25
+ };
28
26
 
29
27
  export const executeGroovy = function (scriptFile: string, replacements?: { [key: string]: string }, jahiaServer: JahiaServer = serverDefaults): void {
30
28
  cy.runProvisioningScript({
@@ -34,5 +32,5 @@ export const executeGroovy = function (scriptFile: string, replacements?: { [key
34
32
  fileName: scriptFile,
35
33
  replacements,
36
34
  type: 'text/plain'
37
- }], jahiaServer).then(r => r[0])
38
- }
35
+ }], jahiaServer).then(r => r[0]);
36
+ };
@@ -1,3 +1,3 @@
1
- export * from './executeGroovy'
2
- export * from './runProvisioningScript'
3
- export * from './installBundle'
1
+ export * from './executeGroovy';
2
+ export * from './runProvisioningScript';
3
+ export * from './installBundle';
@@ -3,8 +3,6 @@
3
3
  // Load type definitions that come with Cypress module
4
4
  /// <reference types="cypress" />
5
5
 
6
-
7
-
8
6
  declare global {
9
7
  namespace Cypress {
10
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -15,8 +13,8 @@ declare global {
15
13
  }
16
14
 
17
15
  export const installBundle = function (bundleFile: string): void {
18
- cy.runProvisioningScript([{ installBundle: bundleFile }], [{
16
+ cy.runProvisioningScript([{installBundle: bundleFile}], [{
19
17
  fileName: bundleFile,
20
18
  type: 'text/plain'
21
- }])
22
- }
19
+ }]);
20
+ };
@@ -1,12 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
2
2
  import RequestOptions = Cypress.RequestOptions;
3
3
 
4
-
5
4
  // Load type definitions that come with Cypress module
6
5
  /// <reference types="cypress" />
7
6
 
8
-
9
-
10
7
  declare global {
11
8
  namespace Cypress {
12
9
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -35,9 +32,12 @@ export type JahiaServer = {
35
32
  function processContent(formFile: FormFile) {
36
33
  let content = formFile.fileContent;
37
34
  if (formFile.replacements) {
38
- Object.keys(formFile.replacements).forEach(k => content = content.replaceAll(k, formFile.replacements[k]))
35
+ Object.keys(formFile.replacements).forEach(k => {
36
+ content = content.replaceAll(k, formFile.replacements[k]);
37
+ });
39
38
  }
40
- formFile.fileContent = content
39
+
40
+ formFile.fileContent = content;
41
41
  return Cypress.Blob.binaryStringToBlob(content, formFile.type);
42
42
  }
43
43
 
@@ -51,8 +51,9 @@ function append(formFile: FormFile, formData: FormData, key: string) {
51
51
  } else {
52
52
  formFile.fileContent = content;
53
53
  }
54
+
54
55
  formData.append(key, processContent(formFile), formFile.fileName);
55
- })
56
+ });
56
57
  }
57
58
  }
58
59
 
@@ -60,33 +61,33 @@ const serverDefaults: JahiaServer = {
60
61
  url: Cypress.config().baseUrl,
61
62
  username: 'root',
62
63
  password: Cypress.env('SUPER_USER_PASSWORD')
63
- }
64
+ };
64
65
 
65
66
  function isFormFile(script: FormFile | StringDictionary[]): script is FormFile {
66
67
  return Boolean((script as FormFile).fileContent || (script as FormFile).fileName);
67
68
  }
68
69
 
69
- export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log:true}, timeout?: number): void => {
70
- const formData = new FormData()
70
+ export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log: true}, timeout?: number): void => {
71
+ const formData = new FormData();
71
72
 
72
73
  if (isFormFile(script)) {
73
- append(script, formData, "script")
74
+ append(script, formData, 'script');
74
75
  } else {
75
76
  append({
76
77
  fileContent: JSON.stringify(script),
77
78
  type: 'application/json'
78
- }, formData, "script");
79
+ }, formData, 'script');
79
80
  }
80
81
 
81
82
  if (files) {
82
- files.forEach((f) => {
83
- append(f, formData, "file")
84
- })
83
+ files.forEach(f => {
84
+ append(f, formData, 'file');
85
+ });
85
86
  }
86
87
 
87
- let response: Cypress.Response<any>
88
- let result: any
89
- let logger: Cypress.Log
88
+ let response: Cypress.Response<any>;
89
+ let result: any;
90
+ let logger: Cypress.Log;
90
91
 
91
92
  if (options.log) {
92
93
  logger = Cypress.log({
@@ -100,9 +101,9 @@ export const runProvisioningScript = (script: FormFile | StringDictionary[], fil
100
101
  Files: files,
101
102
  Response: response,
102
103
  Yielded: result
103
- }
104
- },
105
- })
104
+ };
105
+ }
106
+ });
106
107
  }
107
108
 
108
109
  const request: Partial<RequestOptions> = {
@@ -111,28 +112,28 @@ export const runProvisioningScript = (script: FormFile | StringDictionary[], fil
111
112
  auth: {
112
113
  user: jahiaServer.username,
113
114
  pass: jahiaServer.password,
114
- sendImmediately: true,
115
+ sendImmediately: true
115
116
  },
116
117
  body: formData,
117
118
  log: false
118
- }
119
+ };
119
120
 
120
- if(typeof timeout !== 'undefined'){
121
- request.timeout = timeout
121
+ if (typeof timeout !== 'undefined') {
122
+ request.timeout = timeout;
122
123
  }
123
124
 
124
125
  cy.request(request).then(res => {
125
- response = res
126
- expect(res.status, 'Script result').to.eq(200)
126
+ response = res;
127
+ expect(res.status, 'Script result').to.eq(200);
127
128
  try {
128
- const decoder = new TextDecoder()
129
- result = JSON.parse(decoder.decode(response.body))
129
+ const decoder = new TextDecoder();
130
+ result = JSON.parse(decoder.decode(response.body));
130
131
  } catch (e) {
131
- result = e
132
+ result = e;
132
133
  }
133
134
 
134
- logger?.end()
135
- return result
136
- })
137
- }
135
+ logger?.end();
136
+ return result;
137
+ });
138
+ };
138
139
 
@@ -1,21 +1,21 @@
1
- import {apollo, apolloClient} from "./apollo"
2
- import {executeGroovy, runProvisioningScript, installBundle} from "./provisioning"
3
- import {login} from "./login"
4
- import {logout} from "./logout"
5
- import {fixture} from "./fixture";
6
- import {repeatUntil} from "./repeatUntil";
1
+ import {apollo, apolloClient} from './apollo';
2
+ import {executeGroovy, runProvisioningScript, installBundle} from './provisioning';
3
+ import {login} from './login';
4
+ import {logout} from './logout';
5
+ import {fixture} from './fixture';
6
+ import {repeatUntil} from './repeatUntil';
7
7
 
8
8
  export const registerSupport = (): void => {
9
- Cypress.Commands.add('apolloClient', apolloClient)
10
- Cypress.Commands.add('apollo', {prevSubject: 'optional'}, apollo)
9
+ Cypress.Commands.add('apolloClient', apolloClient);
10
+ Cypress.Commands.add('apollo', {prevSubject: 'optional'}, apollo);
11
11
 
12
- Cypress.Commands.add('runProvisioningScript', runProvisioningScript)
13
- Cypress.Commands.add('executeGroovy', executeGroovy)
14
- Cypress.Commands.add('installBundle', installBundle)
12
+ Cypress.Commands.add('runProvisioningScript', runProvisioningScript);
13
+ Cypress.Commands.add('executeGroovy', executeGroovy);
14
+ Cypress.Commands.add('installBundle', installBundle);
15
15
 
16
- Cypress.Commands.add('login', login)
17
- Cypress.Commands.add('logout', logout)
18
- Cypress.Commands.add('repeatUntil', repeatUntil)
16
+ Cypress.Commands.add('login', login);
17
+ Cypress.Commands.add('logout', logout);
18
+ Cypress.Commands.add('repeatUntil', repeatUntil);
19
19
 
20
- Cypress.Commands.overwrite('fixture', fixture)
21
- }
20
+ Cypress.Commands.overwrite('fixture', fixture);
21
+ };
@@ -11,9 +11,9 @@ export type RepeatUntilOptions = {
11
11
 
12
12
  const defaultOptions: RepeatUntilOptions = {
13
13
  attempts: 10,
14
- callback: () => cy.reload({log:false}),
14
+ callback: () => cy.reload({log: false}),
15
15
  delay: 1000
16
- }
16
+ };
17
17
 
18
18
  declare global {
19
19
  namespace Cypress {
@@ -25,35 +25,35 @@ declare global {
25
25
  }
26
26
 
27
27
  export const repeatUntil = (selector: string, options: Partial<RepeatUntilOptions> = {}): void => {
28
- options = { ...defaultOptions, ...options }
28
+ options = {...defaultOptions, ...options};
29
29
 
30
30
  const log = Cypress.log({
31
31
  name: 'repeatUntil',
32
32
  message: `Reload until ${selector}, remaining attempts : ${options.attempts}`,
33
33
  consoleProps: () => {
34
34
  return {
35
- attempts: options.attempts,
36
- }
37
- },
38
- })
35
+ attempts: options.attempts
36
+ };
37
+ }
38
+ });
39
39
 
40
- const items = Cypress.$(selector)
40
+ const items = Cypress.$(selector);
41
41
  if (items.length) {
42
- log.set({ $el: items })
43
- cy.wrap(items, {log: false})
44
- return
42
+ log.set({$el: items});
43
+ cy.wrap(items, {log: false});
44
+ return;
45
45
  }
46
46
 
47
47
  if (options.attempts > 1) {
48
- log.end()
49
- options.callback()
48
+ log.end();
49
+ options.callback();
50
50
 
51
51
  // eslint-disable-next-line cypress/no-unnecessary-waiting
52
- cy.wait(options.delay)
53
- cy.repeatUntil(selector, {...options, attempts: options.attempts - 1})
52
+ cy.wait(options.delay);
53
+ cy.repeatUntil(selector, {...options, attempts: options.attempts - 1});
54
54
  } else {
55
- const err = Error('Items not found.')
56
- log.error(err)
57
- throw err
55
+ const err = Error('Items not found.');
56
+ log.error(err);
57
+ throw err;
58
58
  }
59
- }
59
+ };