test: refs #8315 fix VnSelect in e2e
gitea/salix-front/pipeline/pr-test This commit looks good Details

This commit is contained in:
Alex Moreno 2024-12-18 11:22:04 +01:00
parent 50262003d0
commit 17527cb4e7
11 changed files with 72 additions and 41 deletions

View File

@ -343,6 +343,7 @@ function handleKeyDown(event) {
@virtual-scroll="onScroll" @virtual-scroll="onScroll"
@keydown="handleKeyDown" @keydown="handleKeyDown"
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'" :data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
:data-url="url"
> >
<template #append> <template #append>
<QIcon <QIcon

View File

@ -98,6 +98,7 @@ function cancel() {
/> />
<QBtn <QBtn
:label="t('globals.confirm')" :label="t('globals.confirm')"
:title="t('globals.confirm')"
color="primary" color="primary"
:loading="isLoading" :loading="isLoading"
@click="confirm()" @click="confirm()"

View File

@ -30,7 +30,6 @@ const warehousesOptions = ref([]);
> >
<template #form-inputs> <template #form-inputs>
<VnRow> <VnRow>
<div class="col">
<VnSelect <VnSelect
:label="t('list.warehouse')" :label="t('list.warehouse')"
v-model="ZoneWarehouseFormData.warehouseFk" v-model="ZoneWarehouseFormData.warehouseFk"
@ -40,7 +39,6 @@ const warehousesOptions = ref([]);
hide-selected hide-selected
:required="true" :required="true"
/> />
</div>
</VnRow> </VnRow>
</template> </template>
</FormPopup> </FormPopup>

View File

@ -16,7 +16,7 @@ describe('Client list', () => {
}); });
it('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(); cy.addBtnClick();
const randomInt = Math.floor(Math.random() * 90) + 10; const randomInt = Math.floor(Math.random() * 90) + 10;
const data = { const data = {
@ -27,7 +27,7 @@ describe('Client list', () => {
Street: { val: `C/ STREET ${randomInt}` }, Street: { val: `C/ STREET ${randomInt}` },
Email: { val: `user.test${randomInt}@cypress.com` }, Email: { val: `user.test${randomInt}@cypress.com` },
'Sales person': { val: 'salesPerson', type: 'select' }, 'Sales person': { val: 'salesPerson', type: 'select' },
Location: { val: '46000, Valencia(Province one), España', type: 'select' }, Location: { val: '46000', type: 'select' },
'Business type': { val: 'Otros', type: 'select' }, 'Business type': { val: 'Otros', type: 'select' },
}; };
cy.fillInForm(data); cy.fillInForm(data);

View File

@ -11,7 +11,7 @@ describe('EntryStockBought', () => {
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get('.q-notification__message').should('have.text', 'Data saved');
}); });
it('Should add a new reserved space for buyerBoss', () => { it('Should add a new reserved space for buyerBoss', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.get('input[aria-label="Reserve"]').type('1'); cy.get('input[aria-label="Reserve"]').type('1');
cy.get('input[aria-label="Date"]').eq(1).clear(); cy.get('input[aria-label="Date"]').eq(1).clear();
cy.get('input[aria-label="Date"]').eq(1).type('01-01'); cy.get('input[aria-label="Date"]').eq(1).type('01-01');

View File

@ -19,7 +19,7 @@ describe('Handle Items FixedPrice', () => {
cy.selectOption('.list > :nth-child(2)', 'Alstroemeria'); cy.selectOption('.list > :nth-child(2)', 'Alstroemeria');
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click(); cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.selectOption(`${firstRow} > :nth-child(2)`, '#13'); cy.selectOption(`${firstRow} > :nth-child(2)`, '#13');
cy.get(`${firstRow} > :nth-child(4)`).find('input').type(1); cy.get(`${firstRow} > :nth-child(4)`).find('input').type(1);
cy.get(`${firstRow} > :nth-child(5)`).find('input').type('2'); cy.get(`${firstRow} > :nth-child(5)`).find('input').type('2');
@ -29,7 +29,7 @@ describe('Handle Items FixedPrice', () => {
}); });
it('Create and delete ', function () { it('Create and delete ', function () {
cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click(); cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click();
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.selectOption(`${firstRow} > :nth-child(2)`, '#11'); cy.selectOption(`${firstRow} > :nth-child(2)`, '#11');
cy.get(`${firstRow} > :nth-child(4)`).type('1'); cy.get(`${firstRow} > :nth-child(4)`).type('1');
cy.get(`${firstRow} > :nth-child(5)`).type('2'); cy.get(`${firstRow} > :nth-child(5)`).type('2');

View File

@ -5,7 +5,7 @@ describe('RoadMap', () => {
cy.visit(`/#/route/roadmap`); cy.visit(`/#/route/roadmap`);
}); });
it('Route list create roadmap and redirect', () => { it('Route list create roadmap and redirect', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.get('input[name="name"]').eq(1).type('roadMapTestOne{enter}'); cy.get('input[name="name"]').eq(1).type('roadMapTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created'); cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary'); cy.url().should('include', '/summary');

View File

@ -9,7 +9,7 @@ describe('Route', () => {
const getRowColumn = (row, column) => `:nth-child(${row}) > :nth-child(${column})`; const getRowColumn = (row, column) => `:nth-child(${row}) > :nth-child(${column})`;
it('Route list create route', () => { it('Route list create route', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.get('input[name="description"]').type('routeTestOne{enter}'); cy.get('input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created'); cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary'); cy.url().should('include', '/summary');

View File

@ -7,7 +7,7 @@ describe('WorkerPda', () => {
}); });
it('assign pda', () => { it('assign pda', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.get(select).click(); cy.get(select).click();
cy.get(select).type('{downArrow}{enter}'); cy.get(select).type('{downArrow}{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created'); cy.get('.q-notification__message').should('have.text', 'Data created');

View File

@ -1,10 +1,10 @@
describe('ZoneWarehouse', () => { describe('ZoneWarehouse', () => {
const data = { const data = {
Warehouse: { val: 'Algemesi', type: 'select' }, Warehouse: { val: 'Warehouse One', type: 'select' },
}; };
const deviceProductionField =
'.vn-row > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container'; const dataError = 'ER_DUP_ENTRY: Duplicate entry';
const dataError = "ER_DUP_ENTRY: Duplicate entry '2-2' for key 'zoneFk'"; const saveBtn = '.q-btn--standard > .q-btn__content > .block';
beforeEach(() => { beforeEach(() => {
cy.viewport(1280, 720); cy.viewport(1280, 720);
@ -13,22 +13,21 @@ describe('ZoneWarehouse', () => {
}); });
it('should throw an error if the warehouse chosen is already put in the zone', () => { it('should throw an error if the warehouse chosen is already put in the zone', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.get(deviceProductionField).click(); cy.selectOption('[data-cy="Warehouse_select"]', 'Warehouse Two');
cy.get(deviceProductionField).type('{upArrow}{enter}'); cy.get(saveBtn).click();
cy.get('.q-notification__message').should('have.text', dataError); cy.checkNotification(dataError);
}); });
it('should create a warehouse', () => { it('should create & remove a warehouse', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick();
cy.get(deviceProductionField).click();
cy.fillInForm(data); cy.fillInForm(data);
cy.get(saveBtn).click();
cy.get('.q-mt-lg > .q-btn--standard').click(); cy.get('.q-mt-lg > .q-btn--standard').click();
});
it('should delete a warehouse', () => {
cy.get('tbody > :nth-child(2) > :nth-child(2) > .q-icon').click(); cy.get('tbody > :nth-child(2) > :nth-child(2) > .q-icon').click();
cy.get('.q-card__actions > .q-btn--flat > .q-btn__content').click(); cy.get('[title="Confirm"]').click();
cy.reload(); cy.reload();
}); });
}); });

View File

@ -58,8 +58,9 @@ Cypress.Commands.add('domContentLoad', (element, timeout = 5000) => {
cy.waitUntil(() => cy.document().then((doc) => doc.readyState === 'complete')); cy.waitUntil(() => cy.document().then((doc) => doc.readyState === 'complete'));
}); });
Cypress.Commands.add('waitForElement', (element, timeout = 5000) => { Cypress.Commands.add('waitForElement', (element, timeout = 5000) => {
cy.waitUntil(() => cy.get(element).then(($el) => $el.is(':visible'))); cy.get(element, { timeout }).should('be.visible').and('not.be.disabled');
}); });
Cypress.Commands.add('getValue', (selector) => { Cypress.Commands.add('getValue', (selector) => {
cy.get(selector).then(($el) => { cy.get(selector).then(($el) => {
if ($el.find('.q-checkbox__inner').length > 0) { if ($el.find('.q-checkbox__inner').length > 0) {
@ -86,15 +87,40 @@ Cypress.Commands.add('getValue', (selector) => {
}); });
// Fill Inputs // Fill Inputs
Cypress.Commands.add('selectOption', (selector, option, timeout) => { Cypress.Commands.add('selectOption', (selector, option, timeout = 5000) => {
cy.waitForElement(selector); cy.waitForElement(selector, timeout);
cy.get(selector).click(); cy.get(selector).click();
cy.wait(timeout || 1000); cy.get(selector).invoke('data', 'url').as('dataUrl');
cy.get('.q-menu .q-item').contains(option).click(); cy.get(selector)
.clear()
.type(option)
.then(() => {
cy.get('.q-menu', { timeout })
.should('be.visible') // Asegurarse de que el menú está visible
.and('exist') // Verificar que el menú existe
.then(() => {
cy.get('@dataUrl').then((url) => {
if (url) {
cy.log('url: ', url);
// Esperar a que el menú no esté visible (desaparezca)
cy.get('.q-menu').should('not.be.visible');
// Ahora esperar a que el menú vuelva a aparecer
cy.get('.q-menu').should('be.visible').and('exist');
}
});
});
});
// Finalmente, seleccionar la opción deseada
cy.get('.q-menu:visible') // Asegurarse de que estamos dentro del menú visible
.find('.q-item') // Encontrar los elementos de las opciones
.contains(option) // Verificar que existe una opción que contenga el texto deseado
.click(); // Hacer clic en la opción
}); });
Cypress.Commands.add('countSelectOptions', (selector, option) => { Cypress.Commands.add('countSelectOptions', (selector, option) => {
cy.waitForElement(selector); cy.waitForElement(selector);
cy.get(selector).click(); cy.get(selector).click({ force: true });
cy.get('.q-menu .q-item').should('have.length', option); cy.get('.q-menu .q-item').should('have.length', option);
}); });
@ -110,8 +136,7 @@ Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
const { type, val } = field; const { type, val } = field;
switch (type) { switch (type) {
case 'select': case 'select':
cy.get(el).click(); cy.selectOption(el, val);
cy.get('.q-menu .q-item').contains(val).click();
break; break;
case 'date': case 'date':
cy.get(el).type(val.split('-').join('')); cy.get(el).type(val.split('-').join(''));
@ -347,3 +372,10 @@ Cypress.Commands.add('searchByLabel', (label, value) => {
Cypress.Commands.add('dataCy', (tag, attr = 'data-cy') => { Cypress.Commands.add('dataCy', (tag, attr = 'data-cy') => {
return cy.get(`[${attr}="${tag}"]`); return cy.get(`[${attr}="${tag}"]`);
}); });
Cypress.Commands.add('addBtnClick', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon')
.should('exist')
.and('be.visible')
.click();
});