From 070def57bb54f3ce75bd168c26ee2f2a55e10324 Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 3 Apr 2025 10:28:40 +0200 Subject: [PATCH] refactor: refs #8422 update vehicle DMS tests and add download verification --- .../route/vehicle/vehicleDms.spec.js | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/test/cypress/integration/route/vehicle/vehicleDms.spec.js b/test/cypress/integration/route/vehicle/vehicleDms.spec.js index 740094199..ebf65308c 100644 --- a/test/cypress/integration/route/vehicle/vehicleDms.spec.js +++ b/test/cypress/integration/route/vehicle/vehicleDms.spec.js @@ -32,12 +32,14 @@ describe('Vehicle DMS', () => { }; const updateData = { - Reference: { val: 'Vehicle:5678-DEF' }, + Reference: { val: 'Vehicle:4598-FGH' }, Company: { val: 'CCs', type: 'select' }, Warehouse: { val: 'Warehouse Two', type: 'select' }, Type: { val: 'Facturas Recibidas', type: 'select' }, }; + const workerSummaryUrlRegex = /worker\/\d+\/summary/; + beforeEach(() => { cy.viewport(1920, 1080); cy.login('developer'); @@ -51,16 +53,22 @@ describe('Vehicle DMS', () => { .should('have.length.greaterThan', 0); }); + it('Should download DMS', () => { + cy.get(selectors.lastRowDownloadBtn).click(); + cy.wait(2000); + + const downloadsFolder = Cypress.config('downloadsFolder'); + const fileName = '11.jpg'; + cy.readFile(`${downloadsFolder}/${fileName}`).should('exist'); + }); + it('Should create new DMS', () => { - const uploadFolder = Cypress.config('tmpUploadFolder'); cy.dataCy(selectors.addBtn).click(); cy.dataCy(selectors.referenceInput).type(`{selectall}${data.Reference.val}`); cy.dataCy(selectors.fileInput).selectFile('test/cypress/fixtures/image.jpg', { force: true, }); cy.dataCy(selectors.saveFormBtn).click(); - const fileName = 'image.jpg'; - cy.readFile(`${uploadFolder}/${fileName}`).should('exist'); cy.checkNotification('Data saved'); }); @@ -87,22 +95,18 @@ describe('Vehicle DMS', () => { cy.get(selectors.lastRowDeleteBtn).click(); cy.clickConfirm(); cy.checkNotification('Data deleted'); - cy.validateContent(selectors.lastRowReference, 'Vehicle:3333-BAT'); - }); - - it('Should download DMS', () => { - const downloadsFolder = Cypress.config('downloadsFolder'); - cy.get(selectors.lastRowDownloadBtn).click(); - cy.wait(3000); - - const fileName = '1.txt'; - cy.readFile(`${downloadsFolder}/${fileName}`).should('exist'); + cy.containContent(selectors.lastRowReference, 'Vehicle:3333-BAT'); }); it('Should redirect to worker summary from worker descriptor pop-up', () => { - cy.get(selectors.lastRowWorkerLink).click(); - cy.get(selectors.descriptorTitle).should('contain', 'administrative'); - cy.get(selectors.descriptorGoToSummaryBtn).click(); - cy.containContent(selectors.summaryTitle, 'administrative'); + cy.get(selectors.lastRowWorkerLink) + .click() + .invoke('text') + .then((workerName) => { + workerName = workerName.trim(); + cy.get(selectors.descriptorGoToSummaryBtn).click(); + cy.url().should('match', workerSummaryUrlRegex); + cy.containContent(selectors.descriptorTitle, workerName); + }); }); });