From 37f2fb62cf6a67b5ef886483156597a03e2c7a0a Mon Sep 17 00:00:00 2001 From: TheBestPessimist Date: Mon, 5 Aug 2019 13:00:56 +0300 Subject: [PATCH] Add new parameter to `cy.executeQuickAction`: `isDialogExpected` if a modal dialog is expected when executing the action. https://github.com/metasfresh/metasfresh-e2e/issues/248 --- cypress/support/commands/action.js | 11 ++++++++--- cypress/support/index.d.ts | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cypress/support/commands/action.js b/cypress/support/commands/action.js index 8c50dc7b..ddc2a19d 100644 --- a/cypress/support/commands/action.js +++ b/cypress/support/commands/action.js @@ -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()}`; @@ -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}`); diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index bfb11993..f38ad239 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -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 + executeQuickAction(actionName: string, defaultAction?: boolean, modal?: boolean, isDialogExpected ?: boolean): Chainable /** * @param fieldName - name of the field is question