diff --git a/test/cypress/integration/property/propertyDms.spec.js b/test/cypress/integration/property/propertyDms.spec.js index be742430b..d26754a41 100644 --- a/test/cypress/integration/property/propertyDms.spec.js +++ b/test/cypress/integration/property/propertyDms.spec.js @@ -3,7 +3,7 @@ describe('Property DMS', () => { `tr:${trPosition}-child > .text-right > .no-wrap > :nth-child(${btnPosition}) > .q-btn > .q-btn__content > .q-icon`; const selectors = { - lastRowDownloadBtn: getBtnSelector('last', 1), + firstRowDownloadBtn: getBtnSelector('first', 1), firstRowEditBtn: getBtnSelector('first', 2), lastRowDeleteBtn: getBtnSelector('last', 3), firstRowDeleteBtn: getBtnSelector('first', 3), @@ -65,6 +65,25 @@ describe('Property DMS', () => { cy.dataCy(selectors.saveFormBtn).click(); cy.checkNotification('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); + expect(interception.response.headers['content-disposition']).to.contain( + fileName, + ); + }); + }); it('Should edit DMS', () => { cy.get(selectors.firstRowEditBtn).click(); @@ -95,15 +114,6 @@ describe('Property DMS', () => { cy.clickConfirm(); }); - 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'); - }); - describe('Worker pop-ups', () => { it('Should redirect to the worker summary from worker descriptor pop-up', () => { cy.get(selectors.lastRowWorkerLink)