From 95758e2564ed49074ac7ff4be2cea28bf0b60d74 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 17 Nov 2024 14:25:23 +0100 Subject: [PATCH] test: refs #8061 #8061 CreateNewPostcodeForm --- .../vnComponent/vnLocation.spec.js | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index d3c750a11..207f5d634 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,28 @@ describe('VnLocation', () => { }); it('should filter provinces based on selected country', () => { // Select a country - cy.selectOption( - `${createForm.prefix} > :nth-child(5) > :nth-child(3) > ${createForm.sufix}`, - 'Ecuador' - ); + cy.selectOption(countrySelector, 'Ecuador'); // Verify that provinces are filtered - cy.get( - `${createForm.prefix} > :nth-child(5) > :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) > :nth-child(2) > ${createForm.sufix}` - ).should('have.length', 1); + cy.get(citySelector).should('have.length', 1); }); it.only('should filter towns based on selected province', () => { // Select a country - cy.selectOption( - `${createForm.prefix} > :nth-child(5) > :nth-child(3) > ${createForm.sufix}`, - 'Ecuador' - ); + cy.selectOption(countrySelector, 'Ecuador'); // Verify that provinces are filtered - cy.get( - `${createForm.prefix} > :nth-child(5) > :nth-child(2) > ${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) > :nth-child(2) > ${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) > :nth-child(3) > ${createForm.sufix}`, - country - ); + cy.selectOption(countrySelector, country); cy.selectOption( `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, province