diff --git a/src/components/FormModelPopup.vue b/src/components/FormModelPopup.vue index 118c8f5f4..d91f07535 100644 --- a/src/components/FormModelPopup.vue +++ b/src/components/FormModelPopup.vue @@ -61,6 +61,7 @@ defineExpose({ :loading="isLoading" @click="emit('onDataCanceled')" v-close-popup + data-cy="FormModelPopup_cancel" /> diff --git a/test/cypress/integration/route/agency/agencyWorkCenter.spec.js b/test/cypress/integration/route/agency/agencyWorkCenter.spec.js index 353c5805b..6a3cab664 100644 --- a/test/cypress/integration/route/agency/agencyWorkCenter.spec.js +++ b/test/cypress/integration/route/agency/agencyWorkCenter.spec.js @@ -7,31 +7,20 @@ describe('AgencyWorkCenter', () => { const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon'; const workCenterCombobox = 'input[role="combobox"]'; - it('assign workCenter', () => { + it('check workCenter crud', () => { + // create cy.get(createButton).click(); cy.get(workCenterCombobox).type('workCenterOne{enter}'); - cy.get('.q-notification__message').should('have.text', 'Data created'); - }); + cy.hasNotify('Data created'); - it('delete workCenter', () => { + // expect error when duplicate + cy.get(createButton).click(); + cy.get('[data-cy="FormModelPopup_save"]').click(); + cy.hasNotify('This workCenter is already assigned to this agency'); + cy.get('[data-cy="FormModelPopup_cancel"]').click(); + + // delete cy.get('.q-item__section--side > .q-btn > .q-btn__content > .q-icon').click(); - cy.get('.q-notification__message').should( - 'have.text', - 'WorkCenter removed successfully' - ); - }); - - it('error on duplicate workCenter', () => { - cy.get(createButton).click(); - cy.get(workCenterCombobox).type('workCenterOne{enter}'); - cy.get('.q-notification__message').should('have.text', 'Data created'); - cy.get(createButton).click(); - cy.get( - '.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container' - ).type('workCenterOne{enter}'); - - cy.get( - ':nth-child(2) > .q-notification__wrapper > .q-notification__content > .q-notification__message' - ).should('have.text', 'This workCenter is already assigned to this agency'); + cy.hasNotify('WorkCenter removed successfully'); }); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 83f45b721..c7b36cd3a 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -254,3 +254,14 @@ Cypress.Commands.add('openUserPanel', () => { '.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image' ).click(); }); + +Cypress.Commands.add('hasNotify', (text) => { + //last + cy.get('.q-notification') + .should('be.visible') + .last() + .then(($lastNotification) => { + if (!Cypress.$($lastNotification).text().includes(text)) + throw new Error(`Notification not found: "${text}"`); + }); +});