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