describe('InvoiceInDescriptor', () => { beforeEach(() => cy.login('administrative')); describe('more options', () => { it('should booking and unbooking the invoice properly', () => { const checkbox = '[data-cy="vnLvIs booked"] > .q-checkbox'; cy.visit('/#/invoice-in/2/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', () => { 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'); cy.validatePdfDownload( /api\/InvoiceIns\/6\/invoice-in-pdf\?access_token=.*/, () => cy.selectDescriptorOption(4), ); }); it('should send the agricultural PDF properly', () => { cy.intercept('POST', 'api/InvoiceIns/6/invoice-in-email').as('sendEmail'); cy.visit('/#/invoice-in/6/summary'); cy.selectDescriptorOption(5); cy.dataCy('SendEmailNotifiactionDialogInput_input').type( '{selectall}jorgito@gmail.mx', ); cy.clickConfirm(); cy.checkNotification('Notification sent'); cy.wait('@sendEmail').then(({ request, response }) => { expect(request.body).to.deep.equal({ recipientId: 2, recipient: 'jorgito@gmail.mx', }); expect(response.statusCode).to.equal(200); }); }); // https://redmine.verdnatura.es/issues/8767 it.skip('should download the file properly', () => { cy.visit('/#/invoice-in/1/summary'); cy.validateDownload(() => cy.selectDescriptorOption(5)); }); }); describe('buttons', () => { beforeEach(() => cy.visit('/#/invoice-in/1/summary')); it('should navigate to the supplier summary', () => { cy.clicDescriptorAction(1); cy.url().should('to.match', /supplier\/\d+\/summary/); }); it('should navigate to the entry summary', () => { cy.clicDescriptorAction(2); cy.url().should('to.match', /entry\/\d+\/summary/); }); it('should navigate to the invoiceIn list', () => { cy.clicDescriptorAction(3); cy.url().should('to.match', /invoice-in\/list\?table=\{.*supplierFk.+\}/); }); }); describe('corrective', () => { const originalId = 4; beforeEach(() => cy.visit(`/#/invoice-in/${originalId}/summary`)); it('should create a correcting invoice and redirect to original invoice', () => { createCorrective(); redirect(originalId); }); it('should create a correcting invoice and navigate to list filtered by corrective', () => { createCorrective(); redirect(originalId); cy.clicDescriptorAction(4); cy.validateVnTableRows({ cols: [ { name: 'supplierRef', val: '1237', operation: 'include', }, ], }); }); }); describe('link', () => { it('should open the supplier descriptor popup', () => { cy.visit('/#/invoice-in/1/summary'); cy.intercept('GET', /Suppliers\/\d+/).as('getSupplier'); cy.dataCy('invoiceInDescriptor_supplier').then(($el) => { const alias = $el.text().trim(); $el.click(); cy.wait('@getSupplier').then(() => cy.validateDescriptor({ listbox: { 1: alias }, popup: true }), ); }); }); }); }); function createCorrective() { cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective'); cy.selectDescriptorOption(4); cy.dataCy('saveCorrectiveInvoice').click(); cy.wait('@corrective').then(({ response }) => { const correctingId = response.body; cy.url().should('include', `/invoice-in/${correctingId}/summary`); cy.visit(`/#/invoice-in/${correctingId}/corrective`); cy.dataCy('invoiceInCorrective_class').should('contain.value', 'R2'); cy.dataCy('invoiceInCorrective_type').should('contain.value', 'diferencias'); cy.dataCy('invoiceInCorrective_reason').should('contain.value', 'sales details'); }); } function redirect(subtitle) { const regex = new RegExp(`InvoiceIns/${subtitle}\\?filter=.*`); cy.intercept('GET', regex).as('getOriginal'); cy.clicDescriptorAction(4); cy.wait('@getOriginal'); cy.validateDescriptor({ subtitle }); }