From 198a0593dd4b6d26d39b5c69bf857aef4e46c4aa Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Fri, 25 Mar 2022 17:22:43 -0600 Subject: [PATCH] add nshmp-lib utils --- .../cypress/utils/nshmp-lib.utils.ts | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 projects/nshmp-apps/cypress/utils/nshmp-lib.utils.ts diff --git a/projects/nshmp-apps/cypress/utils/nshmp-lib.utils.ts b/projects/nshmp-apps/cypress/utils/nshmp-lib.utils.ts new file mode 100644 index 000000000..61eaa9d78 --- /dev/null +++ b/projects/nshmp-apps/cypress/utils/nshmp-lib.utils.ts @@ -0,0 +1,57 @@ +export interface ControlPanelButtons { + hasSubmitButton: boolean; + hasServiceCallButton: boolean; + hasResetButton: boolean; +} + +export function controlPanelButtonsEnabled(buttons: ControlPanelButtons) { + cy.get('nshmp-lib-control-panel-buttons').find('.form-buttons').as('buttons'); + + if (buttons.hasResetButton) { + cy.get('@buttons') + .find('.reset-button') + .should('be.visible') + .find('button') + .should('be.enabled'); + } + + if (buttons.hasServiceCallButton) { + cy.get('@buttons') + .find('.service-button') + .should('be.visible') + .find('button') + .should('be.enabled') + .click(); + + hasServiceCallPopUp(); + cy.get('body').click(); + } + + if (buttons.hasSubmitButton) { + cy.get('@buttons') + .find('.submit-button') + .should('be.visible') + .find('button') + .should('be.enabled'); + } +} + +export function controlPanelButtonsNotEnabled(buttons: ControlPanelButtons) { + cy.get('nshmp-lib-control-panel-buttons').find('.form-buttons').as('buttons'); + + if (buttons.hasResetButton) { + cy.get('@buttons').find('.reset-button').should('be.visible').should('not.be.enabled'); + } + + if (buttons.hasServiceCallButton) { + cy.get('@buttons').find('.service-button').should('be.visible').should('not.be.enabled'); + } + + if (buttons.hasSubmitButton) { + cy.get('@buttons').find('.submit-button').should('be.visible').should('not.be.enabled'); + } +} + +export function hasServiceCallPopUp() { + cy.get('nshmp-lib-url-bottom-sheet').should('be.visible'); +} -- GitLab