test: add better test to vnLocation
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Alex Moreno 2024-07-30 10:01:16 +02:00
parent 9179e13dcd
commit f4347411ab
1 changed files with 57 additions and 41 deletions

View File

@ -4,28 +4,28 @@ describe('VnLocation', () => {
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"]';
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');
// }); });
// it('Show all options', function () { it('Show all options', function () {
// cy.get(inputLocation).click(); 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', 3); cy.get(locationOptions).should('have.length.at.least', 3);
// }); });
// 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);
// }); });
}); });
describe('Fiscal-data', () => { describe('Fiscal-data', () => {
beforeEach(() => { beforeEach(() => {
@ -36,31 +36,47 @@ describe('VnLocation', () => {
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
}); });
it('Create postCode', () => { it('Create postCode', () => {
const postCode = '1234453'; const postCode = '1234475';
const province = 'Valencia';
cy.get('.q-card > h1').should('have.text', 'New postcode'); cy.get('.q-card > h1').should('have.text', 'New postcode');
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 ', '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > .q-select > .q-field__inner > .q-field__control ',
'Valencia' province
); );
cy.get('.q-mt-lg > .q-btn--standard').click(); cy.get('.q-mt-lg > .q-btn--standard').click();
cy.get(':nth-child(6) > .q-input input').contains(postCode); cy.get('.q-dialog__inner > .column > #formModel > .q-card').should(
'not.exist'
);
checkVnLocation(postCode, province);
}); });
// it('Create city', () => { it('Create city', () => {
// const postCode = '9011'; const postCode = '9011';
// const province = 'Saskatchewan'; const province = 'Saskatchew';
// 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' '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > .q-select > .q-field__inner > .q-field__control > :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);
// cy.get('#q-portal--dialog--2 .q-btn--standard').click(); cy.get('#q-portal--dialog--2 .q-btn--standard').click();
// cy.get('#q-portal--dialog--1 .q-btn--standard').click(); cy.get('#q-portal--dialog--1 .q-btn--standard').click();
// cy.get(inputLocation).contains(postCode); checkVnLocation(postCode, province);
// cy.get(inputLocation).contains(province); });
// });
function checkVnLocation(postCode, province) {
cy.get('.q-dialog__inner > .column > #formModel > .q-card').should(
'not.exist'
);
cy.get('.q-form > .q-card > .vn-row:nth-child(6)')
.find('input')
.invoke('val')
.then((text) => {
expect(text).to.contain(postCode);
expect(text).to.contain(province);
});
}
}); });
}); });