feat: refs #8581 add data-cy attr VnTable & implement validation rows
This commit is contained in:
parent
e1c4a0bdb9
commit
44532c4265
|
@ -621,6 +621,7 @@ function cardClick(_, row) {
|
||||||
@update:selected="emit('update:selected', $event)"
|
@update:selected="emit('update:selected', $event)"
|
||||||
@selection="(details) => handleSelection(details, rows)"
|
@selection="(details) => handleSelection(details, rows)"
|
||||||
:hide-selected-banner="true"
|
:hide-selected-banner="true"
|
||||||
|
data-cy="vnTable"
|
||||||
>
|
>
|
||||||
<template #top-left v-if="!$props.withoutHeader">
|
<template #top-left v-if="!$props.withoutHeader">
|
||||||
<slot name="top-left"> </slot>
|
<slot name="top-left"> </slot>
|
||||||
|
@ -750,6 +751,7 @@ function cardClick(_, row) {
|
||||||
: col?.style
|
: col?.style
|
||||||
"
|
"
|
||||||
style="bottom: 0"
|
style="bottom: 0"
|
||||||
|
:data-cy="`vnTableCell_${col.name}`"
|
||||||
>
|
>
|
||||||
{{ formatColumnValue(col, row, dashIfEmpty) }}
|
{{ formatColumnValue(col, row, dashIfEmpty) }}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -440,3 +440,52 @@ Cypress.Commands.add('validateDescriptor', (toCheck = {}) => {
|
||||||
.eq(index)
|
.eq(index)
|
||||||
.should('contain.text', listbox[index]);
|
.should('contain.text', listbox[index]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('validateVnTableRows', (opts = {}) => {
|
||||||
|
let { cols = [], rows = [] } = opts;
|
||||||
|
if (!Array.isArray(cols)) cols = [cols];
|
||||||
|
const rowSelector = rows.length
|
||||||
|
? rows.map((row) => `:nth-child(${row})`).join(', ')
|
||||||
|
: '> *';
|
||||||
|
|
||||||
|
cy.get(`[data-cy="vnTable"] .q-virtual-scroll__content ${rowSelector}`).each(
|
||||||
|
($el) => {
|
||||||
|
for (const { name, type = 'string', val, operation = 'equal' } of cols) {
|
||||||
|
cy.wrap($el)
|
||||||
|
.find(`[data-cy="vnTableCell_${name}"]`)
|
||||||
|
.invoke('text')
|
||||||
|
.then((text) => {
|
||||||
|
if (type === 'string') expect(text.trim()).to.equal(val);
|
||||||
|
if (type === 'number') {
|
||||||
|
const num = parseFloat(text.trim());
|
||||||
|
switch (operation) {
|
||||||
|
case 'equal':
|
||||||
|
expect(num).to.equal(val);
|
||||||
|
break;
|
||||||
|
case 'greater':
|
||||||
|
expect(num).to.be.greaterThan(val);
|
||||||
|
break;
|
||||||
|
case 'less':
|
||||||
|
expect(num).to.be.lessThan(val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type === 'date') {
|
||||||
|
const date = moment(text.trim(), 'DD/MM/YYYY');
|
||||||
|
const compareDate = moment(val, 'DD/MM/YYYY');
|
||||||
|
switch (operation) {
|
||||||
|
case 'equal':
|
||||||
|
expect(text.trim()).to.equal(val);
|
||||||
|
break;
|
||||||
|
case 'before':
|
||||||
|
expect(date.isBefore(compareDate)).to.be.true;
|
||||||
|
break;
|
||||||
|
case 'after':
|
||||||
|
expect(date.isAfter(compareDate)).to.be.true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue