From 83943cd66f446c7039818e4760f76c09042c7fa4 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 27 Feb 2020 07:17:09 +0100 Subject: [PATCH 01/16] 2053 e2e ticket request --- e2e/helpers/selectors.js | 8 ++-- e2e/paths/05-ticket/10_request.spec.js | 54 +++++++++++++++++++------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 563b8d89a..7e3e726e4 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -511,14 +511,16 @@ export default { }, ticketRequests: { addRequestButton: 'vn-ticket-request-index > a > vn-float-button > button', - request: 'vn-ticket-request-index vn-table vn-tr', descriptionInput: 'vn-ticket-request-create [ng-model="$ctrl.ticketRequest.description"]', atender: 'vn-ticket-request-create vn-autocomplete[ng-model="$ctrl.ticketRequest.attenderFk"]', quantity: 'vn-ticket-request-create vn-input-number[ng-model="$ctrl.ticketRequest.quantity"]', price: 'vn-ticket-request-create vn-input-number[ng-model="$ctrl.ticketRequest.price"]', - firstRemoveRequestButton: 'vn-ticket-request-index vn-icon[icon="delete"]:nth-child(1)', + firstRequestQuantity: 'vn-ticket-request-index vn-table vn-tr:nth-child(1) > vn-td:nth-child(6) vn-input-number', + secondRequestQuantity: 'vn-ticket-request-index vn-table vn-tr:nth-child(2) > vn-td:nth-child(6) vn-input-number', + thirdDescription: 'vn-ticket-request-index vn-table vn-tr:nth-child(3) > vn-td:nth-child(2) vn-textfield', + thirdRemoveRequestButton: 'vn-ticket-request-index vn-tr:nth-child(3) vn-icon[icon="delete"]', + thirdRequestQuantity: 'vn-ticket-request-index vn-table vn-tr:nth-child(3) > vn-td:nth-child(6) vn-input-number', saveButton: 'vn-ticket-request-create button[type=submit]', - firstDescription: 'vn-ticket-request-index vn-table vn-tr:nth-child(1) > vn-td:nth-child(2) vn-textfield', }, ticketLog: { diff --git a/e2e/paths/05-ticket/10_request.spec.js b/e2e/paths/05-ticket/10_request.spec.js index ce2c3a324..f4c4c4abe 100644 --- a/e2e/paths/05-ticket/10_request.spec.js +++ b/e2e/paths/05-ticket/10_request.spec.js @@ -9,7 +9,7 @@ describe('Ticket purchase request path', () => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('salesPerson', 'ticket'); - await page.accessToSearchResult('16'); + await page.accessToSearchResult('1'); await page.accessToSection('ticket.card.request.index'); }); @@ -17,10 +17,10 @@ describe('Ticket purchase request path', () => { await browser.close(); }); - it(`should add a new request`, async() => { + it('should add a new request', async() => { await page.waitToClick(selectors.ticketRequests.addRequestButton); await page.write(selectors.ticketRequests.descriptionInput, 'New stuff'); - await page.write(selectors.ticketRequests.quantity, '99'); + await page.write(selectors.ticketRequests.quantity, '9'); await page.autocompleteSearch(selectors.ticketRequests.atender, 'buyerNick'); await page.write(selectors.ticketRequests.price, '999'); await page.waitToClick(selectors.ticketRequests.saveButton); @@ -29,29 +29,53 @@ describe('Ticket purchase request path', () => { expect(result).toEqual('Data saved!'); }); - it(`should have been redirected to the request index`, async() => { + it('should have been redirected to the request index', async() => { let url = await page.expectURL('/request'); expect(url).toBe(true); }); - it(`should confirm the new request was added`, async() => { - await page.reloadSection('ticket.card.request.index'); - const result = await page.waitToGetProperty(selectors.ticketRequests.firstDescription, 'value'); - - expect(result).toEqual('New stuff'); - }); - - it(`should delete the added request`, async() => { - await page.waitToClick(selectors.ticketRequests.firstRemoveRequestButton); + it(`should edit the third request quantity as it's state is still new`, async() => { + // await page.clearInput(selectors.ticketRequests.thirdRequestQuantity); // clear input performs a post. is this intended? + await page.waitForContentLoaded(); + await page.write(selectors.ticketRequests.thirdRequestQuantity, '9'); + await page.keyboard.press('Enter'); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); - it(`should confirm the request was deleted`, async() => { + it('should confirm the new request was added', async() => { + await page.reloadSection('ticket.card.request.index'); + const result = await page.waitToGetProperty(selectors.ticketRequests.thirdRequestQuantity, 'value'); + + expect(result).toEqual('99'); + }); + + it(`should confirm first request can't be edited as its state is different to new`, async() => { + await page.waitForClassPresent(selectors.ticketRequests.firstRequestQuantity, 'disabled'); + const result = await page.isDisabled(selectors.ticketRequests.firstRequestQuantity); + + expect(result).toBe(true); + }); + + it(`should confirm second request can't be edited as its state is different to new`, async() => { + await page.waitForClassPresent(selectors.ticketRequests.secondRequestQuantity, 'disabled'); + const result = await page.isDisabled(selectors.ticketRequests.secondRequestQuantity); + + expect(result).toBe(true); + }); + + it('should delete the added request', async() => { + await page.waitToClick(selectors.ticketRequests.thirdRemoveRequestButton); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should confirm the request was deleted', async() => { await page.reloadSection('ticket.card.request.index'); await page.wait(selectors.ticketRequests.addRequestButton); - await page.waitForSelector(selectors.ticketRequests.request, {hidden: true}); + await page.waitForSelector(selectors.ticketRequests.thirdDescription, {hidden: true}); }); }); From 6b8915a882f04bde7d422db39b8ac5f3af0dcbaf Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 27 Feb 2020 08:07:25 +0100 Subject: [PATCH 02/16] removed a commented line --- e2e/paths/05-ticket/10_request.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/paths/05-ticket/10_request.spec.js b/e2e/paths/05-ticket/10_request.spec.js index f4c4c4abe..fd4231809 100644 --- a/e2e/paths/05-ticket/10_request.spec.js +++ b/e2e/paths/05-ticket/10_request.spec.js @@ -36,7 +36,6 @@ describe('Ticket purchase request path', () => { }); it(`should edit the third request quantity as it's state is still new`, async() => { - // await page.clearInput(selectors.ticketRequests.thirdRequestQuantity); // clear input performs a post. is this intended? await page.waitForContentLoaded(); await page.write(selectors.ticketRequests.thirdRequestQuantity, '9'); await page.keyboard.press('Enter'); From a86c7c9b8a6b1bbbdd3328f07fff1857710be4da Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 26 Feb 2020 14:45:47 +0100 Subject: [PATCH 03/16] updated unit tests --- .../client/front/sample/create/index.spec.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/client/front/sample/create/index.spec.js b/modules/client/front/sample/create/index.spec.js index da9a557f1..d3817a439 100644 --- a/modules/client/front/sample/create/index.spec.js +++ b/modules/client/front/sample/create/index.spec.js @@ -107,7 +107,7 @@ describe('Client', () => { expect(controller.$http.get).not.toHaveBeenCalled(); }); - it(`should perform an HTTP query without passing companyId param`, () => { + it(`should perform an HTTP query without passing companyFk param`, () => { controller.$.sampleType.selection = { hasCompany: false, code: 'MyReport' @@ -116,25 +116,34 @@ describe('Client', () => { clientId: 101, recipient: 'client@email.com' }; + const expectedParams = { + clientId: 101, + recipient: 'client@email.com' + }; + const serializedParams = $httpParamSerializer(expectedParams); - const serializedParams = $httpParamSerializer(controller.clientSample); $httpBackend.expect('GET', `email/MyReport?${serializedParams}`).respond(true); controller.send(false, () => {}); $httpBackend.flush(); }); - it(`should perform an HTTP query passing companyId param`, () => { + it(`should perform an HTTP query passing companyFk param`, () => { controller.$.sampleType.selection = { hasCompany: true, code: 'MyReport' }; controller.clientSample = { + clientId: 101, + recipient: 'client@email.com', + companyFk: 442 + }; + const expectedParams = { clientId: 101, recipient: 'client@email.com', companyId: 442 }; + const serializedParams = $httpParamSerializer(expectedParams); - const serializedParams = $httpParamSerializer(controller.clientSample); $httpBackend.expect('GET', `email/MyReport?${serializedParams}`).respond(true); controller.send(false, () => {}); $httpBackend.flush(); From 05d038fa99147f246e0e08d2de0eaccfbeaa5322 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 27 Feb 2020 08:38:35 +0100 Subject: [PATCH 04/16] custom eslint rules updated --- .eslintrc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.eslintrc.yml b/.eslintrc.yml index 163ff22a7..380cf915b 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -32,3 +32,5 @@ rules: indent: [error, 4] arrow-parens: [error, as-needed] jasmine/no-focused-tests: 0 + no-multiple-empty-lines: ["error", { "max": 1, "maxEOF": 1 }] + space-in-parens: ["error", "never"] \ No newline at end of file From 70210e87c9ae50310aacb901565ac54728142a7e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 27 Feb 2020 09:03:36 +0100 Subject: [PATCH 05/16] Advanced filter by ref --- modules/travel/back/methods/travel/filter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index ecf152b0c..bfe49c834 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -63,6 +63,10 @@ module.exports = Self => { type: 'Number', description: 'The totalEntries filter', http: {source: 'query'} + }, { + arg: 'ref', + type: 'string', + description: 'The reference' } ], returns: { @@ -82,7 +86,7 @@ module.exports = Self => { case 'search': return {'t.id': value}; case 'ref': - return {[param]: {regexp: value}}; + return {'t.ref': {like: `%${value}%`}}; case 'shippedFrom': return {'t.shipped': {gte: value}}; case 'shippedTo': From 262e0cd44708b0ac57978b4ca2f85c961fba7004 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 27 Feb 2020 10:58:58 +0100 Subject: [PATCH 06/16] fix --- e2e/paths/02-client/05_add_address.spec.js | 4 ++-- e2e/paths/05-ticket/10_request.spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index e8c6120f8..737d6b05b 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -70,13 +70,13 @@ describe('Client Add address path', () => { }); it(`should confirm the new address exists and it's the default one`, async() => { + await page.waitFor(2000); // needs more than a single second to load the section const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText'); expect(result).toContain('320 Park Avenue New York'); }); - it(`should click on the make default icon of the second address`, async() => { - await page.waitForContentLoaded(); + it('should click on the make default icon of the second address', async() => { await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar); const result = await page.waitForLastSnackbar(); diff --git a/e2e/paths/05-ticket/10_request.spec.js b/e2e/paths/05-ticket/10_request.spec.js index fd4231809..737d69048 100644 --- a/e2e/paths/05-ticket/10_request.spec.js +++ b/e2e/paths/05-ticket/10_request.spec.js @@ -36,7 +36,7 @@ describe('Ticket purchase request path', () => { }); it(`should edit the third request quantity as it's state is still new`, async() => { - await page.waitForContentLoaded(); + await page.waitFor(2000); // looks like it needs more than a single second some times to load await page.write(selectors.ticketRequests.thirdRequestQuantity, '9'); await page.keyboard.press('Enter'); const result = await page.waitForLastSnackbar(); From 893b634d3390e0729921ea3dc949f567619d3055 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Feb 2020 08:37:37 +0100 Subject: [PATCH 07/16] Get phone from address and client --- .../back/methods/client/createAddress.js | 26 +++++++------- .../back/methods/client/updateAddress.js | 24 ++++++------- .../back/methods/client/updateFiscalData.js | 36 +++++++++---------- modules/client/front/descriptor/index.js | 5 +-- modules/ticket/front/card/index.js | 4 ++- modules/ticket/front/descriptor/index.js | 4 ++- modules/ticket/front/sale/index.js | 5 ++- 7 files changed, 56 insertions(+), 48 deletions(-) diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index 0319fc386..1a086b124 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -5,60 +5,60 @@ module.exports = function(Self) { description: 'Creates client address updating default address', accepts: [{ arg: 'id', - type: 'Number', + type: 'number', description: 'The client id', http: {source: 'path'} }, { arg: 'nickname', - type: 'String', + type: 'string', required: true }, { arg: 'city', - type: 'String', + type: 'string', required: true }, { arg: 'street', - type: 'String', + type: 'string', required: true }, { arg: 'phone', - type: 'String' + type: 'string' }, { arg: 'mobile', - type: 'String' + type: 'string' }, { arg: 'postalCode', - type: 'String' + type: 'string' }, { arg: 'provinceId', - type: 'Number' + type: 'number' }, { arg: 'agencyModeId', - type: 'Number' + type: 'number' }, { arg: 'incotermsId', - type: 'String' + type: 'string' }, { arg: 'customsAgentId', - type: 'Number' + type: 'number' }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isDefaultAddress', - type: 'Boolean' + type: 'boolean' }], returns: { root: true, diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index b9270600f..aa0a7d178 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -10,55 +10,55 @@ module.exports = function(Self) { }, { arg: 'clientId', - type: 'Number', + type: ['number', 'null'], description: 'The client id', http: {source: 'path'} }, { arg: 'addressId', - type: 'Number', + type: ['number', 'null'], description: 'The address id', http: {source: 'path'} }, { arg: 'nickname', - type: 'String' + type: ['string'] }, { arg: 'city', - type: 'String' + type: ['string'] }, { arg: 'street', - type: 'String' + type: ['string'] }, { arg: 'phone', - type: 'String' + type: 'any' }, { arg: 'mobile', - type: 'String' + type: 'any' }, { arg: 'postalCode', - type: 'String' + type: 'any' }, { arg: 'provinceFk', - type: 'Number' + type: 'any' }, { arg: 'agencyModeFk', - type: 'Number' + type: 'any' }, { arg: 'incotermsFk', - type: 'String' + type: 'any' }, { arg: 'customsAgentFk', - type: 'Number' + type: 'any' }, { arg: 'isActive', diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 4bc6fda9b..f16b0ef2b 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -17,75 +17,75 @@ module.exports = Self => { }, { arg: 'socialName', - type: 'String' + type: 'string' }, { arg: 'fi', - type: 'String' + type: 'string' }, { arg: 'street', - type: 'String' + type: 'string' }, { arg: 'postcode', - type: 'String' + type: 'string' }, { arg: 'city', - type: 'String' + type: 'string' }, { arg: 'countryFk', - type: 'Number' + type: 'number' }, { arg: 'provinceFk', - type: 'Number' + type: 'number' }, { arg: 'hasToInvoiceByAddress', - type: 'Boolean' + type: 'boolean' }, { arg: 'hasToInvoice', - type: 'Boolean' + type: 'boolean' }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isFreezed', - type: 'Boolean' + type: 'boolean' }, { arg: 'isVies', - type: 'Boolean' + type: 'boolean' }, { arg: 'isToBeMailed', - type: 'Boolean' + type: 'boolean' }, { arg: 'isEqualizated', - type: 'Boolean' + type: 'boolean' }, { arg: 'isTaxDataVerified', - type: 'Boolean' + type: 'boolean' }, { arg: 'isTaxDataChecked', - type: 'Boolean' + type: 'boolean' }, { arg: 'despiteOfClient', - type: 'Number' + type: 'number' }], returns: { arg: 'res', - type: 'String', + type: 'string', root: true }, http: { diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 3ef1e7616..95754b4df 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -55,10 +55,11 @@ class Controller extends Component { } showSMSDialog() { - const phone = this.$params.phone || this.client.phone; + const client = this.client; + const phone = this.$params.phone || client.mobile || client.phone; const message = this.$params.message || ''; this.newSMS = { - destinationFk: this.client.id, + destinationFk: client.id, destination: phone, message: message }; diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index 131968d65..3872259a9 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -27,7 +27,9 @@ class Controller extends ModuleCard { 'isFreezed', 'isTaxDataChecked', 'credit', - 'email' + 'email', + 'phone', + 'mobile' ], include: { relation: 'salesPerson', diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index 10da4cca9..d804a2eb2 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -241,7 +241,9 @@ class Controller extends Component { showSMSDialog() { const address = this.ticket.address; - const phone = this.$params.phone || address.mobile; + const client = this.ticket.client; + const phone = this.$params.phone || address.mobile || address.phone || + client.mobile || client.phone; const message = this.$params.message || this.$translate.instant('SMSPayment'); this.newSMS = { destinationFk: this.ticket.clientFk, diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index d0854c996..1ecb6fe41 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -431,6 +431,9 @@ class Controller { showSMSDialog() { const address = this.ticket.address; + const client = this.ticket.client; + const phone = address.mobile || address.phone || + client.mobile || client.phone; const sales = this.checkedLines(); const items = sales.map(sale => { return `${sale.quantity} ${sale.concept}`; @@ -443,7 +446,7 @@ class Controller { }; this.newSMS = { destinationFk: this.ticket.clientFk, - destination: address.mobile || null, + destination: phone, message: this.$translate.instant('SMSAvailability', params) }; this.$scope.sms.open(); From c920f0bc91e456abfeca3af8091ef96ea034d01d Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Feb 2020 09:00:13 +0100 Subject: [PATCH 08/16] Requested changes --- .../client/back/methods/client/updateAddress.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index aa0a7d178..db8ed38d6 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -10,27 +10,27 @@ module.exports = function(Self) { }, { arg: 'clientId', - type: ['number', 'null'], + type: 'number', description: 'The client id', http: {source: 'path'} }, { arg: 'addressId', - type: ['number', 'null'], + type: 'number', description: 'The address id', http: {source: 'path'} }, { arg: 'nickname', - type: ['string'] + type: 'string' }, { arg: 'city', - type: ['string'] + type: 'string' }, { arg: 'street', - type: ['string'] + type: 'string' }, { arg: 'phone', @@ -62,11 +62,11 @@ module.exports = function(Self) { }, { arg: 'isActive', - type: 'Boolean' + type: 'boolean' }, { arg: 'isEqualizated', - type: 'Boolean' + type: 'boolean' }], returns: { root: true, From ccd28114ca226619d68c86ad93a861663c261034 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 27 Feb 2020 12:39:58 +0100 Subject: [PATCH 09/16] Updated unit tests --- modules/travel/back/methods/travel/filter.js | 4 ++- .../back/methods/travel/specs/filter.spec.js | 33 ++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index bfe49c834..4d1be2d0e 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -84,7 +84,9 @@ module.exports = Self => { let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': - return {'t.id': value}; + return /^\d+$/.test(value) + ? {'t.id': value} + : {'t.ref': {like: `%${value}%`}}; case 'ref': return {'t.ref': {like: `%${value}%`}}; case 'shippedFrom': diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index 03849f2b0..d04b0f093 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -2,38 +2,53 @@ const app = require('vn-loopback/server/server'); describe('Travel filter()', () => { it('should return the travel matching "search"', async() => { - let ctx = { + const ctx = { args: { search: 1 } }; - let result = await app.models.Travel.filter(ctx); + const result = await app.models.Travel.filter(ctx); + const firstRow = result[0]; expect(result.length).toEqual(1); - expect(result[0].id).toEqual(1); + expect(firstRow.id).toEqual(1); + }); + + it('should return the travel matching "search" by ref', async() => { + const ctx = { + args: { + search: 'third' + } + }; + + const result = await app.models.Travel.filter(ctx); + const firstRow = result[0]; + + expect(result.length).toEqual(1); + expect(firstRow.id).toEqual(3); }); it('should return the travel matching "warehouse out"', async() => { - let ctx = { + const ctx = { args: { warehouseOutFk: 2 } }; - let result = await app.models.Travel.filter(ctx); + const result = await app.models.Travel.filter(ctx); expect(result.length).toEqual(8); }); it('should return the travel matching "total entries"', async() => { - let ctx = { + const ctx = { args: { totalEntries: 1, } }; - let result = await app.models.Travel.filter(ctx); + const result = await app.models.Travel.filter(ctx); expect(result.length).toEqual(5); }); @@ -44,14 +59,14 @@ describe('Travel filter()', () => { from.setHours(0, 0, 0, 0); to.setHours(23, 59, 59, 999); to.setDate(to.getDate() + 1); - let ctx = { + const ctx = { args: { shippedFrom: from, shippedTo: to } }; - let result = await app.models.Travel.filter(ctx); + const result = await app.models.Travel.filter(ctx); expect(result.length).toEqual(1); }); From 6dcfc340566175e313a52f7d91f593fbf67c9763 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 27 Feb 2020 13:33:40 +0100 Subject: [PATCH 10/16] Fix - Find duplicated client --- modules/client/front/fiscal-data/index.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 98773de75..b2602f7a4 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -24,14 +24,15 @@ export default class Controller extends Component { const filter = encodeURIComponent(JSON.stringify(filterObj)); const query = `Clients/findOne?filter=${filter}`; this.$http.get(query).then(res => { - if (res.data.id) { - const params = {clientId: res.data.id}; - const question = $t('Found a client with this phone or email', params, null, null, 'sanitizeParameters'); + const params = {clientId: res.data.id}; + const question = $t('Found a client with this phone or email', params, null, null, 'sanitizeParameters'); - this.client.despiteOfClient = params.clientId; - this.$.confirmDuplicatedClient.question = question; - this.$.confirmDuplicatedClient.show(); - } + this.client.despiteOfClient = params.clientId; + this.$.confirmDuplicatedClient.question = question; + this.$.confirmDuplicatedClient.show(); + }).catch(error => { + if (error.status == 404) + this.save(); }); } From 442541d0f8c63a7aef48f40da7df442f1a43e2b0 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 28 Feb 2020 07:24:36 +0100 Subject: [PATCH 11/16] Renamed rgb column --- modules/worker/back/models/calendar-holidays-type.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/calendar-holidays-type.json b/modules/worker/back/models/calendar-holidays-type.json index a83dbc13c..178331b87 100644 --- a/modules/worker/back/models/calendar-holidays-type.json +++ b/modules/worker/back/models/calendar-holidays-type.json @@ -14,7 +14,7 @@ "name": { "type": "String" }, - "rgb": { + "hexColour": { "type": "String" } }, From 56b986ff95a2299895f7fd1f9a1ce9cfe61402b5 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 28 Feb 2020 07:26:19 +0100 Subject: [PATCH 12/16] No department error --- back/methods/chat/sendCheckingPresence.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index b2a3ca725..7e74a6980 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -37,7 +37,7 @@ module.exports = Self => { } }); const department = workerDepartment && workerDepartment.department(); - const channelName = department.chatName; + const channelName = department && department.chatName; if (channelName) return Self.send(ctx, `#${channelName}`, `@${account.name} => ${message}`); From a8eea3d8f6a24f6713e3c1790e44eccbaaf56fb1 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 28 Feb 2020 08:19:37 +0100 Subject: [PATCH 13/16] Changed primary key --- modules/worker/back/models/worker-dms.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json index 56cad65a6..f8ad824bc 100644 --- a/modules/worker/back/models/worker-dms.json +++ b/modules/worker/back/models/worker-dms.json @@ -13,10 +13,10 @@ }, "properties": { "id": { - "type": "Number", - "id": true + "type": "Number" }, "dmsFk": { + "id": true, "type": "Number", "required": true, "mysql": { From b0779fb2d363375792e76aa1a42bd0d634d3f79f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 28 Feb 2020 08:24:01 +0100 Subject: [PATCH 14/16] Added error handler --- back/methods/chat/sendCheckingPresence.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 7e74a6980..5a4ee2fcf 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -26,6 +26,10 @@ module.exports = Self => { Self.sendCheckingPresence = async(ctx, workerId, message) => { const models = Self.app.models; const account = await models.Account.findById(workerId); + const userId = ctx.req.accessToken.userId; + + if (!account) + throw new Error(`Could not send message to worker id ${workerId} from user ${userId}`); const query = `SELECT worker_isWorking(?) isWorking`; const [result] = await Self.rawSql(query, [workerId]); From 3739548d0d2e7beeefd4ef11c18e3fd137e9731d Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 28 Feb 2020 08:39:59 +0100 Subject: [PATCH 15/16] Added error handling for worker not found --- back/methods/chat/sendCheckingPresence.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 5a4ee2fcf..f67fb6942 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -29,7 +29,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; if (!account) - throw new Error(`Could not send message to worker id ${workerId} from user ${userId}`); + throw new Error(`Could not send message "${message}" to worker id ${workerId} from user ${userId}`); const query = `SELECT worker_isWorking(?) isWorking`; const [result] = await Self.rawSql(query, [workerId]); From 96d98a6dcca83ee14c560676fc21b2e9816b4b72 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 28 Feb 2020 09:23:02 +0100 Subject: [PATCH 16/16] Added workerId validation --- back/methods/chat/sendCheckingPresence.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index f67fb6942..6fa029b70 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -24,6 +24,8 @@ module.exports = Self => { }); Self.sendCheckingPresence = async(ctx, workerId, message) => { + if (!workerId) return false; + const models = Self.app.models; const account = await models.Account.findById(workerId); const userId = ctx.req.accessToken.userId;