0
0
Fork 0

test: refs #7679 #7679 improve test

This commit is contained in:
Javier Segarra 2024-09-26 23:39:14 +02:00
parent d2067c633d
commit 6b2e0df9c2
1 changed files with 53 additions and 11 deletions

View File

@ -3,25 +3,71 @@ describe('VnLocation', () => {
const dialogInputs = '.q-dialog label input'; const dialogInputs = '.q-dialog label input';
const createLocationButton = '.q-form > .q-card > .vn-row:nth-child(6) .--add-icon'; const createLocationButton = '.q-form > .q-card > .vn-row:nth-child(6) .--add-icon';
const inputLocation = '.q-form input[aria-label="Location"]'; 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', () => { describe('Worker Create', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1280, 720); cy.viewport(1280, 720);
cy.login('developer'); cy.login('developer');
cy.visit('/#/worker/create', { timeout: 5000 }); cy.visit('/#/worker/create', { timeout: 5000 });
cy.waitForElement('.q-card'); cy.waitForElement('.q-card');
cy.get(inputLocation).click();
}); });
it('Show all options', function () { it('Show all options', function () {
cy.get(inputLocation).click();
cy.get(locationOptions).should('have.length.at.least', 5); cy.get(locationOptions).should('have.length.at.least', 5);
}); });
it('input filter location as "al"', function () { it('input filter location as "al"', function () {
cy.get(inputLocation).click(); // cy.get(inputLocation).click();
cy.get(inputLocation).clear(); cy.get(inputLocation).clear();
cy.get(inputLocation).type('al'); cy.get(inputLocation).type('al');
cy.get(locationOptions).should('have.length.at.least', 4); cy.get(locationOptions).should('have.length.at.least', 4);
}); });
it('input filter location as "ecuador"', function () { it('input filter location as "ecuador"', function () {
cy.get(inputLocation).click(); // cy.get(inputLocation).click();
cy.get(inputLocation).clear(); cy.get(inputLocation).clear();
cy.get(inputLocation).type('ecuador'); cy.get(inputLocation).type('ecuador');
cy.get(locationOptions).should('have.length.at.least', 1); 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).clear();
cy.get(dialogInputs).eq(0).type(postCode); cy.get(dialogInputs).eq(0).type(postCode);
cy.selectOption( 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 province
); );
cy.get('.q-mt-lg > .q-btn--standard').click(); cy.get('.q-mt-lg > .q-btn--standard').click();
cy.get('.q-dialog__inner > .column > #formModel > .q-card').should( cy.get(`${createForm.prefix}`).should('not.exist');
'not.exist'
);
checkVnLocation(postCode, province); checkVnLocation(postCode, province);
}); });
it('Create city', () => { it('Create city', () => {
@ -79,7 +123,7 @@ describe('VnLocation', () => {
cy.get(dialogInputs).eq(0).type(postCode); cy.get(dialogInputs).eq(0).type(postCode);
// city create button // city create button
cy.get( 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(); ).click();
cy.selectOption('#q-portal--dialog--2 .q-select', 'one'); cy.selectOption('#q-portal--dialog--2 .q-select', 'one');
cy.get('#q-portal--dialog--2 .q-input').type(province); cy.get('#q-portal--dialog--2 .q-input').type(province);
@ -89,9 +133,7 @@ describe('VnLocation', () => {
}); });
function checkVnLocation(postCode, province) { function checkVnLocation(postCode, province) {
cy.get('.q-dialog__inner > .column > #formModel > .q-card').should( cy.get(`${createForm.prefix}`).should('not.exist');
'not.exist'
);
cy.get('.q-form > .q-card > .vn-row:nth-child(6)') cy.get('.q-form > .q-card > .vn-row:nth-child(6)')
.find('input') .find('input')
.invoke('val') .invoke('val')