feat: refs #8463 update data-cy attributes in VnDescriptor for improved testing and consistency
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Alex Moreno 2025-03-23 09:27:55 +01:00
parent 8bdd581764
commit 944a70be47
2 changed files with 25 additions and 13 deletions

View File

@ -106,7 +106,7 @@ const toModule = computed(() => {
</script> </script>
<template> <template>
<div class="descriptor"> <div class="descriptor" data-cy="vnDescriptor">
<template v-if="entity && entity?.id"> <template v-if="entity && entity?.id">
<div class="header bg-primary q-pa-sm justify-between"> <div class="header bg-primary q-pa-sm justify-between">
<slot name="header-extra-action"> <slot name="header-extra-action">
@ -153,7 +153,7 @@ const toModule = computed(() => {
data-cy="goToSummaryBtn" data-cy="goToSummaryBtn"
> >
<QTooltip> <QTooltip>
{{ t('components.cardDescriptor.summary') }} {{ t('components.vnDescriptor.summary') }}
</QTooltip> </QTooltip>
</QBtn> </QBtn>
</RouterLink> </RouterLink>
@ -168,18 +168,27 @@ const toModule = computed(() => {
<QList dense> <QList dense>
<QItemLabel header class="ellipsis text-h5" :lines="1"> <QItemLabel header class="ellipsis text-h5" :lines="1">
<div class="title"> <div class="title">
<span v-if="title" :title="getValueFromPath(title)"> <span
v-if="title"
:title="getValueFromPath(title)"
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_title`"
>
{{ getValueFromPath(title) ?? title }} {{ getValueFromPath(title) ?? title }}
</span> </span>
<slot v-else name="description" :entity="entity"> <slot v-else name="description" :entity="entity">
<span :title="entity.name"> <span
{{ entity.name }} :title="entity.name"
</span> :data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_description`"
v-text="entity.name"
/>
</slot> </slot>
</div> </div>
</QItemLabel> </QItemLabel>
<QItem> <QItem>
<QItemLabel class="subtitle"> <QItemLabel
class="subtitle"
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_subtitle`"
>
#{{ getValueFromPath(subtitle) ?? entity.id }} #{{ getValueFromPath(subtitle) ?? entity.id }}
</QItemLabel> </QItemLabel>
<QBtn <QBtn
@ -197,7 +206,10 @@ const toModule = computed(() => {
</QBtn> </QBtn>
</QItem> </QItem>
</QList> </QList>
<div class="list-box q-mt-xs"> <div
class="list-box q-mt-xs"
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_listbox`"
>
<slot name="body" :entity="entity" /> <slot name="body" :entity="entity" />
</div> </div>
</div> </div>

View File

@ -371,7 +371,7 @@ Cypress.Commands.add('validateContent', (selector, expectedValue) => {
}); });
Cypress.Commands.add('openActionsDescriptor', () => { Cypress.Commands.add('openActionsDescriptor', () => {
cy.get('[data-cy="cardDescriptor"] [data-cy="descriptor-more-opts"]').click(); cy.get('[data-cy="vnDescriptor"] [data-cy="descriptor-more-opts"]').click();
}); });
Cypress.Commands.add('openUserPanel', () => { Cypress.Commands.add('openUserPanel', () => {
@ -466,16 +466,16 @@ Cypress.Commands.add('validateDescriptor', (toCheck = {}) => {
const popupSelector = popup ? '[role="menu"] ' : ''; const popupSelector = popup ? '[role="menu"] ' : '';
if (title) cy.get(`${popupSelector}[data-cy="cardDescriptor_title"]`).contains(title); if (title) cy.get(`${popupSelector}[data-cy="vnDescriptor_title"]`).contains(title);
if (description) if (description)
cy.get(`${popupSelector}[data-cy="cardDescriptor_description"]`).contains( cy.get(`${popupSelector}[data-cy="vnDescriptor_description"]`).contains(
description, description,
); );
if (subtitle) if (subtitle)
cy.get(`${popupSelector}[data-cy="cardDescriptor_subtitle"]`).contains(subtitle); cy.get(`${popupSelector}[data-cy="vnDescriptor_subtitle"]`).contains(subtitle);
for (const index in listbox) for (const index in listbox)
cy.get(`${popupSelector}[data-cy="cardDescriptor_listbox"] > *`) cy.get(`${popupSelector}[data-cy="vnDescriptor_listbox"] > *`)
.eq(index) .eq(index)
.should('contain.text', listbox[index]); .should('contain.text', listbox[index]);
}); });