refactor: refs #8388 streamline InvoiceInVat tests by removing unused variables and improving element selectors
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jorge Penadés 2025-05-15 16:05:16 +02:00
parent 7fcea1dfdc
commit 21d36a0d37
1 changed files with 21 additions and 19 deletions

View File

@ -1,11 +1,11 @@
/// <reference types="cypress" />
describe('InvoiceInVat', () => {
const thirdRow = 'tbody > :nth-child(3)';
const firstLineVat = 'tbody > :nth-child(1) ';
const vats = '[data-cy="vat-sageiva"]';
const dialogInputs = '.q-dialog label input';
const addBtn = 'tbody tr:nth-child(1) td:nth-child(2) .--add-icon';
const randomInt = Math.floor(Math.random() * 100);
const firstTaxType = 'td[data-col-field="taxTypeSageFk"][data-row-index="0"]';
const firstExpense = 'td[data-col-field="expenseFk"][data-row-index="0"]';
const firstDeductible = 'td[data-col-field="isDeductible"][data-row-index="0"]';
const taxType = 'H.P. IVA 21% CEE';
beforeEach(() => {
cy.login('administrative');
@ -13,27 +13,29 @@ describe('InvoiceInVat', () => {
});
it('should edit the sage iva', () => {
cy.selectOption(`${firstLineVat} ${vats}`, 'H.P. IVA 21% CEE');
cy.get(firstTaxType).click().type(`{selectall}{backspace}${taxType}{enter}`);
cy.saveCard();
cy.get(vats).eq(0).should('have.value', '8: H.P. IVA 21% CEE');
cy.get(firstTaxType).should('have.text', `8: ${taxType}`);
});
it('should mark the line as deductible VAT', () => {
cy.get(`${firstLineVat} [data-cy="isDeductible_checkbox"]`).click();
cy.saveCard();
cy.get(`${firstLineVat} [data-cy="isDeductible_checkbox"]`)
.click();
cy.get(firstDeductible).click().click();
cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'Data saved');
});
it('should add a new row', () => {
cy.addRow();
cy.fillRow(thirdRow, [true, 2000000001, 30, 'H.P. IVA 10']);
cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'Data saved');
cy.dataCy('vnTableCreateBtn').click();
cy.fillInForm(
{
Expense_select: { val: '2000000001', type: 'select' },
'Taxable base_input': '30',
'vat-sageiva': { val: 'H.P. IVA 10', type: 'select' },
},
{ attr: 'data-cy' },
);
cy.dataCy('FormModelPopup_save').click();
cy.get('.q-notification__message').should('have.text', 'Data created');
});
it('should remove the first line', () => {
@ -41,10 +43,10 @@ describe('InvoiceInVat', () => {
});
it('should correctly handle expense addition', () => {
cy.get(addBtn).click();
cy.get(firstExpense).click();
cy.get('.--add-icon').click();
cy.get(dialogInputs).eq(0).type(randomInt);
cy.get(dialogInputs).eq(1).type('This is a dummy expense');
cy.get('[data-cy="FormModelPopup_save"]').click();
cy.get('.q-notification__message').should('have.text', 'Data created');
});