From 5515f55bf69d3f2121410d28bdf5f35c4f9557b0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Nov 2024 12:51:05 +0100 Subject: [PATCH] test: fix e2e --- .../integration/client/clientList.spec.js | 31 ++++++++++++++----- .../vnComponent/vnLocation.spec.js | 6 ++-- test/cypress/support/commands.js | 6 ++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index 93e53b9f6..b87ddff3b 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -6,7 +6,11 @@ describe('Client list', () => { cy.visit('/#/customer/list', { timeout: 5000, onBeforeLoad(win) { - cy.stub(win, 'open'); + cy.stub(win, 'open') + .callsFake((url) => { + return win.open.wrappedMethod.call(win, url, '_self'); + }) + .as('Open'); }, }); }); @@ -44,20 +48,31 @@ describe('Client list', () => { }); }); - it('Client founded create ticket', () => { + it.only('Client founded create ticket', () => { const search = 'Jessica Jones'; cy.searchByLabel('Name', search); - cy.clickButtonsDescriptor(2); + cy.openActionDescriptor('Create ticket'); cy.waitForElement('#formModel'); - cy.waitForElement('.q-form'); - cy.checkValueForm(1, search); + cy.waitForElement('.q-form', { timeout: 5000 }); + cy.checkValueSelectForm(1, 1110); + cy.checkValueSelectForm(2, search); + // cy.get('@Open').should('have.been.calledOnceWithExactly', [ + // '/#/ticket/list?table={"clientFk":1110}&createForm={"addressId":10,"clientId":1110}', + // '_blank', + // 'noopener,noreferrer', + // ]); }); - it('Client founded create order', () => { + it.only('Client founded create order', () => { const search = 'Jessica Jones'; cy.searchByLabel('Name', search); - cy.clickButtonsDescriptor(4); + cy.openActionDescriptor('New order'); cy.waitForElement('#formModel'); - cy.waitForElement('.q-form'); + cy.waitForElement('.q-form', { timeout: 5000 }); + cy.checkValueForm(1, 1110); cy.checkValueForm(2, search); + // cy.get('@Open').should( + // 'have.been.calledOnceWithExactly', + // '"/#/order/list?table={"clientFk":1110}&createForm={"addressId":10,"clientFk":1110}", "_blank", "noopener,noreferrer"' + // ); }); }); diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 924b16adc..29e1f868f 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -15,10 +15,10 @@ describe('VnLocation', () => { cy.domContentLoad(); cy.get(createLocationButton).click(); }); - it('should filter provinces based on selected country', () => { + it.only('shoul d filter provinces based on selected country', () => { // Select a country cy.selectOption( - `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`, + `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`, 'Ecuador' ); // Verify that provinces are filtered @@ -32,7 +32,7 @@ describe('VnLocation', () => { ).should('have.length', 1); }); - it('should filter towns based on selected province', () => { + it.only('should filter towns based on selected province', () => { // Select a country cy.selectOption( `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`, diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 34aadad1d..b92bbe269 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -295,16 +295,16 @@ Cypress.Commands.add('checkNotification', (text) => { throw new Error(`Notification not found: "${text}"`); }); }); - +// :nth-child(2) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container Cypress.Commands.add('checkValueForm', (id, search) => { cy.get( - `.grid-create > :nth-child(${id}) > .q-field__inner>.q-field__control> .q-field__control-container>.q-field__native >.q-field__input` + `.grid-create > :nth-child(${id}) > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input` ).should('have.value', search); }); Cypress.Commands.add('checkValueSelectForm', (id, search) => { cy.get( - `.grid-create > :nth-child(${id}) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container>.q-field__native>.q-field__input` + `.grid-create > :nth-child(${id}) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > .q-field__input` ).should('have.value', search); });