From 560cce7c8cafa326ff2499255865108e30a390a5 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 19 Jun 2019 14:40:47 +0200 Subject: [PATCH] #1537 refactor fixtures --- db/dump/fixtures.sql | 20 +- e2e/helpers/extensions.js | 4 +- .../12_lock_of_verified_data.spec.js | 220 +++--------------- .../05-ticket-module/12_descriptor.spec.js | 24 +- .../back/methods/client/specs/getCard.spec.js | 2 +- .../back/methods/client/specs/getDebt.spec.js | 2 +- .../back/methods/client/specs/summary.spec.js | 2 +- .../methods/invoiceOut/specs/delete.spec.js | 32 ++- .../methods/invoiceOut/specs/filter.spec.js | 4 +- .../methods/invoiceOut/specs/summary.spec.js | 20 +- .../back/methods/route/specs/filter.spec.js | 2 +- .../sale/specs/priceDifference.spec.js | 7 +- .../methods/sale/specs/updatePrice.spec.js | 23 +- .../ticket/back/methods/ticket/makeInvoice.js | 10 +- modules/ticket/back/methods/ticket/new.js | 14 +- .../ticket/specs/componentUpdate.spec.js | 28 ++- .../methods/ticket/specs/isEditable.spec.js | 10 +- .../methods/ticket/specs/makeInvoice.spec.js | 7 +- .../back/methods/ticket/threeLastActive.js | 2 +- 19 files changed, 140 insertions(+), 293 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 01a8420fe..fe9d40669 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -187,7 +187,7 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`fax`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`cplusTerIdNifFk`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`) VALUES (101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), - (102, 'Petter Parker', '87945234L', 'Spider-Man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 18, 0, 1), + (102, 'Petter Parker', '87945234L', 'Spider-Man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (103, 'Clark Kent', '06815934E', 'Super-Man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (104, 'Tony Stark', '06089160W', 'Iron-Man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, NULL, 0, 1), @@ -439,12 +439,12 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (14, 1, 2, 2, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 'Malibu Point', 4, NULL, 0, CURDATE()), (15, 1, 3, 3, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 105, 'Plastic Cell', 125, NULL, 0, CURDATE()), (16, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, CURDATE()), - (17, 1, 4, 4, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 107, 'Your pocket', 127, NULL, 0, CURDATE()), + (17, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, CURDATE()), (18, 1, 4, 4, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 'Cerebro', 128, NULL, 0, CURDATE()), - (19, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, CURDATE()), - (20, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, CURDATE()), - (21, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Holland', 102, NULL, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Japan', 103, NULL, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); + (19, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 1, CURDATE()), + (20, 1, 5, 5, 3, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (21, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Holland', 102, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (22, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Japan', 103, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); ccc INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -475,10 +475,10 @@ INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `crea (16, 16, 3, 19, CURDATE()), (17, 17, 3, 19, CURDATE()), (18, 18, 3, 19, CURDATE()), - (19, 19, 3, 19, CURDATE()), - (20, 20, 3, 19, CURDATE()), + (19, 19, 17, 19, CURDATE()), + (20, 20, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), (21, 21, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, 22, 17, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); + (22, 22, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`) VALUES @@ -1095,7 +1095,7 @@ INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_ (17, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 107, 1, 4, 127, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), (18, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 1, 4, 128, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), (19, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 1, 5, 129, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), - (20, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 1, 5, 101, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()), + (20, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 101, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), (21, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 102, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), (22, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 103, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)); diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 19a579127..e1f4f0f37 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -270,8 +270,8 @@ let actions = { waitForClassPresent: function(selector, className, done) { this.wait(selector) - .wait((selector, className) => { - if (document.querySelector(selector).classList.contains(className)) + .wait((elementSelector, targetClass) => { + if (document.querySelector(elementSelector).classList.contains(targetClass)) return true; }, selector, className) .then(done) diff --git a/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js b/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js index 971d1e5f9..d8378e577 100644 --- a/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js +++ b/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js @@ -8,7 +8,7 @@ describe('Client lock verified data path', () => { beforeAll(() => { nightmare .loginAndModule('salesPerson', 'client') - .accessToSearchResult('Petter Parker') + .accessToSearchResult('Hank Pym') .accessToSection('client.card.fiscalData'); }); @@ -27,7 +27,7 @@ describe('Client lock verified data path', () => { const result = await nightmare .wait(selectors.clientFiscalData.socialNameInput) .clearInput(selectors.clientFiscalData.socialNameInput) - .write(selectors.clientFiscalData.socialNameInput, 'salesPerson was here') + .write(selectors.clientFiscalData.socialNameInput, 'Captain America Civil War') .waitToClick(selectors.clientFiscalData.saveButton) .waitForLastSnackbar(); @@ -39,55 +39,16 @@ describe('Client lock verified data path', () => { .reloadSection('client.card.fiscalData') .waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value'); - expect(result).toEqual('salesPerson was here'); + expect(result).toEqual('Captain America Civil War'); }); }); describe('as administrative', () => { beforeAll(() => { nightmare - .waitForLogin('administrative'); - }); - - it('should navigate to clients index', async() => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); - }); - - it('should search again for the user Petter Parker', async() => { - const resultCount = await nightmare - .write(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); - - expect(resultCount).toEqual(1); - }); - - it(`should click on the search result to access to the Petter Parkers fiscal data`, async() => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); - }); - - it(`should click on the fiscal data button`, async() => { - const url = await nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); + .loginAndModule('administrative', 'client') + .accessToSearchResult('Hank Pym') + .accessToSection('client.card.fiscalData'); }); it('should confirm verified data button is enabled for administrative', async() => { @@ -110,18 +71,18 @@ describe('Client lock verified data path', () => { }); it('should confirm Verified data checkbox is checked', async() => { - const result = await nightmare + const isChecked = await nightmare .reloadSection('client.card.fiscalData') .checkboxState(selectors.clientFiscalData.verifiedDataCheckbox); - expect(result).toBe('checked'); + expect(isChecked).toEqual('checked'); }); it('should again edit the social name', async() => { const result = await nightmare .wait(selectors.clientFiscalData.socialNameInput) .clearInput(selectors.clientFiscalData.socialNameInput) - .write(selectors.clientFiscalData.socialNameInput, 'administrative was here') + .write(selectors.clientFiscalData.socialNameInput, 'Ant-Man and the Wasp') .waitToClick(selectors.clientFiscalData.saveButton) .waitForLastSnackbar(); @@ -133,71 +94,32 @@ describe('Client lock verified data path', () => { .reloadSection('client.card.fiscalData') .waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value'); - expect(result).toEqual('administrative was here'); + expect(result).toEqual('Ant-Man and the Wasp'); }); }); describe('as salesPerson second run', () => { beforeAll(() => { nightmare - .waitForLogin('salesPerson'); - }); - - it('should again click on the Clients button of the top bar menu', async() => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); - }); - - it('should again search for the user Petter Parker', async() => { - const resultCount = await nightmare - .write(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); - - expect(resultCount).toEqual(1); - }); - - it(`should click on the search result to access to the client's fiscal data`, async() => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); - }); - - it(`should click on the fiscal data button to start editing`, async() => { - const url = await nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); + .loginAndModule('salesPerson', 'client') + .accessToSearchResult('Hank Pym') + .accessToSection('client.card.fiscalData'); }); it('should confirm verified data button is disabled once again for salesPerson', async() => { - const result = await nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckbox) + const isChecked = await nightmare + .waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked') .evaluate(selector => { return document.querySelector(selector).getAttribute('disabled'); }, selectors.clientFiscalData.verifiedDataCheckbox); - expect(result).toBeTruthy(); + expect(isChecked).toBeTruthy(); }); it('should not be able to save change throwing a verified data error', async() => { const result = await nightmare .clearInput(selectors.clientFiscalData.socialNameInput) - .write(selectors.clientFiscalData.socialNameInput, 'salesPerson was here') + .write(selectors.clientFiscalData.socialNameInput, 'This wont happen') .waitToClick(selectors.clientFiscalData.saveButton) .waitForSnackbar(); @@ -209,64 +131,25 @@ describe('Client lock verified data path', () => { beforeAll(() => { nightmare .forceReloadSection('client.card.fiscalData') - .waitForLogin('salesAssistant'); - }); - - it('should now navigate to clients index', async() => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); - }); - - it('should now search again for the user Petter Parker', async() => { - const resultCount = await nightmare - .write(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); - - expect(resultCount).toEqual(1); - }); - - it(`should click on the search result to access to the Petter Parkers fiscal data`, async() => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); - }); - - it(`should click on the fiscal data button`, async() => { - const url = await nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); + .loginAndModule('salesAssistant', 'client') + .accessToSearchResult('Hank Pym') + .accessToSection('client.card.fiscalData'); }); it('should confirm verified data button is enabled for salesAssistant', async() => { - const result = await nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckbox) + const isDisabled = await nightmare + .waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked') .evaluate(selector => { - return document.querySelector(selector).getAttribute('disabled'); + return document.querySelector(selector).getAttribute('aria-disabled'); }, selectors.clientFiscalData.verifiedDataCheckbox); - expect(result).toBeFalsy(); + expect(isDisabled).toEqual('false'); }); it('should now edit the social name', async() => { const result = await nightmare .clearInput(selectors.clientFiscalData.socialNameInput) - .write(selectors.clientFiscalData.socialNameInput, 'salesAssistant was here') + .write(selectors.clientFiscalData.socialNameInput, 'new social name edition') .waitToClick(selectors.clientFiscalData.saveButton) .waitForLastSnackbar(); @@ -278,65 +161,26 @@ describe('Client lock verified data path', () => { .reloadSection('client.card.fiscalData') .waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value'); - expect(result).toEqual('salesAssistant was here'); + expect(result).toEqual('new social name edition'); }); }); describe('as salesPerson third run', () => { beforeAll(() => { nightmare - .waitForLogin('salesPerson'); - }); - - it('should now click on the Clients button of the top bar menu', async() => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - - expect(url.hash).toEqual('#!/client/index'); - }); - - it('should once again search for the user Petter Parker', async() => { - const resultCount = await nightmare - .write(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); - - expect(resultCount).toEqual(1); - }); - - it(`should click on the search result to access to the client's fiscal data`, async() => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); - }); - - it(`should click on the fiscal data button to start editing`, async() => { - const url = await nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl(); - - expect(url.hash).toContain('fiscal-data'); + .loginAndModule('salesPerson', 'client') + .accessToSearchResult('Hank Pym') + .accessToSection('client.card.fiscalData'); }); it('should confirm verified data button is enabled once again', async() => { - const result = await nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckbox) + const isChecked = await nightmare + .waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked') .evaluate(selector => { return document.querySelector(selector).getAttribute('disabled'); }, selectors.clientFiscalData.verifiedDataCheckbox); - expect(result).toBeTruthy(); + expect(isChecked).toBeTruthy(); }); it('should confirm the form is enabled for salesPerson', async() => { diff --git a/e2e/paths/05-ticket-module/12_descriptor.spec.js b/e2e/paths/05-ticket-module/12_descriptor.spec.js index 23c952af3..10fa0afa8 100644 --- a/e2e/paths/05-ticket-module/12_descriptor.spec.js +++ b/e2e/paths/05-ticket-module/12_descriptor.spec.js @@ -12,7 +12,7 @@ describe('Ticket descriptor path', () => { describe('Delete ticket', () => { it('should search for an specific ticket', async() => { const result = await nightmare - .write(selectors.ticketsIndex.searchTicketInput, 17) + .write(selectors.ticketsIndex.searchTicketInput, 18) .waitToClick(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countElement(selectors.ticketsIndex.searchResult); @@ -22,7 +22,7 @@ describe('Ticket descriptor path', () => { it(`should click on the search result to access to the ticket summary`, async() => { const url = await nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'Your pocket') + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'Cerebro') .waitToClick(selectors.ticketsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); @@ -49,7 +49,7 @@ describe('Ticket descriptor path', () => { it(`should search for the deleted ticket and check it's date`, async() => { const result = await nightmare - .write(selectors.ticketsIndex.searchTicketInput, 17) + .write(selectors.ticketsIndex.searchTicketInput, 18) .waitToClick(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .wait(selectors.ticketsIndex.searchResultDate) @@ -63,7 +63,7 @@ describe('Ticket descriptor path', () => { it('should search for a ticket', async() => { const result = await nightmare .clearInput(selectors.ticketsIndex.searchTicketInput) - .write(selectors.ticketsIndex.searchTicketInput, 20) + .write(selectors.ticketsIndex.searchTicketInput, 16) .waitToClick(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countElement(selectors.ticketsIndex.searchResult); @@ -73,7 +73,7 @@ describe('Ticket descriptor path', () => { it(`should now click on the search result to access to the ticket summary`, async() => { const url = await nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'Somewhere in Thailand') + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'Many Places') .waitToClick(selectors.ticketsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); @@ -104,29 +104,29 @@ describe('Ticket descriptor path', () => { const url = await nightmare .waitToClick(selectors.ticketDescriptor.closeStowawayDialog) .waitToClick(selectors.ticketDescriptor.shipButton) - .waitForURL('#!/ticket/19/summary') + .waitForURL('#!/ticket/17/summary') .parsedUrl(); - expect(url.hash).toContain('#!/ticket/19/summary'); + expect(url.hash).toContain('#!/ticket/17/summary'); }); it(`should navigate to the ship ticket using the descriptors ship button`, async() => { const url = await nightmare .waitToClick(selectors.ticketDescriptor.shipButton) - .waitForURL('#!/ticket/20/summary') + .waitForURL('#!/ticket/16/summary') .parsedUrl(); - expect(url.hash).toContain('#!/ticket/20/summary'); + expect(url.hash).toContain('#!/ticket/16/summary'); }); it(`should navigate back to the added ticket using the descriptors ship button`, async() => { const url = await nightmare .waitToClick(selectors.ticketDescriptor.closeStowawayDialog) .waitToClick(selectors.ticketDescriptor.shipButton) - .waitForURL('#!/ticket/19/summary') + .waitForURL('#!/ticket/17/summary') .parsedUrl(); - expect(url.hash).toContain('#!/ticket/19/summary'); + expect(url.hash).toContain('#!/ticket/17/summary'); }); it('should delete the stowaway', async() => { @@ -149,7 +149,7 @@ describe('Ticket descriptor path', () => { describe('Make invoice', () => { it('should login as adminBoss role then search for a ticket', async() => { - const invoiceableTicketId = 18; + const invoiceableTicketId = 14; const url = await nightmare .loginAndModule('adminBoss', 'ticket') diff --git a/modules/client/back/methods/client/specs/getCard.spec.js b/modules/client/back/methods/client/specs/getCard.spec.js index 9b3ddcf96..30d963150 100644 --- a/modules/client/back/methods/client/specs/getCard.spec.js +++ b/modules/client/back/methods/client/specs/getCard.spec.js @@ -7,6 +7,6 @@ describe('Client get', () => { expect(result.id).toEqual(101); expect(result.name).toEqual('Bruce Wayne'); - expect(result.debt).toEqual(-111.86); + expect(result.debt).toEqual(-101.85); }); }); diff --git a/modules/client/back/methods/client/specs/getDebt.spec.js b/modules/client/back/methods/client/specs/getDebt.spec.js index a50422c8f..84c6d2907 100644 --- a/modules/client/back/methods/client/specs/getDebt.spec.js +++ b/modules/client/back/methods/client/specs/getDebt.spec.js @@ -4,7 +4,7 @@ describe('client getDebt()', () => { it('should return the client debt', async() => { let result = await app.models.Client.getDebt(101); - expect(result.debt).toEqual(-111.86); + expect(result.debt).toEqual(-101.85); }); }); diff --git a/modules/client/back/methods/client/specs/summary.spec.js b/modules/client/back/methods/client/specs/summary.spec.js index 67fe35e4c..74b38f693 100644 --- a/modules/client/back/methods/client/specs/summary.spec.js +++ b/modules/client/back/methods/client/specs/summary.spec.js @@ -17,7 +17,7 @@ describe('client summary()', () => { it('should return a summary object containing debt', async() => { let result = await app.models.Client.summary(101); - expect(result.debt.debt).toEqual(-111.86); + expect(result.debt.debt).toEqual(-101.85); }); it('should return a summary object containing averageInvoiced', async() => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js index 1fba84cbd..0d272a81d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js @@ -2,37 +2,35 @@ const app = require('vn-loopback/server/server'); describe('invoiceOut delete()', () => { const invoiceOutId = 2; - let OriginalInvoiceOut; - let OriginalTickets; + let originalInvoiceOut; + let originalTicket; + afterAll(async done => { - const newInvoiceOut = await app.models.InvoiceOut.create(OriginalInvoiceOut); - await newInvoiceOut.updateAttribute('ref', OriginalInvoiceOut.ref); + const newInvoiceOut = await app.models.InvoiceOut.create(originalInvoiceOut); + await newInvoiceOut.updateAttribute('ref', originalInvoiceOut.ref); const promises = []; - OriginalTickets.forEach(ticket => { - promises.push(ticket.updateAttribute('refFk', newInvoiceOut.ref)); - }); + promises.push(originalTicket.updateAttribute('refFk', newInvoiceOut.ref)); Promise.all(promises); done(); }); - it('should check that there is two tickets from the invoice id 2', async() => { + it('should check that there is one ticket in the target invoiceOut', async() => { const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId); const tickets = await app.models.Ticket.find({where: {refFk: invoiceOut.ref}}); - expect(tickets.length).toEqual(2); - expect(tickets[0].id).toEqual(2); + expect(tickets.length).toEqual(1); + expect(tickets[0].id).toEqual(3); }); - it(`should check the two tickets from the invoice id 2 that are not invoiced`, async() => { - OriginalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId); + it(`should delete the target invoiceOut then check the ticket doesn't have a refFk anymore`, async() => { + originalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId); await app.models.InvoiceOut.delete(invoiceOutId); - OriginalTickets = await app.models.Ticket.find({where: {id: {inq: [2, 3]}}}); - const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId); + originalTicket = await app.models.Ticket.findById(3); + const deletedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId); - expect(OriginalTickets[0].refFk).toBeNull(); - expect(OriginalTickets[1].refFk).toBeNull(); - expect(invoiceOut).toBeNull(); + expect(deletedInvoiceOut).toBeNull(); + expect(originalTicket.refFk).toBeNull(); }); }); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js index b959a0829..c3a009dde 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js @@ -58,8 +58,8 @@ describe('InvoiceOut filter()', () => { it('should return the invoice out matching min and max', async() => { let ctx = { args: { - min: 20.10, - max: 200, + min: 100, + max: 300, } }; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js index c1b90c7a7..1b1b84d15 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js @@ -8,26 +8,26 @@ describe('invoiceOut summary()', () => { }); it(`should return a summary object containing data from it's tickets`, async() => { - const result = await app.models.InvoiceOut.summary(1); - const tickets = result.invoiceOut.tickets(); + const summary = await app.models.InvoiceOut.summary(1); + const tickets = summary.invoiceOut.tickets(); - expect(result.invoiceOut.ref).toEqual('T1111111'); - expect(tickets.length).toEqual(1); + expect(summary.invoiceOut.ref).toEqual('T1111111'); + expect(tickets.length).toEqual(2); }); it(`should return a summary object containing it's supplier country`, async() => { - const result = await app.models.InvoiceOut.summary(1); - const supplier = result.invoiceOut.supplier(); + const summary = await app.models.InvoiceOut.summary(1); + const supplier = summary.invoiceOut.supplier(); - expect(result.invoiceOut.ref).toEqual('T1111111'); + expect(summary.invoiceOut.ref).toEqual('T1111111'); expect(supplier.id).toEqual(442); expect(supplier.countryFk).toEqual(1); }); it(`should return a summary object containing idata from it's tax types`, async() => { - const result = await app.models.InvoiceOut.summary(1); + const summary = await app.models.InvoiceOut.summary(1); - expect(result.invoiceOut.ref).toEqual('T1111111'); - expect(result.invoiceOut.taxesBreakdown.length).toEqual(2); + expect(summary.invoiceOut.ref).toEqual('T1111111'); + expect(summary.invoiceOut.taxesBreakdown.length).toEqual(2); }); }); diff --git a/modules/route/back/methods/route/specs/filter.spec.js b/modules/route/back/methods/route/specs/filter.spec.js index a1ccfb86e..e0238af40 100644 --- a/modules/route/back/methods/route/specs/filter.spec.js +++ b/modules/route/back/methods/route/specs/filter.spec.js @@ -51,7 +51,7 @@ describe('Route filter()', () => { let result = await app.models.Route.filter(ctx); - expect(result.length).toEqual(2); + expect(result.length).toEqual(4); }); it('should return the routes matching "description"', async() => { diff --git a/modules/ticket/back/methods/sale/specs/priceDifference.spec.js b/modules/ticket/back/methods/sale/specs/priceDifference.spec.js index 165b8858c..73825d580 100644 --- a/modules/ticket/back/methods/sale/specs/priceDifference.spec.js +++ b/modules/ticket/back/methods/sale/specs/priceDifference.spec.js @@ -7,18 +7,18 @@ describe('sale priceDifference()', () => { tomorrow.setDate(tomorrow.getDate() + 1); let data = { landed: tomorrow, - addressFk: 121, + addressFk: 122, agencyModeFk: 7, warehouseFk: 1 }; let result = await app.models.Sale.priceDifference(11, data); - expect(result.totalUnitPrice).toEqual(4.03); + expect(result.totalUnitPrice).toEqual(4.13); expect(result.totalNewPrice).toEqual(4.13); expect(result.totalDifference).toEqual(0); }); - it('should return an error if the ticket state is not valid for modifications', async() => { + it('should return an error if the ticket is not editable', async() => { let error; let data = { landed: new Date(), @@ -35,4 +35,3 @@ describe('sale priceDifference()', () => { expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`)); }); }); - diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index d8b5dbfc5..4e4d70efc 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -5,22 +5,26 @@ describe('sale updatePrice()', () => { let originalSalesPersonMana; let createdSaleComponent; let saleId = 7; - - afterAll(async done => { - await originalSale.save(); - await app.models.SaleComponent.updateAll({componentFk: 37, saleFk: saleId}, {value: 0}); - await originalSalesPersonMana.save(); - - done(); - }); + let manaComponentId; beforeAll(async done => { + let componentRate = await app.models.ComponentRate.findOne({where: {code: 'mana'}}); + manaComponentId = componentRate.id; originalSale = await app.models.Sale.findById(saleId); originalSalesPersonMana = await app.models.WorkerMana.findById(18); done(); }); + afterAll(async done => { + await originalSale.save(); + await app.models.SaleComponent.updateAll({componentFk: manaComponentId, saleFk: saleId}, {value: 0}); + await originalSalesPersonMana.save(); + + done(); + }); + + it('should throw an error if the ticket is not editable', async() => { let immutableSaleId = 1; let price = 5; @@ -54,14 +58,13 @@ describe('sale updatePrice()', () => { it('should set price as a decimal number and check the sale has the mana component', async() => { let price = 5.5; - let manaComponentId = 37; await app.models.Sale.updatePrice(saleId, price); let saleUpdated = await app.models.Sale.findById(saleId); createdSaleComponent = await app.models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponentId}}); expect(saleUpdated.price).toEqual(5.5); - expect(createdSaleComponent.value).toEqual(4.48); + expect(createdSaleComponent.value).toEqual(4.43); }); it('should check that the mana of salesPerson changed', async() => { diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 2a70bcfa6..adffdd365 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -26,20 +26,20 @@ module.exports = function(Self) { Self.makeInvoice = async(ctx, id) => { let userId = ctx.req.accessToken.userId; - let $ = Self.app.models; + let models = Self.app.models; let tx = await Self.beginTransaction({}); try { let options = {transaction: tx}; let filter = {fields: ['id', 'clientFk', 'companyFk']}; - let ticket = await $.Ticket.findById(id, filter, options); + let ticket = await models.Ticket.findById(id, filter, options); - let clientCanBeInvoiced = await $.Client.canBeInvoiced(ticket.clientFk); + let clientCanBeInvoiced = await models.Client.canBeInvoiced(ticket.clientFk); if (!clientCanBeInvoiced) throw new UserError(`This client can't be invoiced`); - let ticketCanBeInvoiced = await $.Ticket.canBeInvoiced(ticket.id); + let ticketCanBeInvoiced = await models.Ticket.canBeInvoiced(ticket.id); if (!ticketCanBeInvoiced) throw new UserError(`This ticket can't be invoiced`); @@ -64,7 +64,7 @@ module.exports = function(Self) { await Self.rawSql(query, [invoice], options); } - let user = await $.Worker.findOne({where: {userFk: userId}}, options); + let user = await models.Worker.findOne({where: {userFk: userId}}, options); query = `INSERT INTO printServerQueue(reportFk, param1, workerFk) VALUES (?, ?, ?)`; await Self.rawSql(query, [3, invoice, user.id], options); diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index 9be919689..d57681269 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -22,8 +22,8 @@ module.exports = Self => { }); Self.new = async(ctx, params, options) => { - let $ = Self.app.models; - let address = await $.Address.findOne({ + let models = Self.app.models; + let address = await models.Address.findOne({ where: {id: params.addressFk}, fields: ['id', 'clientFk'], include: [ @@ -42,7 +42,7 @@ module.exports = Self => { let agencyMode; if (params && params.agencyModeFk) - agencyMode = await $.AgencyMode.findById(params.agencyModeFk); + agencyMode = await models.AgencyMode.findById(params.agencyModeFk); if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) { if (address.client().isFreezed) @@ -64,7 +64,7 @@ module.exports = Self => { try { if (!params.shipped && params.landed) { - params.shipped = await $.Agency.getShipped(ctx, { + params.shipped = await models.Agency.getShipped(ctx, { landed: params.landed, addressFk: address.id, agencyModeFk: params.agencyModeFk, @@ -73,7 +73,7 @@ module.exports = Self => { } if (params.shipped && !params.landed) { - const landedResult = await $.Agency.getLanded(ctx, { + const landedResult = await models.Agency.getLanded(ctx, { shipped: params.shipped, addressFk: address.id, agencyModeFk: params.agencyModeFk, @@ -99,7 +99,7 @@ module.exports = Self => { params.userId ], options); - let ticket = await $.Ticket.findById(result[1][0].newTicketId, null, options); + let ticket = await models.Ticket.findById(result[1][0].newTicketId, null, options); let cleanInstance = JSON.parse(JSON.stringify(ticket)); let logRecord = { @@ -112,7 +112,7 @@ module.exports = Self => { newInstance: cleanInstance }; - await $.TicketLog.create(logRecord, options); + await models.TicketLog.create(logRecord, options); if (tx) await tx.commit(); return await ticket; diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 0d27d69b3..347ee9e7e 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -1,19 +1,23 @@ const app = require('vn-loopback/server/server'); describe('ticket componentUpdate()', () => { - let firstvalueBeforeChange; - let secondvalueBeforeChange; - let componentOfSaleSeven = `SELECT value FROM vn.saleComponent - WHERE saleFk = 7 AND componentFk = 15`; - - let componentOfSaleEight = `SELECT value FROM vn.saleComponent - WHERE saleFk = 8 AND componentFk = 15`; + const ticketId = 11; const today = new Date(); const tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); - let ticketId = 11; + + let deliveryComponentId; + let firstvalueBeforeChange; + let secondvalueBeforeChange; + let componentOfSaleSeven; + let componentOfSaleEight; beforeAll(async done => { + let deliveryComponenet = await app.models.ComponentRate.findOne({where: {code: 'delivery'}}); + deliveryComponentId = deliveryComponenet.id; + componentOfSaleSeven = `SELECT value FROM vn.saleComponent WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`; + componentOfSaleEight = `SELECT value FROM vn.saleComponent WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`; + [componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven); firstvalueBeforeChange = componentValue.value; @@ -25,9 +29,9 @@ describe('ticket componentUpdate()', () => { it('should change the agencyMode to modify the sale components value', async() => { let data = { - clientFk: 101, + clientFk: 102, agencyModeFk: 8, - addressFk: 121, + addressFk: 122, warehouseFk: 1, companyFk: 442, shipped: today, @@ -53,9 +57,9 @@ describe('ticket componentUpdate()', () => { it('should change the agencyMode to go back to the originals sale components value', async() => { let data = { - clientFk: 101, + clientFk: 102, agencyModeFk: 7, - addressFk: 121, + addressFk: 122, warehouseFk: 1, companyFk: 442, shipped: today, diff --git a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js index 1ccc4560c..328de4827 100644 --- a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js +++ b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js @@ -1,25 +1,25 @@ const app = require('vn-loopback/server/server'); describe('ticket isEditable()', () => { - it('should return false if the ticket given is not editable', async() => { + it('should return false if the given ticket is not editable', async() => { let result = await app.models.Ticket.isEditable(2); expect(result).toEqual(false); }); - it('should return false if the ticket given does not exist', async() => { + it('should return false if the given ticket does not exist', async() => { let result = await app.models.Ticket.isEditable(99999); expect(result).toEqual(false); }); - it('should return false if the ticket given isDeleted', async() => { - let result = await app.models.Ticket.isEditable(21); + it('should return false if the given ticket isDeleted', async() => { + let result = await app.models.Ticket.isEditable(19); expect(result).toEqual(false); }); - it('should return true if the ticket given is editable', async() => { + it('should return true if the given ticket is editable', async() => { let result = await app.models.Ticket.isEditable(16); expect(result).toEqual(true); diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index b9c14f4d3..6725c379a 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -2,6 +2,7 @@ const app = require('vn-loopback/server/server'); describe('ticket makeInvoice()', () => { let invoice; + let ticketId = 11; afterAll(async done => { let ticket = await app.models.Ticket.findById(11); @@ -18,8 +19,7 @@ describe('ticket makeInvoice()', () => { it('should invoice a ticket', async() => { let ctx = {req: {accessToken: {userId: 9}}}; - let ticketFk = 11; - invoice = await app.models.Ticket.makeInvoice(ctx, ticketFk); + invoice = await app.models.Ticket.makeInvoice(ctx, ticketId); expect(invoice.invoiceFk).not.toBeNaN(); expect(invoice.serial).toEqual('T'); @@ -27,10 +27,9 @@ describe('ticket makeInvoice()', () => { it('should not invoice an already invoiced ticket', async() => { let ctx = {req: {accessToken: {userId: 9}}}; - let ticketFk = 11; let error; - await app.models.Ticket.makeInvoice(ctx, ticketFk).catch(e => { + await app.models.Ticket.makeInvoice(ctx, ticketId).catch(e => { error = e; }).finally(() => { expect(error.message).toEqual(`This ticket can't be invoiced`); diff --git a/modules/ticket/back/methods/ticket/threeLastActive.js b/modules/ticket/back/methods/ticket/threeLastActive.js index 2966514a4..fa4eab99d 100644 --- a/modules/ticket/back/methods/ticket/threeLastActive.js +++ b/modules/ticket/back/methods/ticket/threeLastActive.js @@ -20,7 +20,7 @@ module.exports = Self => { Self.threeLastActive = async params => { let query = ` - SELECT t.id,t.shipped,a.name AS agencyName,w.name AS warehouseName + SELECT t.id, t.shipped, a.name AS agencyName, w.name AS warehouseName FROM vn.ticket t JOIN vn.ticketState ts ON t.id = ts.ticketFk JOIN vn.agencyMode a ON t.agencyModeFk = a.id