diff --git a/test/cypress/integration/route/vehicle/vehicleDms.spec.js b/test/cypress/integration/route/vehicle/vehicleDms.spec.js index 4d9250e0f..64f2d6f59 100644 --- a/test/cypress/integration/route/vehicle/vehicleDms.spec.js +++ b/test/cypress/integration/route/vehicle/vehicleDms.spec.js @@ -1,16 +1,16 @@ describe('Vehicle DMS', () => { const getSelector = (btnPosition) => - `tr:last-child > .text-right > .no-wrap > :nth-child(${btnPosition}) > .q-btn > .q-btn__content > .q-icon`; + `tr:first-child > .text-right > .no-wrap > :nth-child(${btnPosition}) > .q-btn > .q-btn__content > .q-icon`; const selectors = { - lastRowDownloadBtn: getSelector(1), - lastRowEditBtn: getSelector(2), - lastRowDeleteBtn: getSelector(3), + firstRowDownloadBtn: getSelector(1), + firstRowEditBtn: getSelector(2), + firstRowDeleteBtn: getSelector(3), lastRowReference: 'tr:last-child > :nth-child(5) > .q-tr > :nth-child(1) > span', firstRowReference: 'tr:first-child > :nth-child(5) > .q-tr > :nth-child(1) > span', firstRowId: 'tr:first-child > :nth-child(2) > .q-tr > :nth-child(1) > span', - lastRowWorkerLink: 'tr:last-child > :nth-child(8) > .q-tr > .link', + firstRowWorkerLink: 'tr:first-child > :nth-child(8) > .q-tr > .link', descriptorTitle: '.descriptor .title', descriptorOpenSummaryBtn: '.q-menu .descriptor [data-cy="openSummaryBtn"]', descriptorGoToSummaryBtn: '.q-menu .descriptor [data-cy="goToSummaryBtn"]', @@ -55,10 +55,26 @@ describe('Vehicle DMS', () => { .should('have.length.greaterThan', 0); }); - it.skip('Should download DMS', () => { - const fileName = '11.jpg'; - cy.intercept('GET', /\/api\/dms\/11\/downloadFile/).as('download'); - cy.get(selectors.lastRowDownloadBtn).click(); + it('Should create new DMS', () => { + const formSelectors = { + actionBtn: selectors.addBtn, + fileInput: selectors.fileInput, + saveFormBtn: selectors.saveFormBtn, + }; + + cy.testDmsAction('create', formSelectors, data, 'Data saved'); + }); + + it('Should download DMS', () => { + let fileName; + cy.get(selectors.firstRowId) + .invoke('text') + .then((label) => { + label = label.trim(); + fileName = `${label}.jpg`; + }); + cy.intercept('GET', /\/api\/dms\/\d+\/downloadFile/).as('download'); + cy.get(selectors.firstRowDownloadBtn).click(); cy.wait('@download').then((interception) => { expect(interception.response.statusCode).to.equal(200); @@ -68,16 +84,6 @@ describe('Vehicle DMS', () => { }); }); - it('Should create new DMS', () => { - const formSelectors = { - actionBtn: selectors.addBtn, - fileInput: selectors.fileInput, - saveFormBtn: selectors.saveFormBtn, - }; - - cy.testDmsAction('create', formSelectors, data, 'Data saved'); - }); - it('Should import DMS', () => { const data = { Document: { val: '10', type: 'select' }, @@ -93,8 +99,8 @@ describe('Vehicle DMS', () => { it('Should edit DMS', () => { const formSelectors = { - actionBtn: selectors.lastRowEditBtn, - selectorContentToCheck: selectors.lastRowReference, + actionBtn: selectors.firstRowEditBtn, + selectorContentToCheck: selectors.firstRowReference, saveFormBtn: selectors.saveFormBtn, }; @@ -109,8 +115,8 @@ describe('Vehicle DMS', () => { it('Should delete DMS', () => { const formSelectors = { - actionBtn: selectors.lastRowDeleteBtn, - selectorContentToCheck: selectors.lastRowReference, + actionBtn: selectors.firstRowDeleteBtn, + selectorContentToCheck: selectors.firstRowReference, }; cy.testDmsAction( @@ -125,7 +131,7 @@ describe('Vehicle DMS', () => { describe('Worker pop-ups', () => { it('Should redirect to worker summary from worker descriptor pop-up', () => { cy.checkRedirectionFromPopUp({ - selectorToClick: selectors.lastRowWorkerLink, + selectorToClick: selectors.firstRowWorkerLink, steps: [selectors.descriptorGoToSummaryBtn], expectedUrlRegex: workerSummaryUrlRegex, expectedTextSelector: selectors.descriptorTitle, @@ -134,7 +140,7 @@ describe('Vehicle DMS', () => { it('Should redirect to worker summary from summary pop-up from worker descriptor pop-up', () => { cy.checkRedirectionFromPopUp({ - selectorToClick: selectors.lastRowWorkerLink, + selectorToClick: selectors.firstRowWorkerLink, steps: [ selectors.descriptorOpenSummaryBtn, selectors.summaryGoToSummaryBtn,