From 92dcff6d493c722414ea8549a88794598db4168f Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 7 Mar 2024 14:54:20 +0100 Subject: [PATCH] fix: refs #6942 tests e2e --- src/components/CrudModel.vue | 23 +++++++++++++++++++---- src/components/FormModel.vue | 24 ++++++++++++++++++------ test/cypress/support/commands.js | 28 +++++++++++++++++++--------- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index aaada510e..cf040dbc4 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -312,17 +312,32 @@ watch(formUrl, async () => { /> - + - {{ t('globals.saveAndContinue') }} + + + {{ t('globals.save').toUpperCase() }} + diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index ab491390a..76ba6d4df 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -254,19 +254,31 @@ watch(formUrl, async () => { /> - + - {{ - t('globals.saveAndContinue') - }} + + + {{ t('globals.save').toUpperCase() }} + diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index f075d500f..f2f2c372c 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -52,16 +52,18 @@ Cypress.Commands.add('getValue', (selector) => { } // Si es un QSelect if ($el.find('.q-select__dropdown-icon').length) { - return cy.get( - selector + - '> .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > input' - ).invoke('val') + return cy + .get( + selector + + '> .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > input' + ) + .invoke('val'); } // Si es un QSelect if ($el.find('span').length) { - return cy.get( - selector + ' span' - ).then(($span) => { return $span[0].innerText }) + return cy.get(selector + ' span').then(($span) => { + return $span[0].innerText; + }); } // Puedes aƱadir un log o lanzar un error si el elemento no es reconocido cy.log('Elemento no soportado'); @@ -80,8 +82,16 @@ Cypress.Commands.add('checkOption', (selector) => { // Global buttons Cypress.Commands.add('saveCard', () => { + const dropdownArrow = '.q-btn-dropdown__arrow-container > .q-btn__content > .q-icon'; + cy.get('#st-actions').then(($el) => { + if ($el.find(dropdownArrow).length) cy.get(dropdownArrow).click(); + }); cy.get('[title="Save"]').click(); }); + +/* Cypress.Commands.add('saveCard', () => { + cy.get('[title="Save"]').click(); +}); */ Cypress.Commands.add('resetCard', () => { cy.get('[title="Reset"]').click(); }); @@ -132,13 +142,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 (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('equal', value) + cy.getValue(`:nth-child(${index + 1})`).should('equal', value); } }); });