From ce827722e343de35a64cd9a6da68bad3718417d6 Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 6 Mar 2025 13:04:10 +0100 Subject: [PATCH 01/42] feat: refs #8441 add VehicleInvoiceIn component with invoice management functionality --- .../Route/Vehicle/Card/VehicleInvoiceIn.vue | 143 ++++++++++++++++++ src/pages/Route/Vehicle/locale/en.yml | 4 + src/pages/Route/Vehicle/locale/es.yml | 4 + src/pages/Route/locale/en.yml | 1 + src/pages/Route/locale/es.yml | 1 + src/router/modules/route.js | 11 +- 6 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue diff --git a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue new file mode 100644 index 000000000..ec2169706 --- /dev/null +++ b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue @@ -0,0 +1,143 @@ + + + + + + es: + unassignInvoice: Desvincular factura + unassignInvoiceConfirmation: Esta factura se desvinculará de este vehículo! ¿Continuar de todas formas? + en: + unassignInvoice: Unassign invoice + unassignInvoiceConfirmation: This invoice will be unassigned from this vehicle! Continue anyway? + diff --git a/src/pages/Route/Vehicle/locale/en.yml b/src/pages/Route/Vehicle/locale/en.yml index c92022f9d..451fc4640 100644 --- a/src/pages/Route/Vehicle/locale/en.yml +++ b/src/pages/Route/Vehicle/locale/en.yml @@ -18,3 +18,7 @@ vehicle: params: vehicleTypeFk: Type vehicleStateFk: State + ticket: + assignInvoice: Assign invoice + unassignInvoice: Unassign invoice + unassignInvoiceConfirmation: Are you sure you want to unassign the invoice? diff --git a/src/pages/Route/Vehicle/locale/es.yml b/src/pages/Route/Vehicle/locale/es.yml index c878f97ac..a4d9680ea 100644 --- a/src/pages/Route/Vehicle/locale/es.yml +++ b/src/pages/Route/Vehicle/locale/es.yml @@ -18,3 +18,7 @@ vehicle: params: vehicleTypeFk: Tipo vehicleStateFk: Estado + ticket: + assignInvoice: Asignar factura + unassignInvoice: Desasignar factura + unassignInvoiceConfirmation: Seguro que quieres desasignar esta factura? diff --git a/src/pages/Route/locale/en.yml b/src/pages/Route/locale/en.yml index cc445f412..a06793574 100644 --- a/src/pages/Route/locale/en.yml +++ b/src/pages/Route/locale/en.yml @@ -16,6 +16,7 @@ route: shipped: Shipped agencyAgreement: Agency agreement agencyModeName: Agency route + issued: Issued Worker: Worker Agency: Agency Vehicle: Vehicle diff --git a/src/pages/Route/locale/es.yml b/src/pages/Route/locale/es.yml index 51d43774a..5283c3438 100644 --- a/src/pages/Route/locale/es.yml +++ b/src/pages/Route/locale/es.yml @@ -16,6 +16,7 @@ route: ticketFk: Id ticket routeFK: Id ruta shipped: Fecha preparación + issued: F. emisión Worker: Trabajador Agency: Agencia Vehicle: Vehículo diff --git a/src/router/modules/route.js b/src/router/modules/route.js index 835324d20..ba41976eb 100644 --- a/src/router/modules/route.js +++ b/src/router/modules/route.js @@ -166,7 +166,7 @@ const vehicleCard = { component: () => import('src/pages/Route/Vehicle/Card/VehicleCard.vue'), redirect: { name: 'VehicleSummary' }, meta: { - menu: ['VehicleBasicData'], + menu: ['VehicleBasicData', 'VehicleInvoiceIn'], }, children: [ { @@ -187,6 +187,15 @@ const vehicleCard = { }, component: () => import('src/pages/Route/Vehicle/Card/VehicleBasicData.vue'), }, + { + name: 'VehicleInvoiceIn', + path: 'invoice-in', + meta: { + title: 'invoiceIns', + icon: 'vn:ticket', + }, + component: () => import('src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue'), + }, ], }; -- 2.40.1 From 08e68e47b83e694b936d4ef3d7db998d6779184d Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 6 Mar 2025 13:06:50 +0100 Subject: [PATCH 02/42] test: refs #8441 add e2e tests for vehicleInvoiceIn --- .../route/vehicle/vehicleInvoiceIn.spec.js | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js diff --git a/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js new file mode 100644 index 000000000..19fa9d581 --- /dev/null +++ b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js @@ -0,0 +1,87 @@ +describe('Vehicle Invoice In', () => { + const selectors = { + firstRowSupplier: 'tr:first-child > .expand > .no-padding > .link', + firstRowInvoice: + ':nth-child(1) > [data-col-field="supplierRef"] > .no-padding > .link', + descriptorTitle: + '.q-menu > .descriptor > .body > .q-list > .q-item__label--header > .title > span', + descriptorPopupGoToSummaryBtn: + '.header > :nth-child(2) > .q-btn__content > .q-icon', + summaryTitle: '.summaryHeader > :nth-child(2)', + summaryPopUpGoToSummaryBtn: '.header > .q-icon', + unassignBtn: 'tableAction-0', + }; + + const supplier = 'PLANTS SL'; + const invoice = '1234'; + + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('deliveryAssistant'); + cy.visit(`/#/route/vehicle/1/invoice-in`); + }); + + it('Should show assigned tickets', () => { + cy.get('.q-table') + .children() + .should('be.visible') + .should('have.length.greaterThan', 0); + }); + + it('Should assign a new invoice', () => { + const data = { + 'Invoice nº': { val: '5', type: 'select' }, + 'Nº Plate': { val: '3333-BAT', type: 'select' }, + }; + cy.addBtnClick(); + cy.fillInForm(data); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data created'); + }); + + it('Should unassign an invoice', () => { + cy.dataCy(selectors.unassignBtn).last().click(); + cy.clickConfirm(); + cy.checkNotification('Data saved'); + }); + + describe('Supplier pop-ups', () => { + it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => { + cy.get(selectors.firstRowSupplier).click(); + cy.get(selectors.descriptorTitle).should('contain', supplier); + cy.get( + '[href="#/supplier/1/summary"] > .q-btn > .q-btn__content > .q-icon', + ).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', () => { + cy.get(selectors.firstRowSupplier).click(); + cy.get(selectors.descriptorTitle).should('contain', supplier); + cy.get(selectors.descriptorPopupGoToSummaryBtn).click(); + cy.get(selectors.summaryTitle).should('contain', supplier); + cy.get(selectors.summaryPopUpGoToSummaryBtn).click(); + cy.get(selectors.summaryTitle).should('contain', supplier); + }); + }); + + describe('Invoice pop-ups', () => { + it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => { + cy.get(selectors.firstRowInvoice).click(); + cy.get(selectors.descriptorTitle).should('have.text', invoice); + cy.get( + '[href="#/invoice-in/1/summary"] > .q-btn > .q-btn__content > .q-icon', + ).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', () => { + cy.get(selectors.firstRowInvoice).click(); + cy.get(selectors.descriptorTitle).should('have.text', invoice); + cy.get(selectors.descriptorPopupGoToSummaryBtn).click(); + cy.get(selectors.summaryTitle).should('contain', supplier); + cy.get(selectors.summaryPopUpGoToSummaryBtn).click(); + cy.get(selectors.summaryTitle).should('contain', supplier); + }); + }); +}); -- 2.40.1 From 59fdf0fd007843b30e3730bf5ede35b78a35c83b Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 6 Mar 2025 15:25:43 +0100 Subject: [PATCH 03/42] refactor: refs #8441 update VehicleInvoiceIn component and localizations --- .../Route/Vehicle/Card/VehicleInvoiceIn.vue | 34 ++++++++----------- src/pages/Route/Vehicle/locale/en.yml | 2 +- src/pages/Route/Vehicle/locale/es.yml | 6 ++-- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue index ec2169706..7f50d8e60 100644 --- a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue +++ b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue @@ -117,27 +117,23 @@ async function unassignInvoice(id) { - + > + + - - - es: - unassignInvoice: Desvincular factura - unassignInvoiceConfirmation: Esta factura se desvinculará de este vehículo! ¿Continuar de todas formas? - en: - unassignInvoice: Unassign invoice - unassignInvoiceConfirmation: This invoice will be unassigned from this vehicle! Continue anyway? - diff --git a/src/pages/Route/Vehicle/locale/en.yml b/src/pages/Route/Vehicle/locale/en.yml index 451fc4640..b1c0b9a2f 100644 --- a/src/pages/Route/Vehicle/locale/en.yml +++ b/src/pages/Route/Vehicle/locale/en.yml @@ -21,4 +21,4 @@ vehicle: ticket: assignInvoice: Assign invoice unassignInvoice: Unassign invoice - unassignInvoiceConfirmation: Are you sure you want to unassign the invoice? + unassignInvoiceConfirmation: This invoice will be unassigned from this vehicle! Continue anyway? diff --git a/src/pages/Route/Vehicle/locale/es.yml b/src/pages/Route/Vehicle/locale/es.yml index a4d9680ea..0f9746cb4 100644 --- a/src/pages/Route/Vehicle/locale/es.yml +++ b/src/pages/Route/Vehicle/locale/es.yml @@ -19,6 +19,6 @@ vehicle: vehicleTypeFk: Tipo vehicleStateFk: Estado ticket: - assignInvoice: Asignar factura - unassignInvoice: Desasignar factura - unassignInvoiceConfirmation: Seguro que quieres desasignar esta factura? + assignInvoice: Vincular factura + unassignInvoice: Desvincular factura + unassignInvoiceConfirmation: Esta factura se desvinculará de este vehículo! ¿Continuar de todas formas? -- 2.40.1 From 16a54bf02e53fec6b868946ea8215d76295c3974 Mon Sep 17 00:00:00 2001 From: jtubau Date: Fri, 7 Mar 2025 15:28:12 +0100 Subject: [PATCH 04/42] refactor: refs #8441 add VnInputNumber component and update VnSelect options in VehicleInvoiceIn --- .../Route/Vehicle/Card/VehicleInvoiceIn.vue | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue index 7f50d8e60..61ce6caf8 100644 --- a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue +++ b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue @@ -10,6 +10,7 @@ import { useI18n } from 'vue-i18n'; import useNotify from 'src/composables/useNotify.js'; import axios from 'axios'; import VnSelect from 'src/components/common/VnSelect.vue'; +import VnInputNumber from 'src/components/common/VnInputNumber.vue'; const tableRef = ref(); const { t } = useI18n(); @@ -40,7 +41,7 @@ const columns = computed(() => [ fields: ['id', 'name'], }, }, - format: ({supplierName}) => supplierName, + format: ({ supplierName }) => supplierName, columnClass: 'expand', cardVisible: true, }, @@ -117,23 +118,26 @@ async function unassignInvoice(id) { - + + -- 2.40.1 From e2e34d2f2dc4b7141579d13ddf5541c1c560e472 Mon Sep 17 00:00:00 2001 From: jtubau Date: Mon, 10 Mar 2025 09:26:05 +0100 Subject: [PATCH 05/42] feat: refs #8441 add assigned invoices section to VehicleSummary and update localization --- src/pages/Route/Card/RouteSummary.vue | 2 +- .../Route/Vehicle/Card/VehicleSummary.vue | 54 +++++++++++++++++-- src/pages/Route/Vehicle/locale/en.yml | 1 + 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/pages/Route/Card/RouteSummary.vue b/src/pages/Route/Card/RouteSummary.vue index 3051972b2..af87ee010 100644 --- a/src/pages/Route/Card/RouteSummary.vue +++ b/src/pages/Route/Card/RouteSummary.vue @@ -168,7 +168,7 @@ const ticketColumns = ref([ -import { computed } from 'vue'; +import { computed, ref } from 'vue'; import { useRoute } from 'vue-router'; +import { dashIfEmpty, toCurrency, toDate } from 'src/filters'; +import { downloadFile } from 'src/composables/downloadFile'; + +import FetchData from 'src/components/FetchData.vue'; import CardSummary from 'components/ui/CardSummary.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; +import InvoiceInDescriptorProxy from 'src/pages/InvoiceIn/Card/InvoiceInDescriptorProxy.vue'; import VehicleFilter from '../VehicleFilter.js'; -import { downloadFile } from 'src/composables/downloadFile'; -import { dashIfEmpty } from 'src/filters'; const props = defineProps({ id: { type: [Number, String], default: null } }); +const invoices = ref([]); const route = useRoute(); const entityId = computed(() => props.id || +route.params.id); const links = { @@ -22,6 +26,11 @@ const links = { }; diff --git a/src/pages/Route/Vehicle/locale/en.yml b/src/pages/Route/Vehicle/locale/en.yml index b1c0b9a2f..9a32080b1 100644 --- a/src/pages/Route/Vehicle/locale/en.yml +++ b/src/pages/Route/Vehicle/locale/en.yml @@ -19,6 +19,7 @@ vehicle: vehicleTypeFk: Type vehicleStateFk: State ticket: + assignedInvoices: Assigned Invoices assignInvoice: Assign invoice unassignInvoice: Unassign invoice unassignInvoiceConfirmation: This invoice will be unassigned from this vehicle! Continue anyway? -- 2.40.1 From 3961c4e27657dc2e99fceecf8b5ebe96614db1c6 Mon Sep 17 00:00:00 2001 From: jtubau Date: Mon, 10 Mar 2025 09:28:37 +0100 Subject: [PATCH 06/42] refactor: refs #8441 add translation for assigned invoices in Vehicle locale --- src/pages/Route/Vehicle/locale/es.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/Route/Vehicle/locale/es.yml b/src/pages/Route/Vehicle/locale/es.yml index 0f9746cb4..08c7b324a 100644 --- a/src/pages/Route/Vehicle/locale/es.yml +++ b/src/pages/Route/Vehicle/locale/es.yml @@ -19,6 +19,7 @@ vehicle: vehicleTypeFk: Tipo vehicleStateFk: Estado ticket: + assignedInvoices: Facturas vinculadas assignInvoice: Vincular factura unassignInvoice: Desvincular factura unassignInvoiceConfirmation: Esta factura se desvinculará de este vehículo! ¿Continuar de todas formas? -- 2.40.1 From 0fac79ea4dda4d9eba2acfe13885b683f94b8c8b Mon Sep 17 00:00:00 2001 From: jtubau Date: Mon, 10 Mar 2025 09:58:45 +0100 Subject: [PATCH 07/42] test: refs #8441 update vehicleInvoiceIn.spec.js to use 'developer' login and modify invoice data --- .../integration/route/vehicle/vehicleInvoiceIn.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js index 19fa9d581..372e1932c 100644 --- a/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js +++ b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js @@ -17,7 +17,7 @@ describe('Vehicle Invoice In', () => { beforeEach(() => { cy.viewport(1920, 1080); - cy.login('deliveryAssistant'); + cy.login('developer'); cy.visit(`/#/route/vehicle/1/invoice-in`); }); @@ -31,7 +31,7 @@ describe('Vehicle Invoice In', () => { it('Should assign a new invoice', () => { const data = { 'Invoice nº': { val: '5', type: 'select' }, - 'Nº Plate': { val: '3333-BAT', type: 'select' }, + Amount: { val: '1000' }, }; cy.addBtnClick(); cy.fillInForm(data); @@ -72,7 +72,7 @@ describe('Vehicle Invoice In', () => { cy.get( '[href="#/invoice-in/1/summary"] > .q-btn > .q-btn__content > .q-icon', ).click(); - cy.get(selectors.summaryTitle).should('contain', supplier); + // cy.get(selectors.summaryTitle).should('contain', supplier); }); it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => { -- 2.40.1 From 7ebf4cd38f2c7a86fe00c965eca75cfdf6f71f65 Mon Sep 17 00:00:00 2001 From: jtubau Date: Tue, 11 Mar 2025 09:49:16 +0100 Subject: [PATCH 08/42] test: refs #8441 update vehicle invoice in tests for delivery assistant login --- .../integration/route/vehicle/vehicleInvoiceIn.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js index 372e1932c..d941e6b78 100644 --- a/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js +++ b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js @@ -1,4 +1,4 @@ -describe('Vehicle Invoice In', () => { +describe.only('Vehicle Invoice In', () => { const selectors = { firstRowSupplier: 'tr:first-child > .expand > .no-padding > .link', firstRowInvoice: @@ -17,7 +17,7 @@ describe('Vehicle Invoice In', () => { beforeEach(() => { cy.viewport(1920, 1080); - cy.login('developer'); + cy.login('deliveryAssistant'); cy.visit(`/#/route/vehicle/1/invoice-in`); }); @@ -72,7 +72,7 @@ describe('Vehicle Invoice In', () => { cy.get( '[href="#/invoice-in/1/summary"] > .q-btn > .q-btn__content > .q-icon', ).click(); - // cy.get(selectors.summaryTitle).should('contain', supplier); + cy.get(selectors.summaryTitle).should('contain', supplier); }); it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => { -- 2.40.1 From ef797a3675fe58975effd7cff70aadce61031f20 Mon Sep 17 00:00:00 2001 From: jtubau Date: Tue, 11 Mar 2025 11:35:50 +0100 Subject: [PATCH 09/42] test: refs #8441 add Cypress tests for vehicle summary functionality --- .../Route/Vehicle/Card/VehicleSummary.vue | 2 +- .../route/vehicle/vehicleSummary.spec.js | 112 ++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 test/cypress/integration/route/vehicle/vehicleSummary.spec.js diff --git a/src/pages/Route/Vehicle/Card/VehicleSummary.vue b/src/pages/Route/Vehicle/Card/VehicleSummary.vue index 466b770d6..9331d99c2 100644 --- a/src/pages/Route/Vehicle/Card/VehicleSummary.vue +++ b/src/pages/Route/Vehicle/Card/VehicleSummary.vue @@ -138,7 +138,7 @@ const links = { diff --git a/test/cypress/integration/route/vehicle/vehicleSummary.spec.js b/test/cypress/integration/route/vehicle/vehicleSummary.spec.js new file mode 100644 index 000000000..d9dff465b --- /dev/null +++ b/test/cypress/integration/route/vehicle/vehicleSummary.spec.js @@ -0,0 +1,112 @@ +describe('Vehicle summary', () => { + const selectors = { + summaryTitle: '.summaryHeader > :nth-child(2)', + descriptorTitle: '.q-item__label--header > .title > span', + descriptorPopupTitle: '.q-menu > .descriptor > .body > .q-list > .q-item__label--header > .title > span', + supplierSummaryPopUpTitle: '.q-dialog__inner > .summary > .cardSummary > .summaryHeader > :nth-child(2)', + invoiceSummaryPopupTitle: '.q-dialog__inner > .summary > .cardSummary > .summaryHeader > div', + descriptorOptions: 'descriptor-more-opts', + delete: 'delete', + basicDataSupplierLink: ':nth-child(4) > .value > .link', + summaryAssignedInvoicesLink: '.vn-max > .q-pb-lg > .header-link > .link', + summaryBasicDataLink: '[dense=""] > .q-pb-lg > .header-link > .link', + assignedInvoicesSupplierLink: 'tbody > :nth-child(1) > :nth-child(2) > .link', + assignedInvoicesInvoiceLink: ':nth-child(1) > :nth-child(3) > .link', + supplierDescriptorGoToSummary: '[href="#/supplier/1/summary"] > .q-btn > .q-btn__content > .q-icon', + invoiceDescriptorGoToSummary: '[href="#/invoice-in/1/summary"] > .q-btn > .q-btn__content > .q-icon', + descriptorSummaryPopup: '.header > :nth-child(2) > .q-btn__content > .q-icon', + summaryPopupGoToSummary: '.header > .q-icon', + } + + const data = { + vehiclePlate: '3333-BAT', + supplierName: 'PLANTS SL', + invoice: '1234', + } + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('deliveryAssistant'); + cy.visit(`/#/route/vehicle/1/summary`); + }); + it('Should load summary', () => { + cy.get(selectors.summaryTitle).should('contain', data.vehiclePlate); + cy.get(selectors.descriptorTitle).should('contain', data.vehiclePlate); + }); + + it('should delete a vehicle', () => { + cy.typeSearchbar('7{enter}'); + cy.dataCy(selectors.descriptorOptions).click(); + cy.dataCy(selectors.delete).click(); + cy.checkNotification('Vehicle removed'); + }); + + it('Should redirect to vehicle basic-data', () => { + cy.get(selectors.summaryBasicDataLink).click(); + cy.url().should('include', '/vehicle/1/basic-data'); + }) + + it('Should redirect to vehicle invoice-ins', () => { + cy.get(selectors.summaryAssignedInvoicesLink).click(); + cy.url().should('include', '/vehicle/1/invoice-in'); + }) + + describe('Supplier basic data pop-ups', () => { + it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => { + cy.get(selectors.basicDataSupplierLink).click(); + cy.get(selectors.descriptorPopupTitle).should('contain', data.supplierName); + cy.get(selectors.supplierDescriptorGoToSummary).click(); + cy.get(selectors.summaryTitle).should('contain', data.supplierName); + cy.url().should('include', '/supplier/1/summary'); + }); + + it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => { + cy.get(selectors.basicDataSupplierLink).click(); + cy.get(selectors.descriptorPopupTitle).should('contain', data.supplierName); + cy.get(selectors.descriptorSummaryPopup).click(); + cy.get(selectors.supplierSummaryPopUpTitle).should('contain', data.supplierName); + cy.get(selectors.summaryPopupGoToSummary).click(); + cy.get(selectors.summaryTitle).should('contain', data.supplierName); + cy.url().should('include', '/supplier/1/summary'); + }); + }); + + describe('Supplier assigned invoices pop-ups', () => { + it('Should redirect to the supplier summary from the invoice descriptor pop-up', () => { + cy.get(selectors.assignedInvoicesSupplierLink).click(); + cy.get(selectors.descriptorPopupTitle).should('contain', data.supplierName); + cy.get(selectors.supplierDescriptorGoToSummary).click(); + cy.get(selectors.summaryTitle).should('contain', data.supplierName); + cy.url().should('include', '/supplier/1/summary'); + }); + + it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => { + cy.get(selectors.assignedInvoicesSupplierLink).click(); + cy.get(selectors.descriptorPopupTitle).should('contain', data.supplierName); + cy.get(selectors.descriptorSummaryPopup).click(); + cy.get(selectors.supplierSummaryPopUpTitle).should('contain', data.supplierName); + cy.get(selectors.summaryPopupGoToSummary).click(); + cy.get(selectors.summaryTitle).should('contain', data.supplierName); + cy.url().should('include', '/supplier/1/summary'); + }); + }); + + describe('Invoice pop-ups', () => { + it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => { + cy.get(selectors.assignedInvoicesInvoiceLink).click(); + cy.get(selectors.descriptorPopupTitle).should('contain', data.invoice); + cy.get(selectors.invoiceDescriptorGoToSummary).click(); + cy.get(selectors.summaryTitle).should('contain', data.supplierName); + cy.url().should('include', '/invoice-in/1/summary'); + }); + + it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => { + cy.get(selectors.assignedInvoicesInvoiceLink).click(); + cy.get(selectors.descriptorPopupTitle).should('contain', data.invoice); + cy.get(selectors.descriptorSummaryPopup).click(); + cy.get(selectors.invoiceSummaryPopupTitle).should('contain', data.supplierName); + cy.get(selectors.summaryPopupGoToSummary).click(); + cy.get(selectors.summaryTitle).should('contain', data.supplierName); + cy.url().should('include', '/invoice-in/1/summary'); + }); + }); +}); \ No newline at end of file -- 2.40.1 From b8be248af9cd6a3956fef8a4f1804110c15ef9ef Mon Sep 17 00:00:00 2001 From: jtubau Date: Fri, 14 Mar 2025 08:12:48 +0100 Subject: [PATCH 10/42] fix: refs #8441 update unassign invoice functionality and notifications --- src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue | 10 +++++++--- src/pages/Route/Vehicle/locale/en.yml | 1 + src/pages/Route/Vehicle/locale/es.yml | 1 + src/pages/Route/locale/es.yml | 4 ++-- .../integration/route/vehicle/vehicleInvoiceIn.spec.js | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue index 61ce6caf8..4794139d0 100644 --- a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue +++ b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue @@ -79,9 +79,13 @@ const columns = computed(() => [ ]); async function unassignInvoice(id) { - await axios.delete(`VehicleInvoiceIns/${id}`); - notify(t('globals.dataSaved'), 'positive'); - tableRef.value.reload(); + try { + await axios.delete(`VehicleInvoiceIns/${id}`); + notify(t('vehicle.ticket.invoiceUnlinked'), 'positive'); + tableRef.value.reload(); + } catch (e) { + throw e; + } } diff --git a/src/pages/Route/Vehicle/locale/en.yml b/src/pages/Route/Vehicle/locale/en.yml index 9a32080b1..45a0a4950 100644 --- a/src/pages/Route/Vehicle/locale/en.yml +++ b/src/pages/Route/Vehicle/locale/en.yml @@ -21,5 +21,6 @@ vehicle: ticket: assignedInvoices: Assigned Invoices assignInvoice: Assign invoice + invoiceUnlinked: Invoice unlinked unassignInvoice: Unassign invoice unassignInvoiceConfirmation: This invoice will be unassigned from this vehicle! Continue anyway? diff --git a/src/pages/Route/Vehicle/locale/es.yml b/src/pages/Route/Vehicle/locale/es.yml index 08c7b324a..7cda1006c 100644 --- a/src/pages/Route/Vehicle/locale/es.yml +++ b/src/pages/Route/Vehicle/locale/es.yml @@ -21,5 +21,6 @@ vehicle: ticket: assignedInvoices: Facturas vinculadas assignInvoice: Vincular factura + invoiceUnlinked: Factura desvinculada unassignInvoice: Desvincular factura unassignInvoiceConfirmation: Esta factura se desvinculará de este vehículo! ¿Continuar de todas formas? diff --git a/src/pages/Route/locale/es.yml b/src/pages/Route/locale/es.yml index 78af0358c..6affd7e99 100644 --- a/src/pages/Route/locale/es.yml +++ b/src/pages/Route/locale/es.yml @@ -17,7 +17,7 @@ route: clientFk: Id cliente countryFk: Pais warehouseFk: Almacén - shipped: Fecha preparación + shipped: F. preparación agencyModeName: Agencia Ruta agencyAgreement: Agencia Acuerdo issued: F. emisión @@ -58,6 +58,6 @@ route: routeFk: Id ruta country: País clientFk: Id cliente - shipped: Fecha preparación + shipped: F. preparación viewCmr: Ver CMR downloadCmrs: Descargar CMRs diff --git a/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js index d941e6b78..7899b36ab 100644 --- a/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js +++ b/test/cypress/integration/route/vehicle/vehicleInvoiceIn.spec.js @@ -1,4 +1,4 @@ -describe.only('Vehicle Invoice In', () => { +describe('Vehicle Invoice In', () => { const selectors = { firstRowSupplier: 'tr:first-child > .expand > .no-padding > .link', firstRowInvoice: @@ -42,7 +42,7 @@ describe.only('Vehicle Invoice In', () => { it('Should unassign an invoice', () => { cy.dataCy(selectors.unassignBtn).last().click(); cy.clickConfirm(); - cy.checkNotification('Data saved'); + cy.checkNotification('Invoice unlinked'); }); describe('Supplier pop-ups', () => { -- 2.40.1 From 512611a309e5e4a6762ec76a9b0e64436a598392 Mon Sep 17 00:00:00 2001 From: jtubau Date: Fri, 14 Mar 2025 12:45:02 +0100 Subject: [PATCH 11/42] refactor: refs #8441 add data-cy attributes for summary buttons and improve tests for vehicle invoice --- src/components/ui/CardDescriptor.vue | 2 + src/components/ui/CardSummary.vue | 1 + .../Route/Vehicle/Card/VehicleInvoiceIn.vue | 11 +--- .../route/vehicle/vehicleInvoiceIn.spec.js | 62 +++++++++---------- test/cypress/support/commands.js | 8 +++ 5 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/components/ui/CardDescriptor.vue b/src/components/ui/CardDescriptor.vue index 744f84e6d..961438b04 100644 --- a/src/components/ui/CardDescriptor.vue +++ b/src/components/ui/CardDescriptor.vue @@ -180,6 +180,7 @@ const toModule = computed(() => { color="white" class="link" v-if="summary" + data-cy="openSummaryBtn" > {{ t('components.smartCard.openSummary') }} @@ -194,6 +195,7 @@ const toModule = computed(() => { icon="launch" round size="md" + data-cy="goToSummaryBtn" > {{ t('components.cardDescriptor.summary') }} diff --git a/src/components/ui/CardSummary.vue b/src/components/ui/CardSummary.vue index 6a61994c1..05bfed998 100644 --- a/src/components/ui/CardSummary.vue +++ b/src/components/ui/CardSummary.vue @@ -81,6 +81,7 @@ async function fetch() { name: `${moduleName ?? route.meta.moduleName}Summary`, params: { id: entityId || entity.id }, }" + data-cy="goToSummaryBtn" > diff --git a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue index 4794139d0..a10be4b4d 100644 --- a/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue +++ b/src/pages/Route/Vehicle/Card/VehicleInvoiceIn.vue @@ -95,9 +95,10 @@ async function unassignInvoice(id) { :data-key="dataKey" :url="`vehicles/${route.params.id}/getInvoices`" :columns="columns" + search-url="vehicleInvoiceIns" :order="['issued DESC', 'supplierRef ASC']" :create="{ - urlCreate: 'VehicleInvoiceIns/assignInvoice', + urlCreate: 'VehicleInvoiceIns', title: t('vehicle.ticket.assignInvoice'), formInitialData: { vehicleFk: parseInt(route.params.id, 10), @@ -128,14 +129,6 @@ async function unassignInvoice(id) { option-label="supplierRef" :required="true" > - { + const getSelector = (colField) => + `tr:first-child > [data-col-field="${colField}"] > .no-padding > .link`; const selectors = { - firstRowSupplier: 'tr:first-child > .expand > .no-padding > .link', - firstRowInvoice: - ':nth-child(1) > [data-col-field="supplierRef"] > .no-padding > .link', - descriptorTitle: - '.q-menu > .descriptor > .body > .q-list > .q-item__label--header > .title > span', - descriptorPopupGoToSummaryBtn: - '.header > :nth-child(2) > .q-btn__content > .q-icon', - summaryTitle: '.summaryHeader > :nth-child(2)', - summaryPopUpGoToSummaryBtn: '.header > .q-icon', + firstRowSupplier: getSelector('supplierFk'), + firstRowInvoice: getSelector('supplierRef'), + descriptorTitle: '.descriptor .title', + summaryTitle: '.summaryHeader', + descriptorOpenSummaryBtn: '.descriptor [data-cy="openSummaryBtn"]', + descriptorGoToSummaryBtn: '.descriptor [data-cy="goToSummaryBtn"]', + SummaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]', unassignBtn: 'tableAction-0', }; - const supplier = 'PLANTS SL'; - const invoice = '1234'; + const data = { + supplier: 'PLANTS SL', + invoice: '1234', + }; beforeEach(() => { cy.viewport(1920, 1080); @@ -48,40 +52,36 @@ describe('Vehicle Invoice In', () => { describe('Supplier pop-ups', () => { it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => { cy.get(selectors.firstRowSupplier).click(); - cy.get(selectors.descriptorTitle).should('contain', supplier); - cy.get( - '[href="#/supplier/1/summary"] > .q-btn > .q-btn__content > .q-icon', - ).click(); - cy.get(selectors.summaryTitle).should('contain', supplier); + cy.containContent(selectors.descriptorTitle, data.supplier); + cy.get(selectors.descriptorGoToSummaryBtn).click(); + cy.containContent(selectors.summaryTitle, data.supplier); }); 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.descriptorTitle).should('contain', supplier); - cy.get(selectors.descriptorPopupGoToSummaryBtn).click(); - cy.get(selectors.summaryTitle).should('contain', supplier); - cy.get(selectors.summaryPopUpGoToSummaryBtn).click(); - cy.get(selectors.summaryTitle).should('contain', supplier); + cy.containContent(selectors.descriptorTitle, data.supplier); + cy.get(selectors.descriptorOpenSummaryBtn).click(); + cy.containContent(selectors.summaryTitle, data.supplier); + cy.get(selectors.SummaryGoToSummaryBtn).click(); + cy.containContent(selectors.summaryTitle, data.supplier); }); }); describe('Invoice pop-ups', () => { it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => { cy.get(selectors.firstRowInvoice).click(); - cy.get(selectors.descriptorTitle).should('have.text', invoice); - cy.get( - '[href="#/invoice-in/1/summary"] > .q-btn > .q-btn__content > .q-icon', - ).click(); - cy.get(selectors.summaryTitle).should('contain', supplier); + cy.containContent(selectors.descriptorTitle, data.invoice); + cy.get(selectors.descriptorGoToSummaryBtn).click(); + cy.containContent(selectors.summaryTitle, data.supplier); }); 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.descriptorTitle).should('have.text', invoice); - cy.get(selectors.descriptorPopupGoToSummaryBtn).click(); - cy.get(selectors.summaryTitle).should('contain', supplier); - cy.get(selectors.summaryPopUpGoToSummaryBtn).click(); - cy.get(selectors.summaryTitle).should('contain', supplier); + cy.containContent(selectors.descriptorTitle, data.invoice); + cy.get(selectors.descriptorOpenSummaryBtn).click(); + cy.containContent(selectors.summaryTitle, data.supplier); + cy.get(selectors.SummaryGoToSummaryBtn).click(); + cy.containContent(selectors.summaryTitle, data.supplier); }); }); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 8437112e0..9f10e5e50 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -317,6 +317,14 @@ Cypress.Commands.add('validateContent', (selector, 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) => { cy.openActionsDescriptor(); const listItem = '[role="menu"] .q-list .q-item'; -- 2.40.1 From f1f9a6ac162346f64edb3a1871718147e53ab5ad Mon Sep 17 00:00:00 2001 From: jtubau Date: Fri, 14 Mar 2025 14:27:23 +0100 Subject: [PATCH 12/42] refactor: refs #8441 update vehicle summary links to include module name in routes --- src/pages/Route/Vehicle/Card/VehicleSummary.vue | 10 +++++----- .../integration/route/vehicle/vehicleInvoiceIn.spec.js | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pages/Route/Vehicle/Card/VehicleSummary.vue b/src/pages/Route/Vehicle/Card/VehicleSummary.vue index 9331d99c2..04de1ad34 100644 --- a/src/pages/Route/Vehicle/Card/VehicleSummary.vue +++ b/src/pages/Route/Vehicle/Card/VehicleSummary.vue @@ -18,11 +18,11 @@ const invoices = ref([]); const route = useRoute(); const entityId = computed(() => props.id || +route.params.id); const links = { - 'basic-data': `#/vehicle/${entityId.value}/basic-data`, - notes: `#/vehicle/${entityId.value}/notes`, - dms: `#/vehicle/${entityId.value}/dms`, - 'invoice-in': `#/vehicle/${entityId.value}/invoice-in`, - events: `#/vehicle/${entityId.value}/events`, + 'basic-data': `#/${route.meta.moduleName}/vehicle/${entityId.value}/basic-data`, + notes: `#/${route.meta.moduleName}/vehicle/${entityId.value}/notes`, + dms: `#/${route.meta.moduleName}/vehicle/${entityId.value}/dms`, + 'invoice-in': `#/${route.meta.moduleName}/vehicle/${entityId.value}/invoice-in`, + events: `#/${route.meta.moduleName}/vehicle/${entityId.value}/events`, };