From ff559384aad8a7d59a9ebfcb7263ffd93cc40c60 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 25 Oct 2024 10:33:59 +0200 Subject: [PATCH] perf: refs #6943 #6943 merge command --- .../route/agency/agencyWorkCenter.spec.js | 6 +++--- .../worker/workerNotificationsManager.spec.js | 4 +++- test/cypress/support/commands.js | 20 ++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/test/cypress/integration/route/agency/agencyWorkCenter.spec.js b/test/cypress/integration/route/agency/agencyWorkCenter.spec.js index 6a3cab664..311c0130c 100644 --- a/test/cypress/integration/route/agency/agencyWorkCenter.spec.js +++ b/test/cypress/integration/route/agency/agencyWorkCenter.spec.js @@ -11,16 +11,16 @@ describe('AgencyWorkCenter', () => { // create cy.get(createButton).click(); cy.get(workCenterCombobox).type('workCenterOne{enter}'); - cy.hasNotify('Data created'); + cy.checkNotification('created'); // 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.checkNotification('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.hasNotify('WorkCenter removed successfully'); + cy.checkNotification('WorkCenter removed successfully'); }); }); diff --git a/test/cypress/integration/worker/workerNotificationsManager.spec.js b/test/cypress/integration/worker/workerNotificationsManager.spec.js index 367287a5a..f121b3894 100644 --- a/test/cypress/integration/worker/workerNotificationsManager.spec.js +++ b/test/cypress/integration/worker/workerNotificationsManager.spec.js @@ -17,7 +17,9 @@ describe('WorkerNotificationsManager', () => { cy.login('developer'); cy.visit(`/#/worker/${salesPersonId}/notifications`); cy.get(firstAvailableNotification).click(); - cy.hasNotify('The notification subscription of this worker cant be modified'); + cy.checkNotification( + 'The notification subscription of this worker cant be modified' + ); }); it('should active a notification that is yours', () => { diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index dcfb54a3e..7d5a44f78 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -274,21 +274,13 @@ Cypress.Commands.add('openActions', (row) => { cy.get('tbody > tr').eq(row).find('.actions > .q-btn').click(); }); -Cypress.Commands.add('checkNotification', (type) => { - const values = { +Cypress.Commands.add('checkNotification', (tag) => { + const defaultTags = { created: 'Data created', updated: 'Data saved', deleted: 'Data deleted', - }; - cy.get('.q-notification__message').should('have.text', values[type]); -}); - -Cypress.Commands.add('searchByLabel', (label, value) => { - cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`); -}); - -Cypress.Commands.add('hasNotify', (text) => { - //last + }; //last + const text = defaultTags[tag] ?? tag; cy.get('.q-notification') .should('be.visible') .last() @@ -297,3 +289,7 @@ Cypress.Commands.add('hasNotify', (text) => { throw new Error(`Notification not found: "${text}"`); }); }); + +Cypress.Commands.add('searchByLabel', (label, value) => { + cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`); +});