53 lines
1.9 KiB
JavaScript
53 lines
1.9 KiB
JavaScript
/// <reference types="cypress" />
|
|
|
|
describe('InvoiceInList', () => {
|
|
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
|
const firstId = `${firstRow} > td:nth-child(2) span`;
|
|
const firstDetailBtn = `${firstRow} .q-btn:nth-child(1)`;
|
|
const summaryHeaders = (opt) => `.summaryBody > .${opt} > .q-pb-lg > .header-link`;
|
|
const mockInvoiceRef = `createMockInvoice${Math.floor(Math.random() * 100)}`;
|
|
const mock = {
|
|
vnSupplierSelect: { val: 'farmer king', type: 'select' },
|
|
'Invoice nº_input': mockInvoiceRef,
|
|
Company_select: { val: 'orn', type: 'select' },
|
|
'Expedition date_inputDate': '16-11-2001',
|
|
};
|
|
|
|
beforeEach(() => {
|
|
cy.viewport(1920, 1080);
|
|
cy.login('administrative');
|
|
cy.visit(`/#/invoice-in/list`);
|
|
cy.get('#searchbar input').type('{enter}');
|
|
});
|
|
|
|
it('should redirect on clicking a invoice', () => {
|
|
cy.get(firstId)
|
|
.invoke('text')
|
|
.then((content) => {
|
|
const id = content.replace(/\D/g, '');
|
|
cy.get(firstRow).click();
|
|
cy.url().should('include', `/invoice-in/${id}/summary`);
|
|
});
|
|
});
|
|
|
|
it('should open the details', () => {
|
|
cy.get(firstDetailBtn).click();
|
|
cy.get(summaryHeaders('max-width')).contains('Basic data');
|
|
cy.get(summaryHeaders('vat')).contains('Vat');
|
|
});
|
|
|
|
it('should create a new Invoice', () => {
|
|
cy.dataCy('vnTableCreateBtn').click();
|
|
cy.fillInForm({ ...mock }, { attr: 'data-cy' });
|
|
cy.dataCy('FormModelPopup_save').click();
|
|
cy.intercept('GET', /\/api\/InvoiceIns\/\d+\/getTotals$/).as('invoice');
|
|
cy.wait('@invoice').then(() =>
|
|
cy.validateDescriptor({
|
|
title: mockInvoiceRef,
|
|
listBox: { 0: '11/16/2001', 3: 'The farmer' },
|
|
}),
|
|
);
|
|
cy.get('[data-cy="vnLvCompany"]').should('contain.text', 'ORN');
|
|
});
|
|
});
|