From 17a18e8b49d74d46679309ebc837cc88b0ccb10b Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 13 Mar 2025 10:06:05 +0100 Subject: [PATCH] refactor: refs #8626 improve test messages and selectors in route tests --- .../route/agency/agencyWorkCenter.spec.js | 2 +- .../route/routeExtendedList.spec.js | 32 +++++++++++-------- .../route/vehicle/vehicleDescriptor.spec.js | 4 +-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/test/cypress/integration/route/agency/agencyWorkCenter.spec.js b/test/cypress/integration/route/agency/agencyWorkCenter.spec.js index a3e0aac81..79dcd6f70 100644 --- a/test/cypress/integration/route/agency/agencyWorkCenter.spec.js +++ b/test/cypress/integration/route/agency/agencyWorkCenter.spec.js @@ -9,7 +9,7 @@ describe('AgencyWorkCenter', () => { const messages = { dataCreated: 'Data created', alreadyAssigned: 'This workCenter is already assigned to this agency', - removed: 'WorkCenter removed successfully', + removed: 'Work center removed successfully', }; beforeEach(() => { diff --git a/test/cypress/integration/route/routeExtendedList.spec.js b/test/cypress/integration/route/routeExtendedList.spec.js index b46ce3ba2..fb2885f35 100644 --- a/test/cypress/integration/route/routeExtendedList.spec.js +++ b/test/cypress/integration/route/routeExtendedList.spec.js @@ -8,6 +8,8 @@ describe('Route extended list', () => { date: getSelector('dated'), description: getSelector('description'), served: getSelector('isOk'), + firstRowSelectCheckBox: + 'tbody > tr:first-child > :nth-child(1) .q-checkbox__inner', lastRowSelectCheckBox: 'tbody > tr:last-child > :nth-child(1) .q-checkbox__inner', removeBtn: '[title="Remove"]', resetBtn: '[title="Reset"]', @@ -19,7 +21,7 @@ describe('Route extended list', () => { markServedBtn: '#st-actions > .q-btn-group > :nth-child(3)', searchbar: 'searchbar', firstTicketsRowSelectCheckBox: - '.q-card > :nth-child(2) > .q-table__container > .q-table__middle > .q-table > tbody > :nth-child(1) > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg > .q-checkbox__svg', + '.q-card .q-table > tbody > :nth-child(1) .q-checkbox', }; const checkboxState = { @@ -117,12 +119,21 @@ describe('Route extended list', () => { }); }); - it('Should clone selected route', () => { - cy.get(selectors.lastRowSelectCheckBox).click(); + it('Should clone selected route and add ticket', () => { + cy.get(selectors.firstRowSelectCheckBox).click(); cy.get(selectors.cloneBtn).click(); - cy.dataCy('Starting date_inputDate').type('10-05-2001'); + cy.dataCy('Starting date_inputDate').type('01-01-2001'); cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click(); - cy.validateContent(selectors.date, '05/10/2001'); + cy.validateContent(selectors.date, '01/01/2001'); + + cy.dataCy('tableAction-0').last().click(); + cy.get(selectors.firstTicketsRowSelectCheckBox).click(); + cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click(); + cy.checkNotification(dataSaved); + + cy.get(selectors.lastRowSelectCheckBox).click(); + cy.get(selectors.removeBtn).click(); + cy.dataCy(selectors.confirmBtn).click(); }); it('Should download selected route', () => { @@ -143,22 +154,15 @@ describe('Route extended list', () => { cy.validateContent(selectors.served, checkboxState.check); }); - it('Should delete the selected route', () => { + it('Should delete the selected routes', () => { cy.get(selectors.lastRowSelectCheckBox).click(); - cy.get(selectors.removeBtn).click(); + cy.dataCy(selectors.confirmBtn).click(); cy.checkNotification(dataSaved); }); - it('Should add ticket to route', () => { - cy.dataCy('tableAction-0').first().click(); - cy.get(selectors.firstTicketsRowSelectCheckBox).click(); - cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click(); - cy.checkNotification(dataSaved); - }); - it('Should save changes in route', () => { updateFields.forEach(({ selector, type, value }) => { fillField(selector, type, value); diff --git a/test/cypress/integration/route/vehicle/vehicleDescriptor.spec.js b/test/cypress/integration/route/vehicle/vehicleDescriptor.spec.js index 64b9ca0a0..3e9c816c4 100644 --- a/test/cypress/integration/route/vehicle/vehicleDescriptor.spec.js +++ b/test/cypress/integration/route/vehicle/vehicleDescriptor.spec.js @@ -2,11 +2,11 @@ describe('Vehicle', () => { beforeEach(() => { cy.viewport(1920, 1080); cy.login('deliveryAssistant'); - cy.visit(`/#/route/vehicle/7`); + cy.visit(`/#/route/vehicle/7/summary`); }); it('should delete a vehicle', () => { - cy.openActionsDescriptor(); + cy.dataCy('descriptor-more-opts').click(); cy.get('[data-cy="delete"]').click(); cy.checkNotification('Vehicle removed'); });