From d2b1cd406709e8f9fa4faa1703499c59c09e0bf6 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 21 Feb 2025 08:20:35 +0100 Subject: [PATCH] refactor: refs #8599 requested changes --- .../Card/InvoiceOutDescriptorMenu.vue | 8 +++- .../invoiceOutNegativeBases.spec.js | 14 +++---- .../invoiceOut/invoiceOutSummary.spec.js | 39 ++++++++++++------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/pages/InvoiceOut/Card/InvoiceOutDescriptorMenu.vue b/src/pages/InvoiceOut/Card/InvoiceOutDescriptorMenu.vue index 1fd9f3e92..8be928134 100644 --- a/src/pages/InvoiceOut/Card/InvoiceOutDescriptorMenu.vue +++ b/src/pages/InvoiceOut/Card/InvoiceOutDescriptorMenu.vue @@ -163,10 +163,14 @@ const showExportationLetter = () => { - {{ t('Send PDF') }} + + {{ t('Send PDF') }} + - {{ t('Send CSV') }} + + {{ t('Send CSV') }} + diff --git a/test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js b/test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js index dc8235c1a..4d530de05 100644 --- a/test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js +++ b/test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js @@ -1,11 +1,7 @@ /// describe('InvoiceOut negative bases', () => { - const clientDescriptor = - ':nth-child(1) > [data-col-field="clientId"] > .no-padding > .link'; - const ticketDescriptor = - ':nth-child(1) > [data-col-field="ticketFk"] > .no-padding > .link'; - const workerDescriptor = - ':nth-child(1) > [data-col-field="workerName"] > .no-padding > .link'; + const getDescriptors = (opt) => + `:nth-child(1) > [data-col-field="${opt}"] > .no-padding > .link`; beforeEach(() => { cy.viewport(1920, 1080); @@ -14,13 +10,13 @@ describe('InvoiceOut negative bases', () => { }); it('should open the posible descriptors', () => { - cy.get(clientDescriptor).click(); + cy.get(getDescriptors('clientId')).click(); cy.get('.descriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('include.text', '1101'); - cy.get(ticketDescriptor).click(); + cy.get(getDescriptors('ticketFk')).click(); cy.get('.descriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('include.text', '23'); - cy.get(workerDescriptor).click(); + cy.get(getDescriptors('workerName')).click(); cy.get('.descriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('include.text', '18'); }); diff --git a/test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js b/test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js index d774a4935..0e945be6e 100644 --- a/test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js +++ b/test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js @@ -5,11 +5,12 @@ describe('InvoiceOut summary', () => { Type: { val: 'Error in customer data', type: 'select' }, }; - const firstTicketRowDescriptor = 'tbody > :nth-child(1) > :nth-child(1) > .q-btn'; - const firstClientRowDescriptor = - 'tbody > :nth-child(1) > :nth-child(2) > .q-btn > .q-btn__content'; + const firstRowDescriptors = (opt) => + `tbody > :nth-child(1) > :nth-child(${opt}) > .q-btn`; const toCustomerSummary = '[href="#/customer/1101"]'; const toTicketList = '[href="#/ticket/list?table={%22refFk%22:%22T1111111%22}"]'; + const selectMenuOption = (opt) => `.q-menu > .q-list > :nth-child(${opt})`; + const confirmSend = '.q-btn--unelevated'; beforeEach(() => { cy.viewport(1920, 1080); @@ -18,10 +19,10 @@ describe('InvoiceOut summary', () => { }); it('open the descriptors', () => { - cy.get(firstTicketRowDescriptor).click(); + cy.get(firstRowDescriptors(1)).click(); cy.get('.descriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('include.text', '1'); - cy.get(firstClientRowDescriptor).click(); + cy.get(firstRowDescriptors(2)).click(); cy.get('.descriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('include.text', '1101'); }); @@ -35,51 +36,59 @@ describe('InvoiceOut summary', () => { it('should open the ticket list', () => { cy.get(toTicketList).click(); cy.get('.descriptor').should('be.visible'); - cy.get('[data-cy="vnFilterPanelChip"]').should('include.text', 'T1111111'); + cy.dataCy('vnFilterPanelChip').should('include.text', 'T1111111'); }); it('should transfer the invoice ', () => { cy.typeSearchbar('T1111111{enter}'); cy.dataCy('descriptor-more-opts').click(); - cy.get('.q-menu > .q-list > :nth-child(1)').click(); + cy.get(selectMenuOption(1)).click(); cy.fillInForm(transferInvoice); cy.get('.q-mt-lg > .q-btn').click(); cy.checkNotification('Transferred invoice'); }); - it('should send the invoice', () => { + it('should send the invoice as PDF', () => { cy.dataCy('descriptor-more-opts').click(); - cy.get('.q-menu > .q-list > :nth-child(3)').click(); - cy.get('#q-portal--menu--3 > .q-menu > .q-list > :nth-child(1)').click(); - cy.get('.q-btn--unelevated').click(); + cy.get(selectMenuOption(3)).click(); + cy.dataCy('InvoiceOutDescriptorMenuSendPdfOption').click(); + cy.get(confirmSend).click(); + cy.checkNotification('Notification sent'); + }); + + it('should send the invoice as CSV', () => { + cy.dataCy('descriptor-more-opts').click(); + cy.get(selectMenuOption(3)).click(); + cy.dataCy('InvoiceOutDescriptorMenuSendCsvOption').click(); + cy.get(confirmSend).click(); cy.checkNotification('Notification sent'); }); it('should delete an invoice ', () => { cy.typeSearchbar('T2222222{enter}'); cy.dataCy('descriptor-more-opts').click(); - cy.get('.q-menu > .q-list > :nth-child(4)').click(); + cy.get(selectMenuOption(4)).click(); cy.dataCy('VnConfirm_confirm').click(); cy.checkNotification('InvoiceOut deleted'); }); it('shpuld book the invoice', () => { cy.dataCy('descriptor-more-opts').click(); - cy.get('.q-menu > .q-list > :nth-child(5)').click(); + cy.get(selectMenuOption(5)).click(); cy.dataCy('VnConfirm_confirm').click(); cy.checkNotification('InvoiceOut booked'); }); it('should generate the invoice PDF', () => { cy.dataCy('descriptor-more-opts').click(); - cy.get('.q-menu > .q-list > :nth-child(6)').click(); + cy.get(selectMenuOption(6)).click(); cy.dataCy('VnConfirm_confirm').click(); cy.checkNotification('The invoice PDF document has been regenerated'); }); it('should refund the invoice ', () => { cy.dataCy('descriptor-more-opts').click(); - cy.get('.q-menu > .q-list > :nth-child(7)').click(); + cy.get(selectMenuOption(7)).click(); cy.get('#q-portal--menu--3 > .q-menu > .q-list > :nth-child(2)').click(); cy.checkNotification('The following refund ticket have been created'); });