Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
Add new parameter to cy.executeQuickAction: isDialogExpected if a…
Browse files Browse the repository at this point in the history
… modal dialog is expected when executing the action.

#248
  • Loading branch information
TheBestPessimist committed Aug 6, 2019
1 parent 5280fbb commit 37f2fb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cypress/support/commands/action.js
Expand Up @@ -41,7 +41,7 @@ Cypress.Commands.add('executeHeaderActionWithDialog', actionName => {
});
});

Cypress.Commands.add('executeQuickAction', (actionName, defaultAction = false, modal = false) => {
Cypress.Commands.add('executeQuickAction', (actionName, defaultAction = false, modal = false, isDialogExpected = true) => {
let path = `.quick-actions-wrapper`; // default action
const requestAlias = `quickAction-${actionName}-${humanReadableNow()}`;

Expand All @@ -65,8 +65,13 @@ Cypress.Commands.add('executeQuickAction', (actionName, defaultAction = false, m
.should('not.have.class', 'quick-actions-item-disabled')
.get(path)
.click({ timeout: 10000 })
.get('.panel-modal', { timeout: 10000 }) // wait up to 10 secs for the modal to appear
.should('exist');
.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}`);
Expand Down
3 changes: 2 additions & 1 deletion cypress/support/index.d.ts
Expand Up @@ -29,8 +29,9 @@ declare namespace Cypress {
* @param actionName - internal name of the action to be executed
* @param defaultAction - optional, default false - if truthy the default action will be executed.
* @param modal - optional, default = false - use true if the field is in a modal overlay; required if the underlying window has a field with the same name.
* @param isDialogExpected - optional, default true - use false if this action does not open any dialog
*/
executeQuickAction(actionName: string, defaultAction?: boolean, modal?: boolean): Chainable<any>
executeQuickAction(actionName: string, defaultAction?: boolean, modal?: boolean, isDialogExpected ?: boolean): Chainable<any>

/**
* @param fieldName - name of the field is question
Expand Down

0 comments on commit 37f2fb6

Please sign in to comment.