diff --git a/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js b/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js index f267f46af..db78cfdb8 100644 --- a/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js @@ -2,22 +2,74 @@ describe('InvoiceInDescriptor', () => { const checkbox = '[data-cy="vnLvIs booked"] > .q-checkbox'; describe('more options', () => { - it('should booking and unbooking the invoice properly', () => { + beforeEach(() => { cy.viewport(1280, 720); - cy.login('developer'); - cy.visit('/#/invoice-in/1/summary'); - cy.openActionsDescriptor(); - cy.selectDescriptorOption(); + cy.login('administrative'); + }); + it('should booking and unbooking the invoice properly', () => { + cy.visit('/#/invoice-in/1/summary'); + cy.selectDescriptorOption(); cy.dataCy('VnConfirm_confirm').click(); cy.validateCheckbox(checkbox); cy.selectDescriptorOption(); - cy.dataCy('VnConfirm_confirm').click(); cy.validateCheckbox(checkbox, false); }); - }); - // it('should delete the invoice properly', () => { - // }); + it('should delete the invoice properly', () => { + cy.visit('/#/invoice-in/2/summary'); + cy.selectDescriptorOption(2); + cy.clickConfirm(); + cy.checkNotification('invoice deleted'); + }); + + it('should clone the invoice properly', () => { + cy.visit('/#/invoice-in/3/summary'); + cy.selectDescriptorOption(3); + cy.clickConfirm(); + cy.checkNotification('Invoice cloned'); + }); + + it('should show the agricultural PDF properly', () => { + cy.visit('/#/invoice-in/6/summary', { + onBeforeLoad(win) { + cy.stub(win, 'open').as('win'); + }, + }); + cy.selectDescriptorOption(4); + + cy.get('@win') + .should('be.calledOnce') + .then((stub) => { + const [url] = stub.getCall(0).args; + const regex = /api\/InvoiceIns\/6\/invoice-in-pdf\?access_token=.*/; + expect(url).to.match(regex); + cy.request(url).then((response) => + expect(response.headers['content-type']).to.include( + 'application/pdf', + ), + ); + }); + }); + + // it('should send the agricultural PDF properly', () => { + // cy.visit('/#/invoice-in/6/summary'); + // cy.selectDescriptorOption(5); + // cy.checkNotification('Email sent'); + // }); + + // it('should create a corrective invoice properly', () => { + // cy.visit('/#/invoice-in/2/summary'); + // cy.selectDescriptorOption(6); + // cy.dataCy('createCorrectiveItem').click(); + // cy.checkNotification('Corrective invoice created'); + // }); + + // it('should download the file properly', () => { + // cy.visit('/#/invoice-in/2/summary'); + // cy.selectDescriptorOption(7); + // cy.checkNotification('File downloaded'); + // }); + }); });