refactor: refs #8441 add data-cy attributes for summary buttons and improve tests for vehicle invoice
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jose Antonio Tubau 2025-03-14 12:45:02 +01:00
parent b8be248af9
commit 512611a309
5 changed files with 44 additions and 40 deletions

View File

@ -180,6 +180,7 @@ const toModule = computed(() => {
color="white" color="white"
class="link" class="link"
v-if="summary" v-if="summary"
data-cy="openSummaryBtn"
> >
<QTooltip> <QTooltip>
{{ t('components.smartCard.openSummary') }} {{ t('components.smartCard.openSummary') }}
@ -194,6 +195,7 @@ const toModule = computed(() => {
icon="launch" icon="launch"
round round
size="md" size="md"
data-cy="goToSummaryBtn"
> >
<QTooltip> <QTooltip>
{{ t('components.cardDescriptor.summary') }} {{ t('components.cardDescriptor.summary') }}

View File

@ -81,6 +81,7 @@ async function fetch() {
name: `${moduleName ?? route.meta.moduleName}Summary`, name: `${moduleName ?? route.meta.moduleName}Summary`,
params: { id: entityId || entity.id }, params: { id: entityId || entity.id },
}" }"
data-cy="goToSummaryBtn"
> >
<QIcon name="open_in_new" color="white" size="sm" /> <QIcon name="open_in_new" color="white" size="sm" />
</router-link> </router-link>

View File

@ -95,9 +95,10 @@ async function unassignInvoice(id) {
:data-key="dataKey" :data-key="dataKey"
:url="`vehicles/${route.params.id}/getInvoices`" :url="`vehicles/${route.params.id}/getInvoices`"
:columns="columns" :columns="columns"
search-url="vehicleInvoiceIns"
:order="['issued DESC', 'supplierRef ASC']" :order="['issued DESC', 'supplierRef ASC']"
:create="{ :create="{
urlCreate: 'VehicleInvoiceIns/assignInvoice', urlCreate: 'VehicleInvoiceIns',
title: t('vehicle.ticket.assignInvoice'), title: t('vehicle.ticket.assignInvoice'),
formInitialData: { formInitialData: {
vehicleFk: parseInt(route.params.id, 10), vehicleFk: parseInt(route.params.id, 10),
@ -128,14 +129,6 @@ async function unassignInvoice(id) {
option-label="supplierRef" option-label="supplierRef"
:required="true" :required="true"
> >
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.supplierRef }}</QItemLabel>
<QItemLabel caption>{{ `#${scope.opt?.id}` }}</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect> </VnSelect>
<VnInputNumber <VnInputNumber
:label="t('invoiceIn.list.amount')" :label="t('invoiceIn.list.amount')"

View File

@ -1,19 +1,23 @@
const { get } = require('cypress/types/lodash');
describe('Vehicle Invoice In', () => { describe('Vehicle Invoice In', () => {
const getSelector = (colField) =>
`tr:first-child > [data-col-field="${colField}"] > .no-padding > .link`;
const selectors = { const selectors = {
firstRowSupplier: 'tr:first-child > .expand > .no-padding > .link', firstRowSupplier: getSelector('supplierFk'),
firstRowInvoice: firstRowInvoice: getSelector('supplierRef'),
':nth-child(1) > [data-col-field="supplierRef"] > .no-padding > .link', descriptorTitle: '.descriptor .title',
descriptorTitle: summaryTitle: '.summaryHeader',
'.q-menu > .descriptor > .body > .q-list > .q-item__label--header > .title > span', descriptorOpenSummaryBtn: '.descriptor [data-cy="openSummaryBtn"]',
descriptorPopupGoToSummaryBtn: descriptorGoToSummaryBtn: '.descriptor [data-cy="goToSummaryBtn"]',
'.header > :nth-child(2) > .q-btn__content > .q-icon', SummaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
summaryTitle: '.summaryHeader > :nth-child(2)',
summaryPopUpGoToSummaryBtn: '.header > .q-icon',
unassignBtn: 'tableAction-0', unassignBtn: 'tableAction-0',
}; };
const supplier = 'PLANTS SL'; const data = {
const invoice = '1234'; supplier: 'PLANTS SL',
invoice: '1234',
};
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
@ -48,40 +52,36 @@ describe('Vehicle Invoice In', () => {
describe('Supplier pop-ups', () => { describe('Supplier pop-ups', () => {
it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => { it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => {
cy.get(selectors.firstRowSupplier).click(); cy.get(selectors.firstRowSupplier).click();
cy.get(selectors.descriptorTitle).should('contain', supplier); cy.containContent(selectors.descriptorTitle, data.supplier);
cy.get( cy.get(selectors.descriptorGoToSummaryBtn).click();
'[href="#/supplier/1/summary"] > .q-btn > .q-btn__content > .q-icon', cy.containContent(selectors.summaryTitle, data.supplier);
).click();
cy.get(selectors.summaryTitle).should('contain', supplier);
}); });
it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => { it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => {
cy.get(selectors.firstRowSupplier).click(); cy.get(selectors.firstRowSupplier).click();
cy.get(selectors.descriptorTitle).should('contain', supplier); cy.containContent(selectors.descriptorTitle, data.supplier);
cy.get(selectors.descriptorPopupGoToSummaryBtn).click(); cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.get(selectors.summaryTitle).should('contain', supplier); cy.containContent(selectors.summaryTitle, data.supplier);
cy.get(selectors.summaryPopUpGoToSummaryBtn).click(); cy.get(selectors.SummaryGoToSummaryBtn).click();
cy.get(selectors.summaryTitle).should('contain', supplier); cy.containContent(selectors.summaryTitle, data.supplier);
}); });
}); });
describe('Invoice pop-ups', () => { describe('Invoice pop-ups', () => {
it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => { it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => {
cy.get(selectors.firstRowInvoice).click(); cy.get(selectors.firstRowInvoice).click();
cy.get(selectors.descriptorTitle).should('have.text', invoice); cy.containContent(selectors.descriptorTitle, data.invoice);
cy.get( cy.get(selectors.descriptorGoToSummaryBtn).click();
'[href="#/invoice-in/1/summary"] > .q-btn > .q-btn__content > .q-icon', cy.containContent(selectors.summaryTitle, data.supplier);
).click();
cy.get(selectors.summaryTitle).should('contain', supplier);
}); });
it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => { it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => {
cy.get(selectors.firstRowInvoice).click(); cy.get(selectors.firstRowInvoice).click();
cy.get(selectors.descriptorTitle).should('have.text', invoice); cy.containContent(selectors.descriptorTitle, data.invoice);
cy.get(selectors.descriptorPopupGoToSummaryBtn).click(); cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.get(selectors.summaryTitle).should('contain', supplier); cy.containContent(selectors.summaryTitle, data.supplier);
cy.get(selectors.summaryPopUpGoToSummaryBtn).click(); cy.get(selectors.SummaryGoToSummaryBtn).click();
cy.get(selectors.summaryTitle).should('contain', supplier); cy.containContent(selectors.summaryTitle, data.supplier);
}); });
}); });
}); });

View File

@ -317,6 +317,14 @@ Cypress.Commands.add('validateContent', (selector, expectedValue) => {
cy.get(selector).should('have.text', expectedValue); cy.get(selector).should('have.text', expectedValue);
}); });
Cypress.Commands.add('containContent', (selector, expectedValue) => {
cy.get(selector)
.invoke('text')
.then((text) => {
expect(text).to.include(expectedValue);
});
});
Cypress.Commands.add('openActionDescriptor', (opt) => { Cypress.Commands.add('openActionDescriptor', (opt) => {
cy.openActionsDescriptor(); cy.openActionsDescriptor();
const listItem = '[role="menu"] .q-list .q-item'; const listItem = '[role="menu"] .q-list .q-item';