perf: add dataCy
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-12-02 01:25:42 +01:00
parent 007b95a616
commit 21dc47ed74
3 changed files with 12 additions and 22 deletions

View File

@ -40,6 +40,7 @@ const onDataSaved = (...args) => {
url-create="towns" url-create="towns"
model="city" model="city"
@on-data-saved="onDataSaved" @on-data-saved="onDataSaved"
data-cy="newCityForm"
> >
<template #form-inputs="{ data, validate }"> <template #form-inputs="{ data, validate }">
<VnRow> <VnRow>

View File

@ -43,6 +43,7 @@ const isAllowedToCreate = computed(() => {
> >
<template v-if="isAllowedToCreate" #append> <template v-if="isAllowedToCreate" #append>
<QIcon <QIcon
:data-cy="$attrs.dataCy ?? $attrs.label + '_icon'"
@click.stop.prevent="$refs.dialog.show()" @click.stop.prevent="$refs.dialog.show()"
:name="actionIcon" :name="actionIcon"
:size="actionIcon === 'add' ? 'xs' : 'sm'" :size="actionIcon === 'add' ? 'xs' : 'sm'"

View File

@ -116,16 +116,14 @@ describe('VnLocation', () => {
checkVnLocation(postCode, province); checkVnLocation(postCode, province);
}); });
it.only('Create city without country', () => { it('Create city without country', () => {
const postCode = randomNumber(); const postCode = randomNumber();
const province = randomString({ length: 4 }); const province = randomString({ length: 4 });
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
cy.get(dialogInputs).eq(0).type(postCode); cy.get(dialogInputs).eq(0).type(postCode);
cy.get( cy.dataCy('City_icon').click();
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) `
).click();
cy.selectOption('[data-cy="locationProvince"]:last', 'Province one'); cy.selectOption('[data-cy="locationProvince"]:last', 'Province one');
cy.get('[data-cy="cityName"]').type(province); cy.dataCy('cityName').type(province);
cy.dataCy('FormModelPopup_save').eq(1).click(); cy.dataCy('FormModelPopup_save').eq(1).click();
cy.dataCy('FormModelPopup_save').eq(0).click(); cy.dataCy('FormModelPopup_save').eq(0).click();
@ -133,34 +131,28 @@ describe('VnLocation', () => {
checkVnLocation(postCode, province); checkVnLocation(postCode, province);
}); });
it.only('Create city with country', () => { it('Create city with country', () => {
const cityName = 'Saskatchew'.concat(Math.random(1 * 100)); const cityName = 'Saskatchew'.concat(Math.random(1 * 100));
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
cy.selectOption( cy.selectOption(
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `, `${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
'Italia' 'Italia'
); );
cy.get( cy.dataCy('City_icon').click();
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(2) `
).click();
cy.selectOption('[data-cy="locationProvince"]:last', 'Province four'); cy.selectOption('[data-cy="locationProvince"]:last', 'Province four');
cy.countSelectOptions('[data-cy="locationProvince"]:last', 1); cy.countSelectOptions('[data-cy="locationProvince"]:last', 1);
cy.get('[data-cy="cityName"]').type(cityName); cy.dataCy('cityName').type(cityName);
cy.dataCy('FormModelPopup_save').eq(1).click(); cy.dataCy('FormModelPopup_save').eq(1).click();
}); });
it('Create province without country', () => { it('Create province without country', () => {
const provinceName = 'Saskatchew'.concat(Math.random(1 * 100)); const provinceName = 'Saskatchew'.concat(Math.random(1 * 100));
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
cy.get( cy.dataCy('Province_icon').click();
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
)
.eq(0)
.click();
cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one'); cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
cy.countSelectOptions('[data-cy="autonomyProvince"]', 4); cy.countSelectOptions('[data-cy="autonomyProvince"]', 4);
cy.get('[data-cy="provinceName"]').type(provinceName); cy.dataCy('provinceName').type(provinceName);
cy.dataCy('FormModelPopup_save').eq(1).click(); cy.dataCy('FormModelPopup_save').eq(1).click();
}); });
@ -172,16 +164,12 @@ describe('VnLocation', () => {
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `, `${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
'España' 'España'
); );
cy.get( cy.dataCy('Province_icon').click();
`${createForm.prefix} > :nth-child(5) > .q-select > ${createForm.sufix} > :nth-child(2) `
)
.eq(0)
.click();
cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one'); cy.selectOption('[data-cy="autonomyProvince"] ', 'Autonomy one');
cy.countSelectOptions('[data-cy="autonomyProvince"]', 2); cy.countSelectOptions('[data-cy="autonomyProvince"]', 2);
cy.get('[data-cy="provinceName"]').type(provinceName); cy.dataCy('provinceName').type(provinceName);
cy.dataCy('FormModelPopup_save').eq(1).click(); cy.dataCy('FormModelPopup_save').eq(1).click();
}); });