refs #5509 feat: add e2e

This commit is contained in:
Alex Moreno 2024-02-15 15:00:30 +01:00
parent 4315408452
commit b3e554d99e
2 changed files with 39 additions and 4 deletions

View File

@ -1,5 +1,6 @@
describe('WagonTypeCreate', () => {
const entryId = 1;
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
@ -7,7 +8,34 @@ describe('WagonTypeCreate', () => {
});
it('should create and delete a new wagon type', () => {
cy.addCard()
it('should create edit and remove new dms', () => {
cy.addRow();
cy.get('.icon-attach').click()
cy.get('.q-file').selectFile('test/cypress/fixtures/image.jpg', {
force: true,
});
cy.get("tbody > tr").then((value) => {
//Create and check if exist new row
let newFileTd = Cypress.$(value).length;
cy.get('.q-btn--standard > .q-btn__content > .block').click();
expect(value).to.have.length(newFileTd++);
const newRowSelector = `tbody > :nth-child(${newFileTd})`
cy.waitForElement(newRowSelector);
//Edit new dms
const u = undefined;
cy.validateRow(newRowSelector, [u,u,u,u,'ENTRADA ID 1'])
cy.get(`tbody :nth-child(${newFileTd}) > .text-right > .flex > :nth-child(2) > .q-btn > .q-btn__content > .q-icon`).click();
})
// cy.log('newFileTd', newFileTd)
// //Create and check if exist new row
// cy.log('newFileTd:', newFileTd);
// cy.get(`tbody :nth-child(${newFileTd}) > .text-right > .flex > :nth-child(2) > .q-btn > .q-btn__content > .q-icon`).click()
// cy.get(`tbody :nth-child(${newFileTd}) > :nth-child(5) > .q-tr > :nth-child(1) > span`).then((value) => {
// cy.log(value)
// });
});
});

View File

@ -42,7 +42,7 @@ Cypress.Commands.add('login', (user) => {
});
Cypress.Commands.add('waitForElement', (element) => {
cy.get(element, { timeout: 2000 }).should('be.visible');
cy.get(element, { timeout: 5000 }).should('be.visible');
});
Cypress.Commands.add('getValue', (selector) => {
@ -57,6 +57,12 @@ Cypress.Commands.add('getValue', (selector) => {
'> .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > input'
);
}
// Si es un QSelect
if ($el.find('span').length) {
return cy.get(
selector + ' span'
);
}
// Puedes añadir un log o lanzar un error si el elemento no es reconocido
cy.log('Elemento no soportado');
});
@ -126,12 +132,13 @@ Cypress.Commands.add('validateRow', (rowSelector, expectedValues) => {
cy.get(rowSelector).within(() => {
for (const [index, value] of expectedValues.entries()) {
cy.log('CHECKING ', index, value);
if(value === undefined) continue
if (typeof value == 'boolean') {
const prefix = value ? '' : 'not.';
cy.getValue(`:nth-child(${index + 1})`).should(`${prefix}be.checked`);
continue;
}
cy.getValue(`:nth-child(${index + 1})`).should('have.value', value);
cy.getValue(`:nth-child(${index + 1})`).invoke('text').should('have.value', value)
}
});
});