From c50d6d884ec86786ad4831269b76277e348317d6 Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 13 Mar 2025 09:02:41 +0100 Subject: [PATCH] test: refs #8621 add data-cy attributes for summary navigation buttons in CMR list tests --- src/components/ui/VnToSummary.vue | 1 + .../integration/route/cmr/cmrList.spec.js | 77 ++++++++++++++----- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/components/ui/VnToSummary.vue b/src/components/ui/VnToSummary.vue index 305d65e02..853d26230 100644 --- a/src/components/ui/VnToSummary.vue +++ b/src/components/ui/VnToSummary.vue @@ -26,6 +26,7 @@ const id = props.entityId; :to="{ name: routeName, params: { id: id } }" class="header link" :href="url" + data-cy="goToSummaryBtn" > diff --git a/test/cypress/integration/route/cmr/cmrList.spec.js b/test/cypress/integration/route/cmr/cmrList.spec.js index 6bcbfc842..5c71132de 100644 --- a/test/cypress/integration/route/cmr/cmrList.spec.js +++ b/test/cypress/integration/route/cmr/cmrList.spec.js @@ -9,13 +9,12 @@ describe('Cmr list', () => { '.q-virtual-scroll__content > tr:last-child > :nth-child(1) > .q-checkbox', downloadBtn: '#subToolbar > .q-btn', viewCmr: 'tableAction-0', - summaryPopupBtn: '.header > :nth-child(2) > .q-btn__content > .q-icon', - summaryPopupHeader: '.summaryHeader > :nth-child(2)', - summaryHeader: '.summaryHeader', - descriptorId: '.q-item > .q-item__label', - descriptorTitle: '.q-item__label--header > .title > span', - summaryGoToSummaryBtn: '.header > .q-icon', - descriptorGoToSummaryBtn: '.descriptor > .header > a[href] > .q-btn', + descriptorOpenSummaryBtn: '.descriptor [data-cy="openSummaryBtn"]', + summaryTitle: '.summaryHeader', + descriptorId: '.descriptor .subtitle', + descriptorTitle: '.descriptor .title', + summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]', + descriptorGoToSummaryBtn: '.descriptor [data-cy="goToSummaryBtn"]', removeFilter: '.q-chip__icon--remove', }; @@ -54,36 +53,76 @@ describe('Cmr list', () => { describe('Ticket pop-ups', () => { it('Should redirect to the ticket summary from the ticket descriptor pop-up', () => { cy.get(selectors.ticket).click(); - cy.get(selectors.descriptorId).should('contain', data.ticket); + cy.get(selectors.descriptorId) + .invoke('text') + .then((text) => { + expect(text).to.include(data.ticket); + }); cy.get(selectors.descriptorGoToSummaryBtn).click(); - cy.get(selectors.summaryHeader).should('contain', data.client); + cy.get(selectors.summaryTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); }); it('Should redirect to the ticket summary from summary pop-up from the ticket descriptor pop-up', () => { cy.get(selectors.ticket).click(); - cy.get(selectors.descriptorId).should('contain', data.ticket); - cy.get(selectors.summaryPopupBtn).click(); - cy.get(selectors.summaryPopupHeader).should('contain', data.client); + cy.get(selectors.descriptorId) + .invoke('text') + .then((text) => { + expect(text).to.include(data.ticket); + }); + cy.get(selectors.descriptorOpenSummaryBtn).click(); + cy.get(selectors.summaryTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); cy.get(selectors.summaryGoToSummaryBtn).click(); - cy.get(selectors.summaryHeader).should('contain', data.client); + cy.get(selectors.summaryTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); }); }); describe('Client pop-ups', () => { it('Should redirect to the client summary from the client descriptor pop-up', () => { cy.get(selectors.client).click(); - cy.get(selectors.descriptorTitle).should('contain', data.client); + cy.get(selectors.descriptorTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); cy.get(selectors.descriptorGoToSummaryBtn).click(); - cy.get(selectors.summaryHeader).should('contain', data.client); + cy.get(selectors.summaryTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); }); it('Should redirect to the client summary from summary pop-up from the client descriptor pop-up', () => { cy.get(selectors.client).click(); - cy.get(selectors.descriptorTitle).should('contain', data.client); - cy.get(selectors.summaryPopupBtn).click(); - cy.get(selectors.summaryHeader).should('contain', data.client); + cy.get(selectors.descriptorTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); + cy.get(selectors.descriptorOpenSummaryBtn).click(); + cy.get(selectors.summaryTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); cy.get(selectors.summaryGoToSummaryBtn).click(); - cy.get(selectors.summaryHeader).should('contain', data.client); + cy.get(selectors.summaryTitle) + .invoke('text') + .then((text) => { + expect(text).to.include(data.client); + }); }); }); });