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 0000000000000000000000000000000000000000..61eaa9d786d0184d59614a4bc8f5038c472cc809 --- /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'); +}