forked from verdnatura/salix-front
100 lines
3.8 KiB
JavaScript
100 lines
3.8 KiB
JavaScript
describe('InvoiceInDescriptor', () => {
|
|
const checkbox = '[data-cy="vnLvIs booked"] > .q-checkbox';
|
|
|
|
describe('more options', () => {
|
|
beforeEach(() => {
|
|
cy.viewport(1280, 720);
|
|
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', () => {
|
|
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.intercept('POST', 'api/InvoiceIns/6/invoice-in-email').as('sendEmail');
|
|
cy.visit('/#/invoice-in/6/summary');
|
|
cy.selectDescriptorOption(5);
|
|
|
|
cy.get('input[data-cy="sendEmailDialog_address"]').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);
|
|
});
|
|
});
|
|
|
|
it('should create a correcting invoice', () => {
|
|
cy.visit(`/#/invoice-in/1/summary`);
|
|
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.get('tbody > tr:visible').should('have.length', 1);
|
|
});
|
|
|
|
it('should download the file properly', () => {
|
|
cy.visit('/#/invoice-in/1/summary');
|
|
cy.selectDescriptorOption(5);
|
|
const regex = /api\/dms\/1\/downloadFile\?access_token=.*/;
|
|
cy.intercept('GET', regex).as('download');
|
|
cy.wait('@download').then(({ response }) => {
|
|
expect(response.statusCode).to.equal(200);
|
|
expect(response.headers['content-type']).to.include('text/plain');
|
|
});
|
|
});
|
|
});
|
|
});
|