/// 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 = '.summaryBody .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).eq(1).contains('Basic data'); cy.get(summaryHeaders).eq(4).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'); }); });