From 4aea2847039d1ba944723eda2a1ba5ffd273def8 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 20 Oct 2020 14:42:23 +0200 Subject: [PATCH 1/6] WIP: a falta de e2e --- .../10230-oktoberFest/00-observationType.sql | 9 +++ loopback/common/models/loggable.js | 3 +- .../back/methods/client/createAddress.js | 37 ++++------- .../client/specs/createAddress.spec.js | 62 ++++++++++++++----- .../client/front/address/create/index.html | 8 +-- modules/client/front/address/create/index.js | 10 +-- .../client/front/address/create/index.spec.js | 12 ++-- .../order/back/methods/order/catalogFilter.js | 2 - .../back/methods/ticket/componentUpdate.js | 45 +++++++++++++- 9 files changed, 128 insertions(+), 60 deletions(-) create mode 100644 db/changes/10230-oktoberFest/00-observationType.sql diff --git a/db/changes/10230-oktoberFest/00-observationType.sql b/db/changes/10230-oktoberFest/00-observationType.sql new file mode 100644 index 000000000..426fa1b55 --- /dev/null +++ b/db/changes/10230-oktoberFest/00-observationType.sql @@ -0,0 +1,9 @@ +ALTER TABLE `vn`.`observationType` +ADD COLUMN `code` VARCHAR(45) NOT NULL AFTER `description`; + +UPDATE `vn`.`observationType` SET `code` = 'itemPicker' WHERE (`id` = '1'); +UPDATE `vn`.`observationType` SET `code` = 'packager' WHERE (`id` = '2'); +UPDATE `vn`.`observationType` SET `code` = 'salesPerson' WHERE (`id` = '4'); +UPDATE `vn`.`observationType` SET `code` = 'administrative' WHERE (`id` = '5'); +UPDATE `vn`.`observationType` SET `code` = 'weight' WHERE (`id` = '6'); +UPDATE `vn`.`observationType` SET `code` = 'delivery' WHERE (`id` = '3'); diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js index eaa44f9ba..258fff4ff 100644 --- a/loopback/common/models/loggable.js +++ b/loopback/common/models/loggable.js @@ -154,7 +154,8 @@ module.exports = function(Self) { const showFieldNames = [ 'name', 'description', - 'code' + 'code', + 'nickname' ]; for (field of showFieldNames) { const propField = properties && properties[field]; diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index 1a086b124..450b16722 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -4,7 +4,7 @@ module.exports = function(Self) { Self.remoteMethodCtx('createAddress', { description: 'Creates client address updating default address', accepts: [{ - arg: 'id', + arg: 'clientFk', type: 'number', description: 'The client id', http: {source: 'path'} @@ -37,19 +37,19 @@ module.exports = function(Self) { type: 'string' }, { - arg: 'provinceId', + arg: 'provinceFk', type: 'number' }, { - arg: 'agencyModeId', + arg: 'agencyModeFk', type: 'number' }, { - arg: 'incotermsId', + arg: 'incotermsFk', type: 'string' }, { - arg: 'customsAgentId', + arg: 'customsAgentFk', type: 'number' }, { @@ -66,44 +66,33 @@ module.exports = function(Self) { }, http: { verb: 'post', - path: '/:id/createAddress' + path: '/:clientFk/createAddress' } }); - Self.createAddress = async(ctx, clientId) => { + Self.createAddress = async(ctx, clientFk) => { const models = Self.app.models; const args = ctx.args; const tx = await models.Address.beginTransaction({}); try { const options = {transaction: tx}; - const province = await models.Province.findById(args.provinceId, { + const province = await models.Province.findById(args.provinceFk, { include: { relation: 'country' } }, options); const isUeeMember = province.country().isUeeMember; - if (!isUeeMember && !args.incotermsId) + if (!isUeeMember && !args.incotermsFk) throw new UserError(`Incoterms is required for a non UEE member`); - if (!isUeeMember && !args.customsAgentId) + if (!isUeeMember && !args.customsAgentFk) throw new UserError(`Customs agent is required for a non UEE member`); - const newAddress = await models.Address.create({ - clientFk: clientId, - nickname: args.nickname, - incotermsFk: args.incotermsId, - customsAgentFk: args.customsAgentId, - city: args.city, - street: args.street, - phone: args.phone, - postalCode: args.postalCode, - provinceFk: args.provinceId, - agencyModeFk: args.agencyModeId, - isActive: args.isActive - }, options); - const client = await Self.findById(clientId, null, options); + delete args.ctx; // Remove unwanted properties + const newAddress = await models.Address.create(args, options); + const client = await Self.findById(clientFk, null, options); if (args.isDefaultAddress) { await client.updateAttributes({ diff --git a/modules/client/back/methods/client/specs/createAddress.spec.js b/modules/client/back/methods/client/specs/createAddress.spec.js index 8b2d1f5e2..be80fb1db 100644 --- a/modules/client/back/methods/client/specs/createAddress.spec.js +++ b/modules/client/back/methods/client/specs/createAddress.spec.js @@ -1,25 +1,25 @@ const app = require('vn-loopback/server/server'); describe('Address createAddress', () => { - const clientId = 101; - const provinceId = 5; - const incotermsId = 'FAS'; + const clientFk = 101; + const provinceFk = 5; + const incotermsFk = 'FAS'; const customAgentOneId = 1; it('should throw a non uee member error if no incoterms is defined', async() => { const expectedResult = 'My edited address'; const ctx = { args: { - provinceId: provinceId, + provinceFk: provinceFk, nickname: expectedResult, street: 'Wall Street', city: 'New York', - customsAgentId: customAgentOneId + customsAgentFk: customAgentOneId } }; try { - await app.models.Client.createAddress(ctx, clientId); + await app.models.Client.createAddress(ctx, clientFk); } catch (e) { err = e; } @@ -32,16 +32,16 @@ describe('Address createAddress', () => { const expectedResult = 'My edited address'; const ctx = { args: { - provinceId: provinceId, + provinceFk: provinceFk, nickname: expectedResult, street: 'Wall Street', city: 'New York', - incotermsId: incotermsId + incotermsFk: incotermsFk } }; try { - await app.models.Client.createAddress(ctx, clientId); + await app.models.Client.createAddress(ctx, clientFk); } catch (e) { err = e; } @@ -51,7 +51,7 @@ describe('Address createAddress', () => { }); it('should verify that client defaultAddressFk is untainted', async() => { - const client = await app.models.Client.findById(clientId); + const client = await app.models.Client.findById(clientFk); expect(client.defaultAddressFk).toEqual(1); }); @@ -59,18 +59,23 @@ describe('Address createAddress', () => { it('should create a new address and set as a client default address', async() => { const ctx = { args: { - provinceId: 1, + clientFk: 101, + provinceFk: 1, nickname: 'My address', street: 'Wall Street', city: 'New York', - incotermsId: incotermsId, - customsAgentId: customAgentOneId, + phone: 678678678, + mobile: 678678678, + postalCode: 46680, + agencyModeFk: 1, + incotermsFk: incotermsFk, + customsAgentFk: customAgentOneId, isDefaultAddress: true } }; - const address = await app.models.Client.createAddress(ctx, clientId); - const client = await app.models.Client.findById(clientId); + const address = await app.models.Client.createAddress(ctx, clientFk); + const client = await app.models.Client.findById(clientFk); expect(client.defaultAddressFk).toEqual(address.id); @@ -78,4 +83,31 @@ describe('Address createAddress', () => { await client.updateAttributes({defaultAddressFk: 1}); await address.destroy(); }); + + it('should create a new address and set all properties', async() => { + const ctx = { + args: { + clientFk: 101, + provinceFk: 1, + nickname: 'My address', + street: 'Wall Street', + city: 'New York', + phone: '678678678', + mobile: '678678678', + postalCode: '46680', + agencyModeFk: 1, + incotermsFk: incotermsFk, + customsAgentFk: customAgentOneId, + isDefaultAddress: true + } + }; + + address = await app.models.Client.createAddress(ctx, clientFk); + + expect(address.__data).toEqual(jasmine.objectContaining(ctx.args)); + // restores + const client = await app.models.Client.findById(clientFk); + await client.updateAttributes({defaultAddressFk: 1}); + await address.destroy(); + }); }); diff --git a/modules/client/front/address/create/index.html b/modules/client/front/address/create/index.html index d6b5bcf8e..8e882adc7 100644 --- a/modules/client/front/address/create/index.html +++ b/modules/client/front/address/create/index.html @@ -88,7 +88,7 @@ this.address.customsAgentId = res.data.id); + .then(res => this.address.customsAgentFk = res.data.id); } get town() { @@ -45,8 +45,8 @@ export default class Controller extends Section { const province = selection.province; const postcodes = selection.postcodes; - if (!this.address.provinceI) - this.address.provinceId = province.id; + if (!this.address.provinceFk) + this.address.provinceFk = province.id; if (postcodes.length === 1) this.address.postalCode = postcodes[0].code; @@ -68,8 +68,8 @@ export default class Controller extends Section { if (!this.address.city) this.address.city = town.name; - if (!this.address.provinceId) - this.address.provinceId = province.id; + if (!this.address.provinceFk) + this.address.provinceFk = province.id; } onResponse(response) { diff --git a/modules/client/front/address/create/index.spec.js b/modules/client/front/address/create/index.spec.js index 1a4340115..b12bc183b 100644 --- a/modules/client/front/address/create/index.spec.js +++ b/modules/client/front/address/create/index.spec.js @@ -54,7 +54,7 @@ describe('Client', () => { }); describe('town() setter', () => { - it(`should set provinceId property`, () => { + it(`should set provinceFk property`, () => { controller.town = { provinceFk: 1, code: 46001, @@ -69,10 +69,10 @@ describe('Client', () => { postcodes: [] }; - expect(controller.address.provinceId).toEqual(1); + expect(controller.address.provinceFk).toEqual(1); }); - it(`should set provinceId property and fill the postalCode if there's just one`, () => { + it(`should set provinceFk property and fill the postalCode if there's just one`, () => { controller.town = { provinceFk: 1, code: 46001, @@ -87,7 +87,7 @@ describe('Client', () => { postcodes: [{code: '46001'}] }; - expect(controller.address.provinceId).toEqual(1); + expect(controller.address.provinceFk).toEqual(1); expect(controller.address.postalCode).toEqual('46001'); }); }); @@ -112,7 +112,7 @@ describe('Client', () => { }; expect(controller.address.city).toEqual('New York'); - expect(controller.address.provinceId).toEqual(1); + expect(controller.address.provinceFk).toEqual(1); }); }); @@ -123,7 +123,7 @@ describe('Client', () => { controller.onCustomAgentAccept(); $httpBackend.flush(); - expect(controller.address.customsAgentId).toEqual(1); + expect(controller.address.customsAgentFk).toEqual(1); }); }); }); diff --git a/modules/order/back/methods/order/catalogFilter.js b/modules/order/back/methods/order/catalogFilter.js index 8c98317bd..23414372f 100644 --- a/modules/order/back/methods/order/catalogFilter.js +++ b/modules/order/back/methods/order/catalogFilter.js @@ -190,8 +190,6 @@ module.exports = Self => { item.prices.push(price); else item.prices = [price]; - - item.available = price.grouping; } }); }); diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 15cfa0597..b295315c8 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -88,9 +88,29 @@ module.exports = Self => { if (!zoneShipped || zoneShipped.zoneFk != zoneFk) throw new UserError(`You don't have privileges to change the zone`); } - const originalTicket = await models.Ticket.findById(id, {fields: - ['id', 'clientFk', 'agencyModeFk', 'addressFk', 'zoneFk', - 'warehouseFk', 'companyFk', 'shipped', 'landed', 'isDeleted'] + const observationTypeDelivery = await models.ObservationType.findOne({ + where: {code: 'delivery'} + }); + const originalTicket = await models.Ticket.findOne({ + where: {id: id}, + fields: ['id', 'clientFk', 'agencyModeFk', 'addressFk', 'zoneFk', + 'warehouseFk', 'companyFk', 'shipped', 'landed', 'isDeleted'], + include: [ + { + relation: 'address', + scope: { + include: { + relation: 'observations', + scope: { + where: {observationTypeFk: observationTypeDelivery.id}, + include: { + relation: 'observationType' + + } + } + } + } + }] }); const updatedTicket = Object.assign({}, ctx.args); delete updatedTicket.ctx; @@ -125,6 +145,25 @@ module.exports = Self => { option ]); + if (originalTicket.addressFk != updatedTicket.addressFk) { + const ticketObservation = await models.TicketObservation.findOne({ + where: { + ticketFk: id, + observationTypeFk: observationTypeDelivery.id} + }); + + if (ticketObservation) + await ticketObservation.destroy(); + + const [observation] = originalTicket.address().observations(); + if (observation) { + await models.TicketObservation.upsert({ + ticketFk: id, + observationTypeFk: observation.observationTypeFk, + description: observation.description + }); + } + } await models.TicketLog.create(logRecord); return res; }; -- 2.40.1 From 3c77a5316d6e3e5a2172123f3cc0a842108578d5 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 20 Oct 2020 17:36:02 +0200 Subject: [PATCH 2/6] E2E arreglados --- e2e/helpers/selectors.js | 10 +++++----- e2e/paths/03-worker/05_calendar.spec.js | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index e586f38ed..249dc248e 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -109,19 +109,19 @@ export default { streetAddress: 'vn-textfield[ng-model="$ctrl.address.street"]', postcode: 'vn-datalist[ng-model="$ctrl.address.postalCode"]', city: 'vn-datalist[ng-model="$ctrl.address.city"]', - province: 'vn-autocomplete[ng-model="$ctrl.address.provinceId"]', - agency: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeId"]', + province: 'vn-autocomplete[ng-model="$ctrl.address.provinceFk"]', + agency: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeFk"]', phone: 'vn-textfield[ng-model="$ctrl.address.phone"]', mobileInput: 'vn-textfield[ng-model="$ctrl.address.mobile"]', defaultAddress: 'vn-client-address-index div:nth-child(1) div[name="street"]', - incoterms: 'vn-autocomplete[ng-model="$ctrl.address.incotermsId"]', - addNewCustomsAgent: 'vn-client-address-create vn-autocomplete[ng-model="$ctrl.address.customsAgentId"] vn-icon-button[icon="add_circle"]', + incoterms: 'vn-autocomplete[ng-model="$ctrl.address.incotermsFk"]', + addNewCustomsAgent: 'vn-client-address-create vn-autocomplete[ng-model="$ctrl.address.customsAgentFk"] vn-icon-button[icon="add_circle"]', newCustomsAgentFiscalID: 'vn-textfield[ng-model="$ctrl.newCustomsAgent.nif"]', newCustomsAgentFiscalName: 'vn-textfield[ng-model="$ctrl.newCustomsAgent.fiscalName"]', newCustomsAgentStreet: 'vn-textfield[ng-model="$ctrl.newCustomsAgent.street"]', newCustomsAgentPhone: 'vn-textfield[ng-model="$ctrl.newCustomsAgent.phone"]', saveNewCustomsAgentButton: 'button[response="accept"]', - customsAgent: 'vn-autocomplete[ng-model="$ctrl.address.customsAgentId"]', + customsAgent: 'vn-autocomplete[ng-model="$ctrl.address.customsAgentFk"]', secondMakeDefaultStar: 'vn-client-address-index vn-card div:nth-child(2) vn-icon-button[icon="star_border"]', firstEditAddress: 'vn-client-address-index div:nth-child(1) > a', secondEditAddress: 'vn-client-address-index div:nth-child(2) > a', diff --git a/e2e/paths/03-worker/05_calendar.spec.js b/e2e/paths/03-worker/05_calendar.spec.js index 801ff4151..351ed1ff4 100644 --- a/e2e/paths/03-worker/05_calendar.spec.js +++ b/e2e/paths/03-worker/05_calendar.spec.js @@ -50,6 +50,7 @@ describe('Worker calendar path', () => { await page.waitToClick(selectors.workerCalendar.halfFurlough); await page.waitFor(reasonableTimeBetweenClicks); await page.waitToClick(selectors.workerCalendar.mayEighth); + await page.waitFor(reasonableTimeBetweenClicks); }); it('should check the total holidays increased by 1.5', async() => { -- 2.40.1 From 93ef555dcb682317a49f66a3ecc0cd580082ff4e Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 21 Oct 2020 12:35:31 +0200 Subject: [PATCH 3/6] package --- package-lock.json | 640 ++++++++++++++++++++++++++++------------------ 1 file changed, 398 insertions(+), 242 deletions(-) diff --git a/package-lock.json b/package-lock.json index 944d41637..8ac733d78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3065,6 +3065,74 @@ "minimist": "^1.2.0" } }, + "@eslint/eslintrc": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", + "integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "espree": "^7.3.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "lodash": "^4.17.19", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "debug": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + } + } + }, "@google-cloud/common": { "version": "0.32.1", "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.32.1.tgz", @@ -5450,9 +5518,9 @@ } }, "acorn": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", - "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==", + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, "acorn-globals": { @@ -5474,9 +5542,9 @@ } }, "acorn-jsx": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", - "integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", + "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", "dev": true }, "acorn-walk": { @@ -5546,12 +5614,6 @@ "ansi-wrap": "^0.1.0" } }, - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true - }, "ansi-gray": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", @@ -7479,12 +7541,6 @@ "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true - }, "charenc": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", @@ -7591,21 +7647,6 @@ "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", "dev": true }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "requires": { - "restore-cursor": "^2.0.0" - } - }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", - "dev": true - }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -8857,6 +8898,23 @@ } } }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1" + }, + "dependencies": { + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + } + } + }, "ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", @@ -9028,70 +9086,169 @@ } }, "eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.11.0.tgz", + "integrity": "sha512-G9+qtYVCHaDi1ZuWzBsOWo2wSwd70TXnU6UHA3cTYHp7gCTXZcpggWFoUVAMRarg68qtPoNfFbzPh+VdOgmwmw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", + "@eslint/eslintrc": "^0.1.3", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", - "esquery": "^1.0.1", + "enquirer": "^2.3.5", + "eslint-scope": "^5.1.1", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^2.0.0", + "espree": "^7.3.0", + "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.7.0", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.11", + "levn": "^0.4.1", + "lodash": "^4.17.19", "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", + "optionator": "^0.9.1", "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", "table": "^5.2.3", - "text-table": "^0.2.0" + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" }, "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { - "ms": "^2.1.1" + "color-convert": "^2.0.1" } }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "debug": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } + } + }, + "glob-parent": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" } }, "ms": { @@ -9099,6 +9256,95 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } } } }, @@ -9125,29 +9371,45 @@ } }, "eslint-utils": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", - "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, "requires": { - "eslint-visitor-keys": "^1.0.0" + "eslint-visitor-keys": "^1.1.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + } } }, "eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", + "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", "dev": true }, "espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz", + "integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==", "dev": true, "requires": { - "acorn": "^6.0.7", - "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" + "acorn": "^7.4.0", + "acorn-jsx": "^5.2.0", + "eslint-visitor-keys": "^1.3.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + } } }, "esprima": { @@ -9156,12 +9418,20 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", + "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", "dev": true, "requires": { - "estraverse": "^4.0.0" + "estraverse": "^5.1.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } } }, "esrecurse": { @@ -9564,17 +9834,6 @@ } } }, - "external-editor": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", - "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", - "dev": true, - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", @@ -9776,15 +10035,6 @@ "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==", "dev": true }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, "file-entry-cache": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", @@ -9940,20 +10190,6 @@ "write": "1.0.3" }, "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, "rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -9966,9 +10202,9 @@ } }, "flatted": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", - "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", + "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", "dev": true }, "flush-write-stream": { @@ -12798,9 +13034,9 @@ } }, "import-fresh": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", - "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -12879,44 +13115,6 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, - "inquirer": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.4.1.tgz", - "integrity": "sha512-/Jw+qPZx4EDYsaT6uz7F4GJRNFMRdKNeUZw3ZnKV8lyuUgz/YWRCSUAJMZSVhSq4Ec0R2oYnyi6b3d4JXcL5Nw==", - "dev": true, - "requires": { - "ansi-escapes": "^3.2.0", - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.11", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rxjs": "^6.4.0", - "string-width": "^2.1.0", - "strip-ansi": "^5.1.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, "internal-ip": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-4.3.0.tgz", @@ -13219,12 +13417,6 @@ "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=", "dev": true }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, "is-property": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", @@ -20086,12 +20278,6 @@ "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==", "dev": true }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, "mux-demux": { "version": "3.7.9", "resolved": "http://registry.npmjs.org/mux-demux/-/mux-demux-3.7.9.tgz", @@ -22172,9 +22358,9 @@ } }, "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", + "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", "dev": true }, "regexpu-core": { @@ -22496,33 +22682,6 @@ "lowercase-keys": "^1.0.0" } }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - }, - "dependencies": { - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "^1.0.0" - } - } - } - }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", @@ -22580,15 +22739,6 @@ "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", "dev": true }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "requires": { - "is-promise": "^2.1.0" - } - }, "run-queue": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", @@ -22598,15 +22748,6 @@ "aproba": "^1.1.1" } }, - "rxjs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", - "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -24451,23 +24592,41 @@ "dev": true }, "table": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz", - "integrity": "sha512-E6CK1/pZe2N75rGZQotFOdmzWQ1AILtgYbMAbAjvms0S1l5IDB47zG3nCnFGB/w+7nB3vKofbLXCH7HPBo864w==", + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", "dev": true, "requires": { - "ajv": "^6.9.1", - "lodash": "^4.17.11", + "ajv": "^6.10.2", + "lodash": "^4.17.14", "slice-ansi": "^2.1.0", "string-width": "^3.0.0" }, "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, "ansi-regex": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -24806,15 +24965,6 @@ "resolved": "https://registry.npmjs.org/tlds/-/tlds-1.207.0.tgz", "integrity": "sha512-k7d7Q1LqjtAvhtEOs3yN14EabsNO8ZCoY6RESSJDB9lst3bTx3as/m1UuAeCKzYxiyhR1qq72ZPhpSf+qlqiwg==" }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } - }, "tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -26589,6 +26739,12 @@ "resolved": "https://registry.npmjs.org/word-count/-/word-count-0.2.2.tgz", "integrity": "sha1-aZGS/KaCn+k21Byw2V25JIxXBFE=" }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", -- 2.40.1 From 31b5a140d435ed51c25d5da9fedcc33f7f8380b5 Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 30 Oct 2020 10:07:53 +0100 Subject: [PATCH 4/6] test completados --- db/dump/fixtures.sql | 6 +- .../ticket/specs/componentUpdate.spec.js | 68 +++++++++++++++---- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 605b6d2a8..02bb2edbd 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -412,7 +412,8 @@ INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`desc VALUES (1, 121, 1, 'under the floor'), (2, 121, 2, 'wears leather and goes out at night'), - (3, 121, 3, 'care with the dog'); + (3, 121, 3, 'care with the dog'), + (5, 122, 5, 'Delivery after 10am'); INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`) VALUES @@ -606,7 +607,8 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des (8, 23, 2, 'wears leather and goes out at night'), (9, 23, 3, 'care with the dog'), (10, 23, 4, 'Reclama ticket: 8'), - (11, 24, 4, 'Reclama ticket: 7'); + (11, 24, 4, 'Reclama ticket: 7'), + (12, 11, 5, 'Delivery after 10am'); -- FIX for state hours on local, inter_afterInsert UPDATE vncontrol.inter SET odbc_date = DATE_ADD(CURDATE(), INTERVAL -10 SECOND); diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 4bc9fe17b..6126f3dcb 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -97,20 +97,60 @@ describe('ticket componentUpdate()', () => { expect(firstvalueBeforeChange).toEqual(firstvalueAfterChange); expect(secondvalueBeforeChange).toEqual(secondvalueAfterChange); }); -}); -it('should change the addressFk to modify the observations and then undo the changes', async() => { - const clientID = 102; - const addressID = 122; - const agencyModeID = 8; - const warehouseID = 1; - const zoneID = 5; - const shipped = today; - const companyID = 442; - const isDeleted = false; - const landed = tomorrow; - const option = 1; + it('should change the addressFk and check that delivery observations have been changed and then undo the changes', async() => { + const clientID = 102; + const addressID = 122; + const newAddressID = 2; + const agencyModeID = 8; + const warehouseID = 1; + const zoneID = 5; + const shipped = today; + const companyID = 442; + const isDeleted = false; + const landed = tomorrow; + const option = 1; + const ctx = { + args: {clientFk: clientID, + agencyModeFk: agencyModeID}, + req: { + accessToken: {userId: userID}, + headers: {origin: 'http://localhost'}, + __: value => { + return value; + } + } + }; + const observationTypeDelivery = await app.models.ObservationType.findOne({ + where: {code: 'delivery'} + }); + const ticketObservation = await app.models.TicketObservation.findOne({ + where: { + ticketFk: ticketID, + observationTypeFk: observationTypeDelivery.id} + }); - await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, addressID, - zoneID, warehouseID, companyID, shipped, landed, isDeleted, option); + await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, newAddressID, + zoneID, warehouseID, companyID, shipped, landed, isDeleted, option); + + const newTicketObservation = await app.models.TicketObservation.findOne({ + where: { + ticketFk: ticketID, + observationTypeFk: observationTypeDelivery.id} + }); + + expect(newTicketObservation).toBeNull(); + + // restores + await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, addressID, + zoneID, warehouseID, companyID, shipped, landed, isDeleted, option); + + const restoredTicketObservation = await app.models.TicketObservation.findOne({ + where: { + ticketFk: ticketID, + observationTypeFk: observationTypeDelivery.id} + }); + + expect(restoredTicketObservation.description).toEqual(ticketObservation.description); + }); }); -- 2.40.1 From 71fe677a7edf2d59e6348da05de54d8f935a4e5a Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 30 Oct 2020 10:50:13 +0100 Subject: [PATCH 5/6] fix getSummary --- modules/supplier/back/methods/supplier/specs/getSummary.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js index 42e89afd4..85d16bbda 100644 --- a/modules/supplier/back/methods/supplier/specs/getSummary.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getSummary.spec.js @@ -7,7 +7,7 @@ describe('Supplier getSummary()', () => { expect(supplier.id).toEqual(1); expect(supplier.name).toEqual('Plants SL'); expect(supplier.nif).toEqual('06089160W'); - expect(supplier.account).toEqual(4000000001); + expect(supplier.account).toEqual(4100000001); expect(supplier.payDay).toEqual(15); }); -- 2.40.1 From b50ae7b8ca31546a1097e997df9f92e6d32fbb2f Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 30 Oct 2020 15:50:59 +0100 Subject: [PATCH 6/6] testback arreglados --- .../00-ticket_beforeUpdate.sql | 25 ++++++++ db/dump/fixtures.sql | 2 +- .../ticket-request/specs/filter.spec.js | 58 ++++++++++--------- .../back/methods/ticket/componentUpdate.js | 3 +- .../ticket/specs/componentUpdate.spec.js | 11 ++-- 5 files changed, 65 insertions(+), 34 deletions(-) create mode 100644 db/changes/10240-allSaints/00-ticket_beforeUpdate.sql diff --git a/db/changes/10240-allSaints/00-ticket_beforeUpdate.sql b/db/changes/10240-allSaints/00-ticket_beforeUpdate.sql new file mode 100644 index 000000000..183636081 --- /dev/null +++ b/db/changes/10240-allSaints/00-ticket_beforeUpdate.sql @@ -0,0 +1,25 @@ +DROP TRIGGER IF EXISTS `vn`.`ticket_afterUpdate`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` TRIGGER `ticket_afterUpdate` + AFTER UPDATE ON `ticket` + FOR EACH ROW +BEGIN + IF !(NEW.id <=> OLD.id) + OR !(NEW.warehouseFk <=> OLD.warehouseFk) + OR !(NEW.shipped <=> OLD.shipped) THEN + CALL stock.log_add('ticket', NEW.id, OLD.id); + END IF; + + IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN + -- Fallo que se insertan no se sabe como tickets en este cliente + INSERT INTO vn.mail SET + `sender` = 'jgallego@verdnatura.es', + `replyTo` = 'jgallego@verdnatura.es', + `subject` = 'Modificado ticket al cliente 2067', + `body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ', + NEW.id); + END IF; +END$$ +DELIMITER ; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 56c3aca4a..cde371050 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -325,7 +325,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr (119, 'address 19', 'Somewhere in Alberic', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), (120, 'address 20', 'Somewhere in Montortal', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), (121, 'address 21', 'the bat cave', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0, 0), - (122, 'address 22', 'NY roofs', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0, 0), + (122, 'NY roofs', 'address 22', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0, 0), (123, 'address 23', 'The phone box', 'Silla', 46460, 1, 1111111111, 222222222, 1, 103, 2, NULL, NULL, 0, 0), (124, 'address 24', 'Stark tower Silla', 'Silla', 46460, 1, 1111111111, 222222222, 1, 104, 2, NULL, NULL, 0, 0), (125, 'address 25', 'The plastic cell', 'Silla', 46460, 1, 1111111111, 222222222, 1, 105, 2, NULL, NULL, 0, 0), diff --git a/modules/ticket/back/methods/ticket-request/specs/filter.spec.js b/modules/ticket/back/methods/ticket-request/specs/filter.spec.js index 68d7601e4..13636341c 100644 --- a/modules/ticket/back/methods/ticket-request/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/filter.spec.js @@ -1,82 +1,84 @@ const app = require('vn-loopback/server/server'); describe('ticket-request filter()', () => { - it('should now return all ticket requests', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {}}; + const userId = 9; + let ctx = {req: {accessToken: {userId: userId}}}; - let result = await app.models.TicketRequest.filter(ctx); + it('should now return all ticket requests', async() => { + ctx.args = {}; + + const result = await app.models.TicketRequest.filter(ctx); expect(result.length).toEqual(3); }); it('should return the ticket request matching a generic search value which is the ticket ID', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {search: 11}}; + ctx.args = {search: 11}; - let result = await app.models.TicketRequest.filter(ctx); - let requestId = result[0].id; + const result = await app.models.TicketRequest.filter(ctx); + const requestId = result[0].id; expect(requestId).toEqual(4); }); it('should return the ticket request matching a generic search value which is the client address alias', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {search: 'NY roofs'}}; + ctx.args = {search: 'NY roofs'}; - let result = await app.models.TicketRequest.filter(ctx); - let requestId = result[0].id; + const result = await app.models.TicketRequest.filter(ctx); + const requestId = result[0].id; expect(requestId).toEqual(4); }); it('should return the ticket request matching the ticket ID', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {ticketFk: 11}}; - - let result = await app.models.TicketRequest.filter(ctx); - let requestId = result[0].id; + ctx.args = {ticketFk: 11}; + const result = await app.models.TicketRequest.filter(ctx); + const requestId = result[0].id; expect(requestId).toEqual(4); }); it('should return the ticket request matching the atender ID', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {attenderFk: 35}}; + ctx.args = {attenderFk: 35}; - let result = await app.models.TicketRequest.filter(ctx); - let requestId = result[0].id; + const result = await app.models.TicketRequest.filter(ctx); + const requestId = result[0].id; expect(requestId).toEqual(3); }); it('should return the ticket request matching the isOk triple-state', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {isOk: null}}; + ctx.args = {isOk: null}; - let result = await app.models.TicketRequest.filter(ctx); - let requestId = result[0].id; + const result = await app.models.TicketRequest.filter(ctx); + const requestId = result[0].id; expect(requestId).toEqual(3); }); it('should return the ticket request matching the client ID', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {clientFk: 102}}; + ctx.args = {clientFk: 102}; - let result = await app.models.TicketRequest.filter(ctx); - let requestId = result[0].id; + const result = await app.models.TicketRequest.filter(ctx); + const requestId = result[0].id; expect(requestId).toEqual(4); }); it('should return the ticket request matching the warehouse ID', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {warehouse: 1}}; + ctx.args = {warehouse: 1}; - let result = await app.models.TicketRequest.filter(ctx, {order: 'id'}); - let requestId = result[0].id; + const result = await app.models.TicketRequest.filter(ctx, {order: 'id'}); + const requestId = result[0].id; expect(requestId).toEqual(3); }); it('should return the ticket request matching the salesPerson ID', async() => { - let ctx = {req: {accessToken: {userId: 9}}, args: {salesPersonFk: 18}}; + ctx.args = {salesPersonFk: 18}; - let result = await app.models.TicketRequest.filter(ctx); - let requestId = result[0].id; + const result = await app.models.TicketRequest.filter(ctx); + const requestId = result[0].id; expect(requestId).toEqual(3); }); diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 53a1593bc..fe395e562 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -92,6 +92,7 @@ module.exports = Self => { const observationTypeDelivery = await models.ObservationType.findOne({ where: {code: 'delivery'} }); + const originalTicket = await models.Ticket.findOne({ where: {id: id}, fields: ['id', 'clientFk', 'agencyModeFk', 'addressFk', 'zoneFk', @@ -151,7 +152,7 @@ module.exports = Self => { }); const [observation] = address.observations(); if (observation) { - await models.TicketObservation.upsert({ + await models.TicketObservation.create({ ticketFk: id, observationTypeFk: observation.observationTypeFk, description: observation.description diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 6126f3dcb..76733f2c6 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -5,6 +5,7 @@ describe('ticket componentUpdate()', () => { const ticketID = 11; const today = new Date(); const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); let deliveryComponentId; @@ -124,22 +125,24 @@ describe('ticket componentUpdate()', () => { const observationTypeDelivery = await app.models.ObservationType.findOne({ where: {code: 'delivery'} }); - const ticketObservation = await app.models.TicketObservation.findOne({ + const originalTicketObservation = await app.models.TicketObservation.findOne({ where: { ticketFk: ticketID, observationTypeFk: observationTypeDelivery.id} }); + expect(originalTicketObservation).toBeDefined(); + await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, newAddressID, zoneID, warehouseID, companyID, shipped, landed, isDeleted, option); - const newTicketObservation = await app.models.TicketObservation.findOne({ + const removedTicketObservation = await app.models.TicketObservation.findOne({ where: { ticketFk: ticketID, observationTypeFk: observationTypeDelivery.id} }); - expect(newTicketObservation).toBeNull(); + expect(removedTicketObservation).toBeNull(); // restores await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, addressID, @@ -151,6 +154,6 @@ describe('ticket componentUpdate()', () => { observationTypeFk: observationTypeDelivery.id} }); - expect(restoredTicketObservation.description).toEqual(ticketObservation.description); + expect(restoredTicketObservation.description).toEqual(originalTicketObservation.description); }); }); -- 2.40.1