salix-front/test/cypress/integration/deliveryNote/deliveryNoteList.spec.js

60 lines
2.1 KiB
JavaScript

/// <reference types="cypress" />
describe('DelieryNote list', () => {
const supplier = 'PLANTS SL';
let totalSelectedAmount = 0;
beforeEach(() => {
cy.login('developer');
cy.visit('/#/delivery-note/list');
cy.dataCy('vn-searchbar_input').type('{enter}');
});
it('Should show data and then filter by supplier', () => {
cy.selectOption('[data-cy="deliveryNote-supplier-filter"]', supplier);
cy.dataCy('vnFilterPanel_search').click();
cy.validateVnTableRows({ cols: [{ name: 'supplierFk', val: supplier }] });
});
it('click the first two checkboxes and the table footer quantity should match the sum of the checked rows', () => {
cy.selectRows([1, 2]);
[1, 2].forEach((index) => {
cy.get(
`.q-virtual-scroll__content > :nth-child(${index}) > :nth-child(1) > .q-checkbox > .q-checkbox__inner`,
).should('have.class', 'q-checkbox__inner--truthy');
});
const getAmountFromRow = (index) => {
return cy
.get(
`.q-virtual-scroll__content > :nth-child(${index}) [data-col-field="amount"]`,
)
.invoke('text')
.then((text) =>
parseFloat(text.replace(/[^\d.,-]/g, '').replace(',', '')),
);
};
getAmountFromRow(1)
.then((amount1) => {
totalSelectedAmount += amount1;
return getAmountFromRow(2);
})
.then((amount2) => {
totalSelectedAmount += amount2;
cy.log('Total seleccionado:', totalSelectedAmount);
cy.dataCy('deliveryNote-total-amount')
.invoke('text')
.then((text) => {
const totalFooterAmount = parseFloat(
text.replace(/[^\d.,-]/g, '').replace(',', ''),
);
expect(totalFooterAmount).to.eq(totalSelectedAmount);
});
});
});
});