diff --git a/test/cypress/integration/vnComponent/vnLocation.spec.js b/test/cypress/integration/vnComponent/vnLocation.spec.js index 1872d3591..88919e41c 100644 --- a/test/cypress/integration/vnComponent/vnLocation.spec.js +++ b/test/cypress/integration/vnComponent/vnLocation.spec.js @@ -3,25 +3,71 @@ describe('VnLocation', () => { const dialogInputs = '.q-dialog label input'; const createLocationButton = '.q-form > .q-card > .vn-row:nth-child(6) .--add-icon'; const inputLocation = '.q-form input[aria-label="Location"]'; + const createForm = { + prefix: '.q-dialog__inner > .column > #formModel > .q-card', + sufix: ' .q-field__inner > .q-field__control', + }; + describe('CreateFormDialog ', () => { + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('developer'); + cy.visit('/#/supplier/567/fiscal-data', { timeout: 7000 }); + cy.waitForElement('.q-card'); + cy.get(createLocationButton).click(); + }); + it('should filter provinces based on selected country', () => { + // Select a country + cy.selectOption( + `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`, + 'Ecuador' + ); + // Verify that provinces are filtered + cy.get( + `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}` + ).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); + }); + + 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' + ); + // Verify that provinces are filtered + cy.get( + `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(3)> ${createForm.sufix}` + ).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); + }); + }); describe('Worker Create', () => { beforeEach(() => { cy.viewport(1280, 720); cy.login('developer'); cy.visit('/#/worker/create', { timeout: 5000 }); cy.waitForElement('.q-card'); + cy.get(inputLocation).click(); }); it('Show all options', function () { - cy.get(inputLocation).click(); cy.get(locationOptions).should('have.length.at.least', 5); }); it('input filter location as "al"', function () { - cy.get(inputLocation).click(); + // 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).click(); cy.get(inputLocation).clear(); cy.get(inputLocation).type('ecuador'); cy.get(locationOptions).should('have.length.at.least', 1); @@ -63,13 +109,11 @@ describe('VnLocation', () => { cy.get(dialogInputs).eq(0).clear(); cy.get(dialogInputs).eq(0).type(postCode); cy.selectOption( - '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > .q-select > .q-field__inner > .q-field__control ', + `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, province ); cy.get('.q-mt-lg > .q-btn--standard').click(); - cy.get('.q-dialog__inner > .column > #formModel > .q-card').should( - 'not.exist' - ); + cy.get(`${createForm.prefix}`).should('not.exist'); checkVnLocation(postCode, province); }); it('Create city', () => { @@ -79,7 +123,7 @@ describe('VnLocation', () => { cy.get(dialogInputs).eq(0).type(postCode); // city create button cy.get( - '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > .q-select > .q-field__inner > .q-field__control > :nth-child(2) > .q-icon' + `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) > .q-icon` ).click(); cy.selectOption('#q-portal--dialog--2 .q-select', 'one'); cy.get('#q-portal--dialog--2 .q-input').type(province); @@ -89,9 +133,7 @@ describe('VnLocation', () => { }); function checkVnLocation(postCode, province) { - cy.get('.q-dialog__inner > .column > #formModel > .q-card').should( - 'not.exist' - ); + cy.get(`${createForm.prefix}`).should('not.exist'); cy.get('.q-form > .q-card > .vn-row:nth-child(6)') .find('input') .invoke('val')