feat: refs #8581 validateVnTableRows

This commit is contained in:
Jorge Penadés 2025-02-21 17:37:58 +01:00
parent bb2997fc65
commit fcea5b7bbe
1 changed files with 6 additions and 7 deletions

View File

@ -445,11 +445,10 @@ Cypress.Commands.add('validateVnTableRows', (opts = {}) => {
let { cols = [], rows = [] } = opts; let { cols = [], rows = [] } = opts;
if (!Array.isArray(cols)) cols = [cols]; if (!Array.isArray(cols)) cols = [cols];
const rowSelector = rows.length const rowSelector = rows.length
? rows.map((row) => `:nth-child(${row})`).join(', ') ? rows.map((row) => `> :nth-child(${row})`).join(', ')
: '> *'; : '> *';
cy.get(`[data-cy="vnTable"] .q-virtual-scroll__content`).within(() => {
cy.get(`[data-cy="vnTable"] .q-virtual-scroll__content ${rowSelector}`).each( cy.get(`${rowSelector}`).each(($el) => {
($el) => {
for (const { name, type = 'string', val, operation = 'equal' } of cols) { for (const { name, type = 'string', val, operation = 'equal' } of cols) {
cy.wrap($el) cy.wrap($el)
.find(`[data-cy="vnTableCell_${name}"]`) .find(`[data-cy="vnTableCell_${name}"]`)
@ -457,7 +456,7 @@ Cypress.Commands.add('validateVnTableRows', (opts = {}) => {
.then((text) => { .then((text) => {
if (type === 'string') expect(text.trim()).to.equal(val); if (type === 'string') expect(text.trim()).to.equal(val);
if (type === 'number') { if (type === 'number') {
const num = parseFloat(text.trim()); const num = parseFloat(text.trim().replace(/[^\d.-]/g, ''));
switch (operation) { switch (operation) {
case 'equal': case 'equal':
expect(num).to.equal(val); expect(num).to.equal(val);
@ -486,6 +485,6 @@ Cypress.Commands.add('validateVnTableRows', (opts = {}) => {
} }
}); });
} }
}, });
); });
}); });