2023-10-31 07:56:51 +00:00
|
|
|
/// <reference types="cypress" />
|
2025-02-21 16:38:08 +00:00
|
|
|
|
2023-10-31 07:56:51 +00:00
|
|
|
describe('InvoiceInList', () => {
|
2024-08-09 08:47:15 +00:00
|
|
|
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
2024-12-12 11:09:23 +00:00
|
|
|
const firstId = `${firstRow} > td:nth-child(2) span`;
|
2024-08-09 08:47:15 +00:00
|
|
|
const firstDetailBtn = `${firstRow} .q-btn:nth-child(1)`;
|
2024-03-20 07:03:25 +00:00
|
|
|
const summaryHeaders = '.summaryBody .header-link';
|
2025-02-21 16:38:08 +00:00
|
|
|
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',
|
|
|
|
};
|
2023-10-31 07:56:51 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2024-07-02 06:29:55 +00:00
|
|
|
cy.viewport(1920, 1080);
|
2025-03-05 16:29:55 +00:00
|
|
|
cy.login('administrative');
|
2024-02-06 14:11:59 +00:00
|
|
|
cy.visit(`/#/invoice-in/list`);
|
2025-01-31 11:41:16 +00:00
|
|
|
cy.get('#searchbar input').type('{enter}');
|
2023-10-31 07:56:51 +00:00
|
|
|
});
|
|
|
|
|
2025-02-24 17:16:06 +00:00
|
|
|
it('should redirect on clicking a invoice', () => {
|
2024-08-09 08:47:15 +00:00
|
|
|
cy.get(firstId)
|
2023-10-31 07:56:51 +00:00
|
|
|
.invoke('text')
|
2023-12-18 14:39:26 +00:00
|
|
|
.then((content) => {
|
2024-03-20 07:03:25 +00:00
|
|
|
const id = content.replace(/\D/g, '');
|
2024-08-09 08:47:15 +00:00
|
|
|
cy.get(firstRow).click();
|
2023-10-31 07:56:51 +00:00
|
|
|
cy.url().should('include', `/invoice-in/${id}/summary`);
|
|
|
|
});
|
|
|
|
});
|
2025-02-21 16:38:08 +00:00
|
|
|
|
2025-02-24 17:16:06 +00:00
|
|
|
it('should open the details', () => {
|
2023-10-31 07:56:51 +00:00
|
|
|
cy.get(firstDetailBtn).click();
|
2023-11-09 12:26:03 +00:00
|
|
|
cy.get(summaryHeaders).eq(1).contains('Basic data');
|
|
|
|
cy.get(summaryHeaders).eq(4).contains('Vat');
|
2023-10-31 07:56:51 +00:00
|
|
|
});
|
2025-02-21 16:38:08 +00:00
|
|
|
|
2025-02-24 17:16:06 +00:00
|
|
|
it('should create a new Invoice', () => {
|
2025-02-21 16:38:08 +00:00
|
|
|
cy.dataCy('vnTableCreateBtn').click();
|
2025-03-13 09:10:40 +00:00
|
|
|
cy.fillInForm({ ...mock }, { attr: 'data-cy' });
|
2025-02-21 16:38:08 +00:00
|
|
|
cy.dataCy('FormModelPopup_save').click();
|
|
|
|
cy.intercept('GET', /\/api\/InvoiceIns\/\d+\/getTotals$/).as('invoice');
|
|
|
|
cy.wait('@invoice').then(() =>
|
|
|
|
cy.validateDescriptor({
|
|
|
|
title: mockInvoiceRef,
|
2025-02-24 17:16:06 +00:00
|
|
|
listBox: { 0: '11/16/2001', 3: 'The farmer' },
|
2025-02-21 16:38:08 +00:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
cy.get('[data-cy="vnLvCompany"]').should('contain.text', 'ORN');
|
|
|
|
});
|
2023-10-31 07:56:51 +00:00
|
|
|
});
|