0
0
Fork 0

test: better command if is date

This commit is contained in:
Alex Moreno 2024-07-16 10:42:35 +02:00
parent 9cc11f0a28
commit f01e6d74f8
2 changed files with 3 additions and 9 deletions

View File

@ -14,7 +14,7 @@ describe('WorkerCreate', () => {
Phone: { val: '123456789' }, Phone: { val: '123456789' },
'Worker code': { val: 'DWW' }, 'Worker code': { val: 'DWW' },
Boss: { val: developerBossId, type: 'select' }, Boss: { val: developerBossId, type: 'select' },
Birth: { val: '2022-12-11T23:00:00.000Z', type: 'date', day: 11 }, Birth: { val: '11-12-2022', type: 'date' },
}; };
const external = { const external = {
Fi: { val: 'Z4531219V' }, Fi: { val: 'Z4531219V' },

View File

@ -87,7 +87,6 @@ Cypress.Commands.add('selectOption', (selector, option) => {
}); });
Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => { Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
const days = '.q-date__calendar-days .q-date__calendar-item--in';
cy.waitForElement('.q-form > .q-card'); cy.waitForElement('.q-form > .q-card');
cy.get(`${form} input`).each(([el]) => { cy.get(`${form} input`).each(([el]) => {
cy.wrap(el) cy.wrap(el)
@ -96,19 +95,14 @@ Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
const field = obj[ariaLabel]; const field = obj[ariaLabel];
if (!field) return; if (!field) return;
const { type, val, day } = field; const { type, val } = field;
switch (type) { switch (type) {
case 'select': case 'select':
cy.wrap(el).type(val); cy.wrap(el).type(val);
cy.get('.q-menu .q-item').contains(val).click(); cy.get('.q-menu .q-item').contains(val).click();
break; break;
case 'date': case 'date':
cy.get( cy.wrap(el).type(val.split('-').join(''));
'[label="Birth"] > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon'
).click();
cy.get(days)
.eq(day ? day - 1 : 0)
.click();
break; break;
default: default:
cy.wrap(el).type(val); cy.wrap(el).type(val);