From 5515f55bf69d3f2121410d28bdf5f35c4f9557b0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Nov 2024 12:51:05 +0100 Subject: [PATCH 1/9] 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); }); From 65100fcf256f9c19494088c9c2b3d48422c8970b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Nov 2024 13:45:44 +0100 Subject: [PATCH 2/9] test: fix e2e --- test/cypress/integration/vnComponent/vnLocation.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 29e1f868f..0ee453aa0 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -15,7 +15,7 @@ describe('VnLocation', () => { cy.domContentLoad(); cy.get(createLocationButton).click(); }); - it.only('shoul d filter provinces based on selected country', () => { + it('should filter provinces based on selected country', () => { // Select a country cy.selectOption( `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`, @@ -32,7 +32,7 @@ describe('VnLocation', () => { ).should('have.length', 1); }); - it.only('should filter towns based on selected province', () => { + it('should filter towns based on selected province', () => { // Select a country cy.selectOption( `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`, From b4ee19bcde76c9d44568b7742aeab673fdf61b50 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 19 Nov 2024 15:56:27 +0100 Subject: [PATCH 3/9] test: #8162 fix clientList spec --- .../integration/client/clientList.spec.js | 18 +++++----- .../vnComponent/vnLocation.spec.js | 35 ++++++------------- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index b87ddff3b..b3ac9d3df 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -15,7 +15,7 @@ describe('Client list', () => { }); }); - it('Client list create new client', () => { + it.only('Client list create new client', () => { cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); const data = { Name: { val: 'Name 1' }, @@ -24,9 +24,9 @@ describe('Client list', () => { 'Web user': { val: 'user_test_1' }, Street: { val: 'C/ STREET 1' }, Email: { val: 'user.test@1.com' }, - 'Business type': { val: 'Otros', type: 'select' }, - 'Sales person': { val: 'salesboss', type: 'select' }, + 'Sales person': { val: 'employee', type: 'select' }, Location: { val: '46000, Valencia(Province one), EspaƱa', type: 'select' }, + 'Business type': { val: 'Otros', type: 'select' }, }; cy.fillInForm(data); @@ -48,13 +48,13 @@ describe('Client list', () => { }); }); - it.only('Client founded create ticket', () => { + it('Client founded create ticket', () => { const search = 'Jessica Jones'; cy.searchByLabel('Name', search); cy.openActionDescriptor('Create ticket'); cy.waitForElement('#formModel'); - cy.waitForElement('.q-form', { timeout: 5000 }); - cy.checkValueSelectForm(1, 1110); + cy.waitForElement('.q-form'); + cy.checkValueSelectForm(1, search); cy.checkValueSelectForm(2, search); // cy.get('@Open').should('have.been.calledOnceWithExactly', [ // '/#/ticket/list?table={"clientFk":1110}&createForm={"addressId":10,"clientId":1110}', @@ -62,13 +62,13 @@ describe('Client list', () => { // 'noopener,noreferrer', // ]); }); - it.only('Client founded create order', () => { + it('Client founded create order', () => { const search = 'Jessica Jones'; cy.searchByLabel('Name', search); cy.openActionDescriptor('New order'); cy.waitForElement('#formModel'); - cy.waitForElement('.q-form', { timeout: 5000 }); - cy.checkValueForm(1, 1110); + cy.waitForElement('.q-form'); + cy.checkValueForm(1, search); cy.checkValueForm(2, search); // cy.get('@Open').should( // 'have.been.calledOnceWithExactly', diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 0ee453aa0..70c88b26f 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -7,6 +7,9 @@ describe('VnLocation', () => { prefix: '.q-dialog__inner > .column > #formModel > .q-card', sufix: ' .q-field__inner > .q-field__control', }; + const countrySelector = `${createForm.prefix} > :nth-child(5) > :nth-child(3) > ${createForm.sufix}`; + const provinceSelector = `${createForm.prefix} > :nth-child(5) > :nth-child(2) > ${createForm.sufix}`; + const citySelector = `${createForm.prefix} > :nth-child(4) > :nth-child(2) > ${createForm.sufix}`; describe('CreateFormDialog ', () => { beforeEach(() => { cy.viewport(1280, 720); @@ -17,45 +20,29 @@ describe('VnLocation', () => { }); it('should filter provinces based on selected country', () => { // Select a country - cy.selectOption( - `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`, - 'Ecuador' - ); + cy.selectOption(countrySelector, 'Ecuador'); // Verify that provinces are filtered - cy.get( - `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}` - ).should('have.length', 1); + cy.get(countrySelector).should('have.length', 1); // Verify that towns are filtered - cy.get( - `${createForm.prefix} > :nth-child(4) > .q-field:nth-child(3)> ${createForm.sufix}` - ).should('have.length', 1); + cy.get(citySelector).should('have.length', 1); }); it('should filter towns based on selected province', () => { // Select a country - cy.selectOption( - `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}`, - 'Ecuador' - ); + cy.selectOption(countrySelector, 'Ecuador'); // Verify that provinces are filtered - cy.get( - `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}` - ).should('have.length', 1); + cy.get(provinceSelector).should('have.length', 1); // Verify that towns are filtered - cy.get( - `${createForm.prefix} > :nth-child(4) > .q-field:nth-child(3)> ${createForm.sufix}` - ).should('have.length', 1); + cy.get(citySelector).should('have.length', 1); }); it('should pass selected country', () => { // Select a country const country = 'Ecuador'; const province = 'Province five'; - cy.selectOption( - `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`, - country - ); + + cy.selectOption(countrySelector, country); cy.selectOption( `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, province From 1fb927488a2df2a312cb06dee4f9880ef014db7e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 09:26:33 +0100 Subject: [PATCH 4/9] test: #8162 fix clientList spec --- test/cypress/integration/client/clientList.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index b3ac9d3df..37983cc70 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -15,7 +15,7 @@ describe('Client list', () => { }); }); - it.only('Client list create new client', () => { + it('Client list create new client', () => { cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); const data = { Name: { val: 'Name 1' }, From e10ee5e6c77d4dceff48d9eaf0e97a7694461adb Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 09:26:40 +0100 Subject: [PATCH 5/9] test: #8162 fix vnLocation spec --- test/cypress/integration/vnComponent/vnLocation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 70c88b26f..70a943688 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -107,7 +107,7 @@ describe('VnLocation', () => { cy.get(inputLocation).should('have.value', postCodeLabel); }); - it('Create postCode', () => { + it.only('Create postCode', () => { const postCode = '1234475'; const province = 'Valencia'; cy.get(createLocationButton).click(); From 226f604f9d1f27b2a9bc9b6bc92cd1a72ee12c50 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 09:37:47 +0100 Subject: [PATCH 6/9] test: #8162 fix vnLocation spec --- test/cypress/integration/vnComponent/vnLocation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 70a943688..70c88b26f 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -107,7 +107,7 @@ describe('VnLocation', () => { cy.get(inputLocation).should('have.value', postCodeLabel); }); - it.only('Create postCode', () => { + it('Create postCode', () => { const postCode = '1234475'; const province = 'Valencia'; cy.get(createLocationButton).click(); From 9da04881841c5fc269f7fdeab4ed8f7f91790f0b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 10:03:23 +0100 Subject: [PATCH 7/9] feat: remove comments --- test/cypress/integration/client/clientList.spec.js | 9 --------- .../integration/vnComponent/vnLocation.spec.js | 13 ------------- test/cypress/support/commands.js | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index 37983cc70..431ac0548 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -56,11 +56,6 @@ describe('Client list', () => { cy.waitForElement('.q-form'); cy.checkValueSelectForm(1, search); 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', () => { const search = 'Jessica Jones'; @@ -70,9 +65,5 @@ describe('Client list', () => { cy.waitForElement('.q-form'); cy.checkValueForm(1, search); 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 70c88b26f..ef08af679 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -19,26 +19,17 @@ describe('VnLocation', () => { cy.get(createLocationButton).click(); }); it('should filter provinces based on selected country', () => { - // Select a country cy.selectOption(countrySelector, 'Ecuador'); - // Verify that provinces are filtered cy.get(countrySelector).should('have.length', 1); - - // Verify that towns are filtered cy.get(citySelector).should('have.length', 1); }); it('should filter towns based on selected province', () => { - // Select a country cy.selectOption(countrySelector, 'Ecuador'); - // Verify that provinces are filtered cy.get(provinceSelector).should('have.length', 1); - - // Verify that towns are filtered cy.get(citySelector).should('have.length', 1); }); it('should pass selected country', () => { - // Select a country const country = 'Ecuador'; const province = 'Province five'; @@ -67,13 +58,11 @@ describe('VnLocation', () => { cy.get(locationOptions).should('have.length.at.least', 5); }); it('input filter location as "al"', function () { - // cy.get(inputLocation).click(); cy.get(inputLocation).clear(); cy.get(inputLocation).type('al'); cy.get(locationOptions).should('have.length.at.least', 4); }); it('input filter location as "ecuador"', function () { - // cy.get(inputLocation).click(); cy.get(inputLocation).clear(); cy.get(inputLocation).type('ecuador'); cy.get(locationOptions).should('have.length.at.least', 1); @@ -129,7 +118,6 @@ describe('VnLocation', () => { const province = 'Saskatchew'; cy.get(createLocationButton).click(); cy.get(dialogInputs).eq(0).type(postCode); - // city create button cy.get( `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon` ).click(); @@ -138,7 +126,6 @@ describe('VnLocation', () => { cy.get('#q-portal--dialog--3 .q-btn--standard').click(); cy.get('#q-portal--dialog--1 .q-btn--standard').click(); cy.waitForElement('.q-form'); - checkVnLocation(postCode, province); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index d4b2486e7..add41db57 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -294,7 +294,7 @@ 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` From deb6467af8ed5072dc714cc459ca036b3803302e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 10:05:10 +0100 Subject: [PATCH 8/9] feat: remove comments --- test/cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index add41db57..1765b9043 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -297,7 +297,7 @@ Cypress.Commands.add('checkNotification', (text) => { 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); }); From d6aedad38e49ee64b2a6b2f49a107b3b5975a67d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Nov 2024 10:07:03 +0100 Subject: [PATCH 9/9] perf: use const in VnLocation --- test/cypress/integration/vnComponent/vnLocation.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index ef08af679..aeb938c6f 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -19,13 +19,15 @@ describe('VnLocation', () => { cy.get(createLocationButton).click(); }); it('should filter provinces based on selected country', () => { - cy.selectOption(countrySelector, 'Ecuador'); + const country = 'Ecuador'; + cy.selectOption(countrySelector, country); cy.get(countrySelector).should('have.length', 1); cy.get(citySelector).should('have.length', 1); }); it('should filter towns based on selected province', () => { - cy.selectOption(countrySelector, 'Ecuador'); + const country = 'Ecuador'; + cy.selectOption(countrySelector, country); cy.get(provinceSelector).should('have.length', 1); cy.get(citySelector).should('have.length', 1); });