diff --git a/test/cypress/integration/entry/entryDms.spec.js b/test/cypress/integration/entry/entryDms.spec.js index d9f1d77c0..79a9c5162 100644 --- a/test/cypress/integration/entry/entryDms.spec.js +++ b/test/cypress/integration/entry/entryDms.spec.js @@ -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) + // }); }); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 6d627e631..a8b4a86f0 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -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) } }); });