This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.js
79 lines (63 loc) · 2.36 KB
/
action.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { checkIfWindowCanExecuteActions } from './commands_utils';
import { RewriteURL } from "../utils/constants";
import { humanReadableNow } from "../utils/utils";
function executeHeaderAction(actionName) {
checkIfWindowCanExecuteActions();
cy.get('.header-container .btn-square .meta-icon-more').click();
cy.get('.subheader-container').should('exist');
cy.get(`#headerAction_${actionName}`).click();
}
Cypress.Commands.add('clickHeaderNav', navName => {
const name = navName.toLowerCase().replace(/\s/g, '');
describe('Fire header action with a certain name', function() {
cy.get('.header-container .btn-header').click();
cy.get('.subheader-container').should('exist');
return cy.get(`#subheaderNav_${name}`).click();
});
});
Cypress.Commands.add('executeHeaderAction', actionName => {
describe('Fire header action with a certain name', function() {
executeHeaderAction(actionName);
});
});
Cypress.Commands.add('executeHeaderActionWithDialog', actionName => {
describe('Fire header action with a certain name and expect a modal dialog to pop up within 10 secs', function() {
cy.server();
cy.route('GET', 'rest/api/process/*/layout').as('dialogLayout');
executeHeaderAction(actionName);
cy.wait('@dialogLayout');
return cy
.get('.panel-modal', { timeout: 10000 }) // wait up to 10 secs for the modal to appear
.should('exist');
});
});
Cypress.Commands.add('executeQuickAction', (actionName, defaultAction = false, modal = false, isDialogExpected = true) => {
let path = `.quick-actions-wrapper`; // default action
const requestAlias = `quickAction-${actionName}-${humanReadableNow()}`;
if (modal) {
path = '.modal-content-wrapper ' + path;
}
if (!defaultAction) {
cy.get(`${path} .btn-inline`)
.eq(0)
.click();
cy.get('.quick-actions-dropdown').should('exist');
path = `#quickAction_${actionName}`;
cy.server();
cy.route('GET', new RegExp(RewriteURL.QUICKACTION)).as(requestAlias);
}
cy.get(path)
.should('not.have.class', 'quick-actions-item-disabled')
.get(path)
.click({ timeout: 10000 })
.then(el => {
if (isDialogExpected) {
cy.wrap(el)
.get('.panel-modal', { timeout: 10000 }) // wait up to 10 secs for the modal to appear
.should('exist');
}
});
if (!defaultAction) {
cy.wait(`@${requestAlias}`);
}
});