@jahia/cypress 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/support/index.d.ts +1 -0
- package/dist/support/index.js +1 -0
- package/dist/support/registerSupport.js +2 -0
- package/dist/support/reloadUntil.d.ts +15 -0
- package/dist/support/reloadUntil.js +50 -0
- package/dist/support/repeatUntil.d.ts +15 -0
- package/dist/support/repeatUntil.js +52 -0
- package/dist/support/waitUntil.d.ts +15 -0
- package/dist/support/waitUntil.js +44 -0
- package/package.json +1 -1
- package/src/support/index.ts +1 -0
- package/src/support/registerSupport.ts +2 -0
- package/src/support/repeatUntil.md +40 -0
- package/src/support/repeatUntil.ts +59 -0
package/README.md
CHANGED
package/dist/support/index.d.ts
CHANGED
package/dist/support/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var login_1 = require("./login");
|
|
|
10
10
|
var logout_1 = require("./logout");
|
|
11
11
|
var installLogsCollector_1 = __importDefault(require("cypress-terminal-report/src/installLogsCollector"));
|
|
12
12
|
var fixture_1 = require("./fixture");
|
|
13
|
+
var repeatUntil_1 = require("./repeatUntil");
|
|
13
14
|
var registerSupport = function () {
|
|
14
15
|
Cypress.Commands.add('apolloClient', apollo_1.apolloClient);
|
|
15
16
|
Cypress.Commands.add('apollo', { prevSubject: 'optional' }, apollo_1.apollo);
|
|
@@ -17,6 +18,7 @@ var registerSupport = function () {
|
|
|
17
18
|
Cypress.Commands.add('executeGroovy', provisioning_1.executeGroovy);
|
|
18
19
|
Cypress.Commands.add('login', login_1.login);
|
|
19
20
|
Cypress.Commands.add('logout', logout_1.logout);
|
|
21
|
+
Cypress.Commands.add('repeatUntil', repeatUntil_1.repeatUntil);
|
|
20
22
|
Cypress.Commands.overwrite('fixture', fixture_1.fixture);
|
|
21
23
|
installLogsCollector_1["default"]();
|
|
22
24
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,50 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
declare type RepeatUntilOptions = {
|
|
3
|
+
attempts: number;
|
|
4
|
+
callback: () => void;
|
|
5
|
+
delay: number;
|
|
6
|
+
};
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Cypress {
|
|
9
|
+
interface Chainable<Subject> {
|
|
10
|
+
repeatUntil(selector: string, options?: Partial<RepeatUntilOptions>): Chainable<JQuery>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const repeatUntil: (selector: string, options?: Partial<RepeatUntilOptions>) => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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.repeatUntil = void 0;
|
|
16
|
+
var defaultOptions = {
|
|
17
|
+
attempts: 10,
|
|
18
|
+
callback: function () { return cy.reload({ log: false }); },
|
|
19
|
+
delay: 1000
|
|
20
|
+
};
|
|
21
|
+
var repeatUntil = function (selector, options) {
|
|
22
|
+
if (options === void 0) { options = {}; }
|
|
23
|
+
options = __assign(__assign({}, defaultOptions), options);
|
|
24
|
+
var log = Cypress.log({
|
|
25
|
+
name: 'repeatUntil',
|
|
26
|
+
message: "Reload until " + selector + ", remaining attempts : " + options.attempts,
|
|
27
|
+
consoleProps: function () {
|
|
28
|
+
return {
|
|
29
|
+
attempts: options.attempts
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var items = Cypress.$(selector);
|
|
34
|
+
if (items.length) {
|
|
35
|
+
log.set({ $el: items });
|
|
36
|
+
cy.wrap(items, { log: false });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (options.attempts > 1) {
|
|
40
|
+
log.end();
|
|
41
|
+
options.callback();
|
|
42
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
43
|
+
cy.wait(options.delay);
|
|
44
|
+
cy.repeatUntil(selector, __assign(__assign({}, options), { attempts: options.attempts - 1 }));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
var err = Error('Items not found.');
|
|
48
|
+
log.error(err);
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.repeatUntil = repeatUntil;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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/package.json
CHANGED
package/src/support/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {login} from "./login"
|
|
|
4
4
|
import {logout} from "./logout"
|
|
5
5
|
import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector'
|
|
6
6
|
import {fixture} from "./fixture";
|
|
7
|
+
import {repeatUntil} from "./repeatUntil";
|
|
7
8
|
|
|
8
9
|
export const registerSupport = (): void => {
|
|
9
10
|
Cypress.Commands.add('apolloClient', apolloClient)
|
|
@@ -14,6 +15,7 @@ export const registerSupport = (): void => {
|
|
|
14
15
|
|
|
15
16
|
Cypress.Commands.add('login', login)
|
|
16
17
|
Cypress.Commands.add('logout', logout)
|
|
18
|
+
Cypress.Commands.add('repeatUntil', repeatUntil)
|
|
17
19
|
|
|
18
20
|
Cypress.Commands.overwrite('fixture', fixture)
|
|
19
21
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# repeatUntil
|
|
2
|
+
|
|
3
|
+
This commands reload or repeat a function until an item is visible in the page
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
### Usage
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
cy.repeatUntil('div:contains("some text")')
|
|
11
|
+
cy.repeatUntil('div:contains("some text")', {attempts: 10, reloadCallback: () => { cy.reload() }, delay: 1000})
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Arguments
|
|
15
|
+
|
|
16
|
+
#### > selector (`string`)
|
|
17
|
+
|
|
18
|
+
The selector that is being searched in the page
|
|
19
|
+
|
|
20
|
+
#### > options (`RepeatUntilOptions`)
|
|
21
|
+
|
|
22
|
+
- `attempts`: max number of attempts
|
|
23
|
+
- `callback`: the callback to execute if the item is not found. By default, do a `cy.reload()`
|
|
24
|
+
- `delay`: time to wait between each attemps (ms)
|
|
25
|
+
|
|
26
|
+
### Yields
|
|
27
|
+
|
|
28
|
+
The found element
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
### Requirements
|
|
33
|
+
|
|
34
|
+
- `cy.repeatUntil()` requires being chained off of `cy`.
|
|
35
|
+
|
|
36
|
+
### Assertions
|
|
37
|
+
|
|
38
|
+
### Timeouts
|
|
39
|
+
|
|
40
|
+
## Command Log
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
2
|
+
|
|
3
|
+
// Load type definitions that come with Cypress module
|
|
4
|
+
/// <reference types="cypress" />
|
|
5
|
+
|
|
6
|
+
type RepeatUntilOptions = {
|
|
7
|
+
attempts: number,
|
|
8
|
+
callback: () => void,
|
|
9
|
+
delay: number,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const defaultOptions: RepeatUntilOptions = {
|
|
13
|
+
attempts: 10,
|
|
14
|
+
callback: () => cy.reload({log:false}),
|
|
15
|
+
delay: 1000
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
namespace Cypress {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
interface Chainable<Subject> {
|
|
22
|
+
repeatUntil(selector: string, options?: Partial<RepeatUntilOptions>): Chainable<JQuery>
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const repeatUntil = (selector: string, options: Partial<RepeatUntilOptions> = {}): void => {
|
|
28
|
+
options = { ...defaultOptions, ...options }
|
|
29
|
+
|
|
30
|
+
const log = Cypress.log({
|
|
31
|
+
name: 'repeatUntil',
|
|
32
|
+
message: `Reload until ${selector}, remaining attempts : ${options.attempts}`,
|
|
33
|
+
consoleProps: () => {
|
|
34
|
+
return {
|
|
35
|
+
attempts: options.attempts,
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const items = Cypress.$(selector)
|
|
41
|
+
if (items.length) {
|
|
42
|
+
log.set({ $el: items })
|
|
43
|
+
cy.wrap(items, {log: false})
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (options.attempts > 1) {
|
|
48
|
+
log.end()
|
|
49
|
+
options.callback()
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
52
|
+
cy.wait(options.delay)
|
|
53
|
+
cy.repeatUntil(selector, {...options, attempts: options.attempts - 1})
|
|
54
|
+
} else {
|
|
55
|
+
const err = Error('Items not found.')
|
|
56
|
+
log.error(err)
|
|
57
|
+
throw err
|
|
58
|
+
}
|
|
59
|
+
}
|