feat: enhance item tags with data attributes for improved testing
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Pablo Natek 2025-02-23 12:57:57 +01:00
parent 8c69e5c937
commit 24b4d0071a
2 changed files with 27 additions and 20 deletions

View File

@ -87,7 +87,7 @@ const insertTag = (rows) => {
tagFk: undefined,
}"
:default-remove="false"
:filter="{
:user-filter="{
fields: ['id', 'itemFk', 'tagFk', 'value', 'priority'],
where: { itemFk: route.params.id },
include: {
@ -119,6 +119,7 @@ const insertTag = (rows) => {
"
:required="true"
:rules="validate('itemTag.tagFk')"
:data-cy="`tag${row?.tag?.name}`"
/>
<VnSelect
v-if="row.tag?.isFree === false"
@ -145,6 +146,7 @@ const insertTag = (rows) => {
:label="t('itemTags.value')"
:is-clearable="false"
@keyup.enter.stop="(data) => itemTagsRef.onSubmit(data)"
:data-cy="`tag${row?.tag?.name}Value`"
/>
<VnInput
:label="t('itemBasicData.relevancy')"
@ -162,6 +164,7 @@ const insertTag = (rows) => {
name="delete"
size="sm"
dense
:data-cy="`deleteTag${row?.tag?.name}`"
>
<QTooltip>
{{ t('itemTags.removeTag') }}
@ -177,6 +180,7 @@ const insertTag = (rows) => {
icon="add"
shortcut="+"
fab
data-cy="createNewTag"
>
<QTooltip>
{{ t('itemTags.addTag') }}

View File

@ -1,33 +1,36 @@
/// <reference types="cypress" />
describe('Item tag', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/item/1/tags`);
cy.get('.q-page').should('be.visible');
cy.waitForElement('[data-cy="itemTags"]');
});
const createNewTag = 'createNewTag';
const saveBtn = 'crudModelDefaultSaveBtn';
const newTag = 'tagundefined';
it('should throw an error adding an existent tag', () => {
cy.get('.q-page').should('be.visible');
cy.get('.q-page-sticky > div').click();
cy.get('.q-page-sticky > div').click();
cy.dataCy('Tag_select').eq(7).type('Tallos');
cy.get('.q-menu .q-item').contains('Tallos').click();
cy.get(':nth-child(8) > [label="Value"]').type('1');
+cy.dataCy('crudModelDefaultSaveBtn').click();
cy.checkNotification("The tag or priority can't be repeated for an item");
cy.dataCy(createNewTag).click();
cy.dataCy(newTag).should('be.visible').click().type('Genero{enter}');
cy.dataCy('tagGeneroValue').eq(1).should('be.visible');
cy.dataCy(saveBtn).click();
cy.get('.q-notification__message').should(
'have.text',
"The tag or priority can't be repeated for an item",
);
});
it('should add a new tag', () => {
cy.get('.q-page').should('be.visible');
cy.get('.q-page-sticky > div').click();
cy.get('.q-page-sticky > div').click();
cy.dataCy('Tag_select').eq(7).click();
cy.get('.q-menu .q-item').contains('Ancho de la base').type('{enter}');
cy.get(':nth-child(8) > [label="Value"]').type('50');
cy.dataCy('crudModelDefaultSaveBtn').click();
cy.dataCy(createNewTag).click();
cy.dataCy(newTag).should('be.visible').click().type('Forma{enter}');
cy.dataCy('tagFormaValue').should('be.visible').type('50');
cy.dataCy(saveBtn).click();
cy.checkNotification('Data saved');
cy.dataCy('itemTags').children(':nth-child(8)').find('.justify-center > .q-icon').click();
cy.dataCy('VnConfirm_confirm').click();
cy.dataCy('deleteTagForma').should('be.visible').click();
cy.dataCy('VnConfirm_confirm').should('be.visible').click();
cy.checkNotification('Data saved');
});
});
});