salix-front/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js

60 lines
2.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

describe('invoiceInCorrective', () => {
beforeEach(() => cy.login('administrative'));
it('should modify the invoice', () => {
cy.visit('/#/invoice-in/1/summary');
cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective');
cy.intercept('POST', '/api/InvoiceInCorrections/crud').as('crud');
cy.intercept('GET', /InvoiceInCorrections\?filter=.+/).as('getCorrective');
cy.selectDescriptorOption(4);
cy.dataCy('saveCorrectiveInvoice').click();
cy.wait('@corrective').then(({ response }) => {
const correctingFk = response.body;
cy.url().should('include', `/invoice-in/${correctingFk}/summary`);
cy.visit(`/#/invoice-in/${correctingFk}/corrective`);
cy.selectOption('[data-cy="invoiceInCorrective_class"]', 'r4');
cy.selectOption('[data-cy="invoiceInCorrective_type"]', 'sustitución');
cy.selectOption('[data-cy="invoiceInCorrective_reason"]', 'vat');
cy.dataCy('crudModelDefaultSaveBtn').click();
cy.wait('@crud');
cy.reload();
cy.wait('@getCorrective');
cy.validateRow('tbody > :nth-of-type(1)', [
,
'S Por sustitución',
'R4',
'Error in VAT calculation',
]);
});
});
it('should not be able to modify the invoice if the original invoice is booked', () => {
cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective');
cy.visit('/#/invoice-in/4/summary');
cy.selectDescriptorOption();
cy.dataCy('VnConfirm_confirm').click();
cy.selectDescriptorOption(4);
cy.dataCy('saveCorrectiveInvoice').click();
cy.wait('@corrective').then(({ response }) => {
const correctingFk = response.body;
cy.url().should('include', `/invoice-in/${correctingFk}/summary`);
cy.visit(`/#/invoice-in/${correctingFk}/corrective`);
cy.dataCy('invoiceInCorrective_class').should('be.disabled');
cy.dataCy('invoiceInCorrective_type').should('be.disabled');
cy.dataCy('invoiceInCorrective_reason').should('be.disabled');
});
});
it('should show/hide the section if it is a corrective invoice', () => {
cy.visit('/#/invoice-in/1/summary');
cy.get('[data-cy="InvoiceInCorrective-menu-item"]').should('not.exist');
cy.clicDescriptorAction(4);
cy.get('[data-cy="InvoiceInCorrective-menu-item"]').should('exist');
});
});