From 4e27581045a0e37fdad80c9d895486bc3dfbd059 Mon Sep 17 00:00:00 2001 From: Bernat Date: Wed, 27 Mar 2019 08:44:15 +0100 Subject: [PATCH 1/2] cau 10269 fix test and update fixtures --- db/install/dump/fixtures.sql | 161 ++++++++++-------- e2e/paths/item-module/01_summary.spec.js | 30 ++-- e2e/paths/item-module/02_basic_data.spec.js | 2 +- e2e/paths/item-module/03_tax.spec.js | 2 +- e2e/paths/item-module/04_tags.spec.js | 6 +- e2e/paths/item-module/05_niche.spec.js | 2 +- e2e/paths/item-module/06_botanical.spec.js | 2 +- e2e/paths/item-module/07_barcode.spec.js | 2 +- e2e/paths/item-module/09_regularize.spec.js | 8 +- e2e/paths/ticket-module/03_list_sale.spec.js | 6 +- .../04_create_ticket_packages.spec.js | 8 +- .../06_edit_basic_data_steps.spec.js | 2 +- e2e/paths/ticket-module/07_edit_sale.spec.js | 2 +- .../item-tag/specs/filterItemTags.spec.js | 4 +- .../back/methods/item/specs/filter.spec.js | 4 +- .../methods/order/specs/catalogFilter.spec.js | 6 +- .../packaging/specs/listPackaging.spec.js | 4 +- .../specs/listSaleTracking.spec.js | 2 +- .../sale/specs/getClaimableFromTicket.spec.js | 2 +- .../methods/ticket/specs/getSales.spec.js | 2 +- 20 files changed, 136 insertions(+), 121 deletions(-) diff --git a/db/install/dump/fixtures.sql b/db/install/dump/fixtures.sql index 3293f0b57..e8b3b9af5 100644 --- a/db/install/dump/fixtures.sql +++ b/db/install/dump/fixtures.sql @@ -562,16 +562,16 @@ INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) (05080000, 'Coral y materiales similares' , 2, 2), (06021010, 'Plantas vivas: Esqueje/injerto, Vid', 1, 1); -INSERT INTO `vn`.`item`(`id`, `name`,`typeFk`,`size`,`inkFk`,`category`,`stems`,`originFk`,`description`,`producerFk`,`intrastatFk`,`isOnOffer`,`expenceFk`,`isBargain`,`comment`,`relevancy`,`image`,`taxClassFk`,`longName`,`subName`,`tag5`,`value5`,`tag6`,`value6`,`tag7`,`value7`,`tag8`,`value8`) +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `isOnOffer`, `expenceFk`, `isBargain`, `comment`, `relevancy`, `image`, `taxClassFk`, `subName`) VALUES - (1 , 'Object1 Gem1 5', 2, 70, 'AMA', 'EXT', 1 , 1, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 66540, 1, 'Object1 Gem1 5', NULL, 'Medida', '70', 'Color', 'Amarillo' , 'Categoria', 'EXT', 'Tallos', '1'), - (2 , 'Object2 Gem2 3', 2, 70, 'AZL', 'EXT', 1 , 2, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 65540, 1, 'Object2 Gem2 3', NULL, 'Medida', '70', 'Color', 'Azul' , 'Categoria', 'EXT', 'Tallos', '1'), - (3 , 'Object3 Armor 3', 1, 60, 'AMR', 'EXT', 1 , 3, 'Rhodeys armor', 1, 05080000, 0, 4751000000, 0, NULL, 0, 61692, 1, 'Object3 Armor 3', NULL, 'Medida', '60', 'Color', 'Rosa/Amarillo', 'Categoria', 'EXT', 'Tallos', '1'), - (4 , 'Object4 Armor2 2', 1, 60, 'AMR', 'EXT', 1 , 1, 'Iron Mans first armor', 1, 05080000, 1, 4751000000, 0, NULL, 0, 66090, 2, 'Object4 Armor2 2', NULL, 'Medida', '60', 'Color', 'Rosa/Amarillo', 'Categoria', 'EXT', 'Tallos', '1'), - (5 , 'Object5 Weapon 50', 3, 30, 'GRE', 'EXT', 1 , 2, 'Thors hammer!', 2, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, 'Object5 Weapon 50', NULL, 'Medida', '30', 'Color', 'Azul' , 'Categoria', 'EXT', 'Tallos', '1'), - (6 , 'Broken Box', 5, 30, 'GRE', 'EXT', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, 'Broken Box', NULL, 'Medida', '30', 'Color', 'Gris' , NULL, NULL, NULL, NULL), - (7 , 'Legendary Box', 5, 90, 'AZL', 'EXT', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, 'Legendary Box', NULL, 'Medida', '90', 'Color', 'Gris' , NULL, NULL, NULL, NULL), - (71, 'ShippingCost', 4, NULL, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, NULL, 2, 'ShippingCost', NULL, NULL , NULL, NULL , NULL , NULL, NULL, NULL, NULL); + (1 , 2, 70, 'AMA', 1 , 1, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 66540, 1, NULL), + (2 , 2, 70, 'AZL', 1 , 2, 'One of the infinity gems', 1, 06021010, 0, 2000000000, 0, NULL, 0, 65540, 1, NULL), + (3 , 1, 60, 'AMR', 1 , 3, 'Rhodeys armor', 1, 05080000, 0, 4751000000, 0, NULL, 0, 61692, 1, NULL), + (4 , 1, 60, 'AMR', 1 , 1, 'Iron Mans first armor', 1, 05080000, 1, 4751000000, 0, NULL, 0, 66090, 2, NULL), + (5 , 3, 30, 'GRE', 1 , 2, 'Thors hammer!', 2, 06021010, 1, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (6 , 5, 30, 'GRE', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (7 , 5, 90, 'AZL', 1 , 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL), + (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, NULL, 2, NULL); INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`) VALUES @@ -596,30 +596,30 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) VALUES - (1, 1, 1, 'Object1 Gem1 5', 5, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (2, 2, 1, 'Object2 Gem2 3', 10, 1.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (3, 1, 1, 'Object1 Gem1 5', 2, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (4, 4, 1, 'Object4 Armor2 2', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (5, 1, 2, 'Object1 Gem1 5', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)), - (6, 1, 3, 'Object1 Gem1 5', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)), - (7, 2, 11, 'Object2 Gem2 3', 15, 1.46, 0, 0, 0, CURDATE()), - (8, 4, 11, 'Object4 Armor2 2', 10, 3.05, 0, 0, 0, CURDATE()), - (9, 1, 16, 'Object1 Gem1 5', 5, 9.10, 0, 0, 0, CURDATE()), - (10, 2, 16, 'Object2 Gem2 3', 10, 1.07, 0, 0, 0, CURDATE()), - (11, 1, 16, 'Object1 Gem1 5', 2, 9.10, 0, 0, 0, CURDATE()), - (12, 4, 16, 'Object4 Armor2 2', 20, 3.06, 0, 0, 0, CURDATE()), - (13, 2, 8, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (14, 1, 8, 'Object1 Gem1 5', 10, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (15, 1, 19, 'Object1 Gem1 5', 10, 1.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (16, 2, 20, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (17, 2, 22, 'Object2 Gem2 3', 30, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (18, 4, 22, 'Object4 Armor2 2', 20, 3.00, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (19, 1, 4, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -4 DAY)), - (20, 1, 5, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 DAY)), - (21, 1, 6, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 DAY)), - (22, 1, 7, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 DAY)), - (23, 1, 9, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (24, 1, 10, 'Object1 Gem1 5', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)); + (1, 1, 1, 'Ranged weapon longbow 2m', 5, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (2, 2, 1, 'Melee weapon combat first 15cm', 10, 1.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (3, 1, 1, 'Ranged weapon longbow 2m', 2, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (5, 1, 2, 'Ranged weapon longbow 2m', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)), + (6, 1, 3, 'Ranged weapon longbow 2m', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)), + (7, 2, 11, 'Melee weapon combat first 15cm', 15, 1.46, 0, 0, 0, CURDATE()), + (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 3.05, 0, 0, 0, CURDATE()), + (9, 1, 16, 'Ranged weapon longbow 2m', 5, 9.10, 0, 0, 0, CURDATE()), + (10, 2, 16, 'Melee weapon combat first 15cm', 10, 1.07, 0, 0, 0, CURDATE()), + (11, 1, 16, 'Ranged weapon longbow 2m', 2, 9.10, 0, 0, 0, CURDATE()), + (12, 4, 16, 'Melee weapon heavy shield 1x0.5m', 20, 3.06, 0, 0, 0, CURDATE()), + (13, 2, 8, 'Melee weapon combat first 15cm', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (14, 1, 8, 'Ranged weapon longbow 2m', 10, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), + (15, 1, 19, 'Ranged weapon longbow 2m', 10, 1.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (16, 2, 20, 'Melee weapon combat first 15cm', 15, 1.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (17, 2, 22, 'Melee weapon combat first 15cm', 30, 2.30, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (18, 4, 22, 'Melee weapon heavy shield 1x0.5m', 20, 3.00, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (19, 1, 4, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -4 DAY)), + (20, 1, 5, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 DAY)), + (21, 1, 6, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 DAY)), + (22, 1, 7, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 DAY)), + (23, 1, 9, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), + (24, 1, 10, 'Ranged weapon longbow 2m', 1, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH)); INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`) VALUES @@ -660,7 +660,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (7, 28, 5.6), (7, 29, -4.6), (7, 39, 0.01), - (8, 15, 0.0426), + (8, 15, 0.039), (8, 21, -0.003), (8, 28, 20.72), (8, 29, -19.72), @@ -791,41 +791,56 @@ INSERT INTO `vn`.`itemBotanical`(`itemFk`, `botanical`, `genusFk`, `specieFk`) INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) VALUES - (1 , 1, 56, 'Object1', 1), - (2 , 1, 58, 'Gem1' , 2), - (3 , 1, 27, '5' , 3), - (4 , 1, 36, 'Marvel1', 4), - (5 , 1, 1 , 'Yellow' , 5), - (6 , 1, 67 , 'A1' , 6), - (7 , 1, 23, '0' , 7), - (8 , 2, 56, 'Object2', 1), - (9 , 2, 58, 'Gem2' , 2), - (10, 2, 27 , '3' , 3), - (11, 2, 36, 'Marvel2', 4), - (12, 2, 1 , 'Red' , 5), - (13, 2, 67, 'A1' , 6), - (14, 2, 23, '0' , 7), - (15, 3, 56, 'Object3', 1), - (16, 3, 58, 'Armor' , 2), - (17, 3, 4, '3' , 3), - (18, 3, 36, 'Stark' , 4), - (19, 3, 1 , 'Green' , 5), - (20, 3, 67, 'EXT' , 6), - (21, 3, 23, '0' , 7), - (22, 4, 56, 'Object4', 1), - (23, 4, 58, 'Armor2' , 2), - (24, 4, 4, '2' , 3), - (25, 4, 36, 'Stark' , 4), - (26, 4, 1 , 'Blue' , 5), - (27, 4, 67, 'EXT' , 6), - (28, 4, 23, '1' , 7), - (29, 5, 56, 'Object5', 1), - (30, 5, 58, 'Weapon' , 2), - (31, 5, 27 , '50' , 3), - (32, 5, 36, 'Thor' , 4), - (33, 5, 1 , 'Grey' , 5), - (34, 5, 67, 'EXT' , 6), - (35, 5, 23, '1' , 7); + (1 , 1, 56, 'Ranged weapon', 1), + (2 , 1, 58, 'longbow', 2), + (3 , 1, 27, '2m', 3), + (4 , 1, 36, 'Stark Industries', 4), + (5 , 1, 1, 'Brown', 5), + (6 , 1, 67, 'precission', 6), + (7 , 1, 23, '1', 7), + (8 , 2, 56, 'Melee weapon', 1), + (9 , 2, 58, 'combat first', 2), + (10, 2, 27, '15cm', 3), + (11, 2, 36, 'Stark Industries', 4), + (12, 2, 1, 'Silver', 5), + (13, 2, 67, 'concussion', 6), + (14, 2, 23, '1', 7), + (15, 3, 56, 'Ranged weapon', 1), + (16, 3, 58, 'sniper rifle', 2), + (17, 3, 4, '300mm', 3), + (18, 3, 36, 'Stark Industries', 4), + (19, 3, 1, 'Green', 5), + (20, 3, 67, 'precission', 6), + (21, 3, 23, '1', 7), + (22, 4, 56, 'Melee weapon', 1), + (23, 4, 58, 'heavy shield', 2), + (24, 4, 4, '1x0.5m', 3), + (25, 4, 36, 'Stark Industries', 4), + (26, 4, 1, 'Black', 5), + (27, 4, 67, 'containtment', 6), + (28, 4, 23, '1', 7), + (29, 5, 56, 'Ranged weapon', 1), + (30, 5, 58, 'pistol', 2), + (31, 5, 27, '9mm', 3), + (32, 5, 36, 'Stark Industries', 4), + (33, 5, 1, 'Silver', 5), + (34, 5, 67, 'rapid fire', 6), + (35, 5, 23, '1', 7), + (36, 6, 56, 'Container', 1), + (37, 6, 58, 'ammo box', 2), + (38, 6, 27, '1m', 3), + (39, 6, 36, 'Stark Industries', 4), + (40, 6, 1, 'Green', 5), + (41, 6, 67, 'supply', 6), + (42, 6, 23, '1', 7), + (43, 7, 56, 'Container', 1), + (44, 7, 58, 'medical box', 2), + (45, 7, 27, '1m', 3), + (46, 7, 36, 'Stark Industries', 4), + (47, 7, 1, 'White', 5), + (48, 7, 67, 'supply', 6), + (49, 7, 23, '1', 7), + (50, 71, 92, 'Shipping cost', 2); INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) VALUES @@ -1170,10 +1185,10 @@ INSERT INTO `vn2008`.`workerTeam`(`id`, `team`, `user`) INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `atenderFk`, `quantity`, `itemFk`, `price`, `isOk`, `saleFk`, `ticketFk`, `created`) VALUES - (1, 'Object1 Gem1 5', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (2, 'Object2 Gem2 3', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (3, 'Object4 Armor2 2', 18, 35, 20, 4, 3.06, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), - (4, 'Object2 Gem2 3', 18, 35, 15, 2, 1.30, NULL, NULL, 11, CURDATE()); + (1, 'Ranged weapon longbow 2m', 18, 35, 5, 1, 9.10, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (2, 'Melee weapon combat first 15cm', 18, 35, 10, 2, 1.07, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (3, 'Melee weapon heavy shield 1x0.5m', 18, 35, 20, 4, 3.06, 0, NULL, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (4, 'Melee weapon combat first 15cm', 18, 35, 15, 2, 1.30, NULL, NULL, 11, CURDATE()); INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`) VALUES diff --git a/e2e/paths/item-module/01_summary.spec.js b/e2e/paths/item-module/01_summary.spec.js index 1364aa00a..e4b27d127 100644 --- a/e2e/paths/item-module/01_summary.spec.js +++ b/e2e/paths/item-module/01_summary.spec.js @@ -11,7 +11,7 @@ describe('Item summary path', () => { it('should search for an item', async() => { const result = await nightmare - .write(selectors.itemsIndex.searchItemInput, 'Object1 Gem1 5') + .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon longbow 2m') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -21,7 +21,7 @@ describe('Item summary path', () => { it(`should click on the search result summary button to open the item summary popup`, async() => { const isVisibleBefore = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object1 Gem1 5') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon longbow 2m') .isVisible(selectors.itemSummary.basicData); const isVisibleAfter = await nightmare @@ -34,18 +34,18 @@ describe('Item summary path', () => { it(`should check the item summary preview shows fields from basic data`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Object1 Gem1 5') + .waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 2m') .waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - expect(result).toContain('Object1 Gem1 5'); + expect(result).toContain('Ranged weapon longbow 2m'); }); it(`should check the item summary preview shows fields from tags`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.tags, 'Yellow') + .waitForTextInElement(selectors.itemSummary.tags, 'Brown') .waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - expect(result).toContain('Yellow'); + expect(result).toContain('Brown'); }); it(`should check the item summary preview shows fields from niche`, async() => { @@ -84,7 +84,7 @@ describe('Item summary path', () => { const result = await nightmare .clearInput('vn-item-index vn-searchbar input') .waitToClick(selectors.itemsIndex.searchButton) - .write(selectors.itemsIndex.searchItemInput, 'Object2 Gem2 3') + .write(selectors.itemsIndex.searchItemInput, 'Melee weapon combat first 15cm') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -94,7 +94,7 @@ describe('Item summary path', () => { it(`should now click on the search result summary button to open the item summary popup`, async() => { const isVisibleBefore = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object2 Gem2 3') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Melee weapon combat first 15cm') .isVisible(selectors.itemSummary.basicData); const isVisibleAfter = await nightmare @@ -108,18 +108,18 @@ describe('Item summary path', () => { it(`should now check the item summary preview shows fields from basic data`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Object2 Gem2 3') + .waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat first 15cm') .waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - expect(result).toContain('Object2 Gem2 3'); + expect(result).toContain('Melee weapon combat first 15cm'); }); it(`should now check the item summary preview shows fields from tags`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.tags, 'Red') + .waitForTextInElement(selectors.itemSummary.tags, 'Silver') .waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - expect(result).toContain('Red'); + expect(result).toContain('Silver'); }); it(`should now check the item summary preview shows fields from niche`, async() => { @@ -172,17 +172,17 @@ describe('Item summary path', () => { it(`should check the item summary shows fields from basic data section`, async() => { const result = await nightmare - .waitForTextInElement(selectors.itemSummary.basicData, 'Object2 Gem2 3') + .waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat first 15cm') .waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); - expect(result).toContain('Object2 Gem2 3'); + expect(result).toContain('Melee weapon combat first 15cm'); }); it(`should check the item summary shows fields from tags section`, async() => { const result = await nightmare .waitToGetProperty(selectors.itemSummary.tags, 'innerText'); - expect(result).toContain('Red'); + expect(result).toContain('Silver'); }); it(`should check the item summary shows fields from niches section`, async() => { diff --git a/e2e/paths/item-module/02_basic_data.spec.js b/e2e/paths/item-module/02_basic_data.spec.js index 15cea353a..257b12e17 100644 --- a/e2e/paths/item-module/02_basic_data.spec.js +++ b/e2e/paths/item-module/02_basic_data.spec.js @@ -7,7 +7,7 @@ describe('Item Edit basic data path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object2 Gem2 3') + .accessToSearchResult('Melee weapon combat first 15cm') .accessToSection('item.card.data'); }); diff --git a/e2e/paths/item-module/03_tax.spec.js b/e2e/paths/item-module/03_tax.spec.js index c1c75f51f..5060a4f91 100644 --- a/e2e/paths/item-module/03_tax.spec.js +++ b/e2e/paths/item-module/03_tax.spec.js @@ -7,7 +7,7 @@ describe('Item edit tax path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.tax'); }); diff --git a/e2e/paths/item-module/04_tags.spec.js b/e2e/paths/item-module/04_tags.spec.js index ab4f833f4..b7412576d 100644 --- a/e2e/paths/item-module/04_tags.spec.js +++ b/e2e/paths/item-module/04_tags.spec.js @@ -7,7 +7,7 @@ describe('Item create tags path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.tags'); }); @@ -55,7 +55,7 @@ describe('Item create tags path', () => { .waitToGetProperty(selectors.itemTags.fifthRelevancyInput, 'value'); expect(tag).toEqual('Color'); - expect(value).toEqual('Yellow'); + expect(value).toEqual('Brown'); expect(relevancy).toEqual('5'); }); @@ -70,7 +70,7 @@ describe('Item create tags path', () => { .waitToGetProperty(selectors.itemTags.sixthRelevancyInput, 'value'); expect(tag).toEqual('Categoria'); - expect(value).toEqual('A1'); + expect(value).toEqual('precission'); expect(relevancy).toEqual('6'); }); }); diff --git a/e2e/paths/item-module/05_niche.spec.js b/e2e/paths/item-module/05_niche.spec.js index 6f0e624db..fcb3c69ef 100644 --- a/e2e/paths/item-module/05_niche.spec.js +++ b/e2e/paths/item-module/05_niche.spec.js @@ -7,7 +7,7 @@ describe('Item create niche path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.niche'); }); diff --git a/e2e/paths/item-module/06_botanical.spec.js b/e2e/paths/item-module/06_botanical.spec.js index c17a7adc7..864705056 100644 --- a/e2e/paths/item-module/06_botanical.spec.js +++ b/e2e/paths/item-module/06_botanical.spec.js @@ -7,7 +7,7 @@ describe('Item Create botanical path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object5 Weapon 50') + .accessToSearchResult('Ranged weapon pistol 9mm') .accessToSection('item.card.botanical'); }); diff --git a/e2e/paths/item-module/07_barcode.spec.js b/e2e/paths/item-module/07_barcode.spec.js index 268b2b7e9..db588cfe6 100644 --- a/e2e/paths/item-module/07_barcode.spec.js +++ b/e2e/paths/item-module/07_barcode.spec.js @@ -7,7 +7,7 @@ describe('Item Create barcodes path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object1 Gem1 5') + .accessToSearchResult('Ranged weapon longbow 2m') .accessToSection('item.card.itemBarcode'); }); diff --git a/e2e/paths/item-module/09_regularize.spec.js b/e2e/paths/item-module/09_regularize.spec.js index 50d5d2f68..23d8904e4 100644 --- a/e2e/paths/item-module/09_regularize.spec.js +++ b/e2e/paths/item-module/09_regularize.spec.js @@ -29,7 +29,7 @@ xdescribe('Item regularize path', () => { it('should search for the item', async() => { const resultCount = await nightmare - .write(selectors.itemsIndex.searchItemInput, 'Object5 Weapon 50') + .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -39,7 +39,7 @@ xdescribe('Item regularize path', () => { it(`should click on the search result to access to the item tax`, async() => { const url = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object5 Weapon 50') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); @@ -134,7 +134,7 @@ xdescribe('Item regularize path', () => { it('should search for the item once again', async() => { const resultCount = await nightmare - .write(selectors.itemsIndex.searchItemInput, 'Object5 Weapon 50') + .write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -144,7 +144,7 @@ xdescribe('Item regularize path', () => { it(`should click on the search result to access to the item tax`, async() => { const url = await nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Object5 Weapon 50') + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm') .waitToClick(selectors.itemsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); diff --git a/e2e/paths/ticket-module/03_list_sale.spec.js b/e2e/paths/ticket-module/03_list_sale.spec.js index 54d63e26a..b261cc612 100644 --- a/e2e/paths/ticket-module/03_list_sale.spec.js +++ b/e2e/paths/ticket-module/03_list_sale.spec.js @@ -15,7 +15,7 @@ describe('Ticket List sale path', () => { const value = await nightmare .waitToGetProperty(selectors.ticketSales.firstSaleColour, 'innerText'); - expect(value).toContain('Yellow'); + expect(value).toContain('Silver'); }); it('should confirm the first ticket sale contains the lenght', async() => { @@ -29,7 +29,7 @@ describe('Ticket List sale path', () => { const value = await nightmare .waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText'); - expect(value).toContain('2.30'); + expect(value).toContain('1.30'); }); it('should confirm the first ticket sale contains the discount', async() => { @@ -43,7 +43,7 @@ describe('Ticket List sale path', () => { const value = await nightmare .waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText'); - expect(value).toContain('23'); + expect(value).toContain('19.50'); }); it('should navigate to the catalog by pressing the new item button', async() => { diff --git a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js index 6576893a9..b800f9069 100644 --- a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js +++ b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js @@ -15,7 +15,7 @@ describe('Ticket Create packages path', () => { const result = await nightmare .waitToClick(selectors.ticketPackages.firstRemovePackageButton) .waitToClick(selectors.ticketPackages.addPackageButton) - .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Legendary Box') + .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m') .waitToClick(selectors.ticketPackages.savePackagesButton) .waitForLastSnackbar(); @@ -54,7 +54,7 @@ describe('Ticket Create packages path', () => { it(`should create a new package with correct data`, async() => { const result = await nightmare - .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Legendary Box') + .autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m') .waitToClick(selectors.ticketPackages.savePackagesButton) .waitForLastSnackbar(); @@ -64,10 +64,10 @@ describe('Ticket Create packages path', () => { it(`should confirm the first select is the expected one`, async() => { const result = await nightmare .reloadSection('ticket.card.package.index') - .waitForTextInInput(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'Legendary Box') + .waitForTextInInput(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'Container medical box 1m') .waitToGetProperty(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'value'); - expect(result).toEqual('7 : Legendary Box'); + expect(result).toEqual('7 : Container medical box 1m'); }); it(`should confirm the first quantity is the expected one`, async() => { diff --git a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js index d467a9f5e..1a51a9a60 100644 --- a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js +++ b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js @@ -73,7 +73,7 @@ describe('Ticket Edit basic data path', () => { .wait(1900) .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); - expect(result).toContain('-€204.25'); + expect(result).toContain('-€202.25'); }); it(`should then click next to move on to step three`, async() => { diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index 0edba8750..f339f6a57 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -311,7 +311,7 @@ xdescribe('Ticket Edit sale path', () => { .wait(selectors.ticketSales.firstSaleText) .waitToGetProperty(selectors.ticketSales.firstSaleText, 'innerText'); - expect(result).toContain(`Object4 Armor2 2`); + expect(result).toContain(`Melee weapon heavy shield 1x0.5m`); }); it('should go back to the original ticket sales section', async() => { diff --git a/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js b/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js index e1bfdb4c1..272367327 100644 --- a/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js +++ b/modules/item/back/methods/item-tag/specs/filterItemTags.spec.js @@ -1,9 +1,9 @@ const app = require('vn-loopback/server/server'); describe('item filterItemTags()', () => { - it('should filter ItemTags table', async () => { + it('should filter ItemTags table', async() => { let [result] = await app.models.ItemTag.filterItemTags(1, {}); - expect(result.value).toEqual('Blue'); + expect(result.value).toEqual('Black'); }); }); diff --git a/modules/item/back/methods/item/specs/filter.spec.js b/modules/item/back/methods/item/specs/filter.spec.js index e21031f70..ecaa7aabe 100644 --- a/modules/item/back/methods/item/specs/filter.spec.js +++ b/modules/item/back/methods/item/specs/filter.spec.js @@ -6,12 +6,12 @@ describe('item filter()', () => { order: 'isActive ASC, name', limit: 8 }; - let tags = [{value: 'Gem2', tagFk: 58}]; + let tags = [{value: 'combat first', tagFk: 58}]; let result = await app.models.Item.filter({args: {filter: filter, typeFk: 2, tags: tags}}); expect(result.length).toEqual(1); expect(result[0].id).toEqual(2); - expect(result[0].name).toEqual('Object2 Gem2 3'); + expect(result[0].name).toEqual('Melee weapon combat first 15cm'); expect(result[0].type).toEqual('Anthurium'); }); }); diff --git a/modules/order/back/methods/order/specs/catalogFilter.spec.js b/modules/order/back/methods/order/specs/catalogFilter.spec.js index f36f9457b..5a1ed6274 100644 --- a/modules/order/back/methods/order/specs/catalogFilter.spec.js +++ b/modules/order/back/methods/order/specs/catalogFilter.spec.js @@ -14,10 +14,10 @@ describe('order catalogFilter()', () => { let firstItemId = result[0].id; expect(result.length).toEqual(2); - expect(firstItemId).toEqual(2); + expect(firstItemId).toEqual(1); }); - it('should return an array of items based on tag filter', async() => { + it('should now return an array of items based on tag filter', async() => { let filter = { where: { categoryFk: 1, @@ -25,7 +25,7 @@ describe('order catalogFilter()', () => { } }; - let tags = [{tagFk: 56, value: 'Object2'}]; + let tags = [{tagFk: 56, value: 'Melee weapon'}]; let orderFk = 11; let orderBy = {field: 'relevancy DESC, name', way: 'DESC'}; let result = await app.models.Order.catalogFilter(orderFk, orderBy, filter, tags); diff --git a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js index 40ee40fb0..048d16c04 100644 --- a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js +++ b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js @@ -1,12 +1,12 @@ const app = require('vn-loopback/server/server'); describe('ticket listPackaging()', () => { - it('should call the listPackaging method and return the response', async () => { + it('should call the listPackaging method and return the response', async() => { let filter = {where: {packagingFk: 1}}; let response = await app.models.Packaging.listPackaging(filter); expect(response[0].name).toBeDefined(); - expect(response[0].name).toEqual('Broken Box'); + expect(response[0].name).toEqual('Container ammo box 1m'); }); }); diff --git a/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js b/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js index eb8ea615c..0d9937f89 100644 --- a/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js +++ b/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js @@ -5,7 +5,7 @@ describe('ticket listSaleTracking()', () => { let filter = {where: {ticketFk: 1}}; let result = await app.models.SaleTracking.listSaleTracking(filter); - expect(result[0].concept).toEqual('Object1 Gem1 5'); + expect(result[0].concept).toEqual('Ranged weapon longbow 2m'); }); it(`should call the listSaleTracking method and return zero if doesn't have lines`, async() => { diff --git a/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js b/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js index 7fed64ba2..b12c22084 100644 --- a/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js +++ b/modules/ticket/back/methods/sale/specs/getClaimableFromTicket.spec.js @@ -4,7 +4,7 @@ describe('sale getClaimableFromTicket()', () => { it('should return the claimable sales of a given ticket', async() => { let claimableFromTicket = await app.models.Sale.getClaimableFromTicket(16); - expect(claimableFromTicket[0].concept).toBe('Object1 Gem1 5'); + expect(claimableFromTicket[0].concept).toBe('Ranged weapon longbow 2m'); expect(claimableFromTicket.length).toBe(3); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/getSales.spec.js b/modules/ticket/back/methods/ticket/specs/getSales.spec.js index a2ea4de3f..cefa9ff4d 100644 --- a/modules/ticket/back/methods/ticket/specs/getSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getSales.spec.js @@ -9,6 +9,6 @@ describe('ticket getSales()', () => { expect(sales[1].tags).toBeDefined(); expect(sales[2].tags).toBeDefined(); expect(sales[3].tags).toBeDefined(); - expect(sales[2].claim).toBeDefined(); + expect(sales[0].claim).toBeDefined(); }); }); From 56f352686c37daa83b19bb43f6ad11eae169682f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 27 Mar 2019 08:48:13 +0100 Subject: [PATCH 2/2] added sms endpoint #1149 --- db/install/boot.sh | 6 + db/install/changes/00-smsConfig.sql | 1 + .../{01-ACL.sql => only-local/00-ACL.sql} | 0 .../00-absenceType.sql} | 0 .../00-department.sql} | 0 .../00-holiday.sql} | 0 .../00-holidayDetail.sql} | 0 .../00-holidayType.sql} | 0 .../00-mailUser.sql} | 0 .../00-nodeAdd.sql} | 0 .../00-nodeRecalc.sql} | 0 .../00-ticketCalculateSale.sql} | 0 .../00-ticketGetProblems.sql} | 0 .../00-ticketGetVisibleAvailable.sql} | 0 .../00-ticketLog.sql} | 0 .../00-workCenterHoliday.sql} | 0 .../00-workerCalendar.sql} | 0 .../00-workerLabour.sql} | 0 modules/client/back/methods/sms/send.js | 80 +++++++++ modules/client/back/model-config.json | 6 + modules/client/back/models/sms-config.json | 29 ++++ modules/client/back/models/sms.js | 4 + modules/client/back/models/sms.json | 51 ++++++ package-lock.json | 161 ++++++++++++++---- package.json | 4 +- 25 files changed, 306 insertions(+), 36 deletions(-) create mode 100644 db/install/changes/00-smsConfig.sql rename db/install/changes/{01-ACL.sql => only-local/00-ACL.sql} (100%) rename db/install/changes/{absenceType.sql => only-local/00-absenceType.sql} (100%) rename db/install/changes/{12-department.sql => only-local/00-department.sql} (100%) rename db/install/changes/{holiday.sql => only-local/00-holiday.sql} (100%) rename db/install/changes/{holidayDetail.sql => only-local/00-holidayDetail.sql} (100%) rename db/install/changes/{holidayType.sql => only-local/00-holidayType.sql} (100%) rename db/install/changes/{17-mailUser.sql => only-local/00-mailUser.sql} (100%) rename db/install/changes/{13-nodeAdd.sql => only-local/00-nodeAdd.sql} (100%) rename db/install/changes/{14-nodeRecalc.sql => only-local/00-nodeRecalc.sql} (100%) rename db/install/changes/{11-ticketCalculateSale.sql => only-local/00-ticketCalculateSale.sql} (100%) rename db/install/changes/{12-ticketGetProblems.sql => only-local/00-ticketGetProblems.sql} (100%) rename db/install/changes/{ticketGetVisibleAvailable.sql => only-local/00-ticketGetVisibleAvailable.sql} (100%) rename db/install/changes/{15-ticketLog.sql => only-local/00-ticketLog.sql} (100%) rename db/install/changes/{workCenterHoliday.sql => only-local/00-workCenterHoliday.sql} (100%) rename db/install/changes/{workerCalendar.sql => only-local/00-workerCalendar.sql} (100%) rename db/install/changes/{workerLabour.sql => only-local/00-workerLabour.sql} (100%) create mode 100644 modules/client/back/methods/sms/send.js create mode 100644 modules/client/back/models/sms-config.json create mode 100644 modules/client/back/models/sms.js create mode 100644 modules/client/back/models/sms.json diff --git a/db/install/boot.sh b/db/install/boot.sh index ebfdae87f..eb91ed8ae 100755 --- a/db/install/boot.sh +++ b/db/install/boot.sh @@ -13,6 +13,12 @@ for file in changes/*.sql; do mysql -u root -fc < $file done +# Import changes for local db +for file in changes/only-local/*.sql; do + echo "[INFO] -> Imported ./$file" + mysql -u root -fc < $file +done + # Import fixtures echo "[INFO] -> Imported ./dump/dumpedFixtures.sql" mysql -u root -f < ./dump/dumpedFixtures.sql diff --git a/db/install/changes/00-smsConfig.sql b/db/install/changes/00-smsConfig.sql new file mode 100644 index 000000000..7d2c6e1b7 --- /dev/null +++ b/db/install/changes/00-smsConfig.sql @@ -0,0 +1 @@ +INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `user`, `password`, `title`) VALUES ('1', 'https://websms.xtratelecom.es/api_php/server.wsdl', 'FERRERTORIBIO', 'HERMANOS', 'Verdnatura'); diff --git a/db/install/changes/01-ACL.sql b/db/install/changes/only-local/00-ACL.sql similarity index 100% rename from db/install/changes/01-ACL.sql rename to db/install/changes/only-local/00-ACL.sql diff --git a/db/install/changes/absenceType.sql b/db/install/changes/only-local/00-absenceType.sql similarity index 100% rename from db/install/changes/absenceType.sql rename to db/install/changes/only-local/00-absenceType.sql diff --git a/db/install/changes/12-department.sql b/db/install/changes/only-local/00-department.sql similarity index 100% rename from db/install/changes/12-department.sql rename to db/install/changes/only-local/00-department.sql diff --git a/db/install/changes/holiday.sql b/db/install/changes/only-local/00-holiday.sql similarity index 100% rename from db/install/changes/holiday.sql rename to db/install/changes/only-local/00-holiday.sql diff --git a/db/install/changes/holidayDetail.sql b/db/install/changes/only-local/00-holidayDetail.sql similarity index 100% rename from db/install/changes/holidayDetail.sql rename to db/install/changes/only-local/00-holidayDetail.sql diff --git a/db/install/changes/holidayType.sql b/db/install/changes/only-local/00-holidayType.sql similarity index 100% rename from db/install/changes/holidayType.sql rename to db/install/changes/only-local/00-holidayType.sql diff --git a/db/install/changes/17-mailUser.sql b/db/install/changes/only-local/00-mailUser.sql similarity index 100% rename from db/install/changes/17-mailUser.sql rename to db/install/changes/only-local/00-mailUser.sql diff --git a/db/install/changes/13-nodeAdd.sql b/db/install/changes/only-local/00-nodeAdd.sql similarity index 100% rename from db/install/changes/13-nodeAdd.sql rename to db/install/changes/only-local/00-nodeAdd.sql diff --git a/db/install/changes/14-nodeRecalc.sql b/db/install/changes/only-local/00-nodeRecalc.sql similarity index 100% rename from db/install/changes/14-nodeRecalc.sql rename to db/install/changes/only-local/00-nodeRecalc.sql diff --git a/db/install/changes/11-ticketCalculateSale.sql b/db/install/changes/only-local/00-ticketCalculateSale.sql similarity index 100% rename from db/install/changes/11-ticketCalculateSale.sql rename to db/install/changes/only-local/00-ticketCalculateSale.sql diff --git a/db/install/changes/12-ticketGetProblems.sql b/db/install/changes/only-local/00-ticketGetProblems.sql similarity index 100% rename from db/install/changes/12-ticketGetProblems.sql rename to db/install/changes/only-local/00-ticketGetProblems.sql diff --git a/db/install/changes/ticketGetVisibleAvailable.sql b/db/install/changes/only-local/00-ticketGetVisibleAvailable.sql similarity index 100% rename from db/install/changes/ticketGetVisibleAvailable.sql rename to db/install/changes/only-local/00-ticketGetVisibleAvailable.sql diff --git a/db/install/changes/15-ticketLog.sql b/db/install/changes/only-local/00-ticketLog.sql similarity index 100% rename from db/install/changes/15-ticketLog.sql rename to db/install/changes/only-local/00-ticketLog.sql diff --git a/db/install/changes/workCenterHoliday.sql b/db/install/changes/only-local/00-workCenterHoliday.sql similarity index 100% rename from db/install/changes/workCenterHoliday.sql rename to db/install/changes/only-local/00-workCenterHoliday.sql diff --git a/db/install/changes/workerCalendar.sql b/db/install/changes/only-local/00-workerCalendar.sql similarity index 100% rename from db/install/changes/workerCalendar.sql rename to db/install/changes/only-local/00-workerCalendar.sql diff --git a/db/install/changes/workerLabour.sql b/db/install/changes/only-local/00-workerLabour.sql similarity index 100% rename from db/install/changes/workerLabour.sql rename to db/install/changes/only-local/00-workerLabour.sql diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js new file mode 100644 index 000000000..539b6e546 --- /dev/null +++ b/modules/client/back/methods/sms/send.js @@ -0,0 +1,80 @@ +const soap = require('soap'); +const xmlParser = require('xml2js').parseString; +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('send', { + description: 'Sends SMS to a destination phone', + accepts: [{ + arg: 'recipientFk', + type: 'Integer' + }, + { + arg: 'recipient', + type: 'String', + required: true, + }, + { + arg: 'message', + type: 'String', + required: true, + }], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/send`, + verb: 'POST' + } + }); + + Self.send = async(ctx, recipientFk, recipient, message) => { + const userId = ctx.req.accessToken.userId; + const smsConfig = await Self.app.models.SmsConfig.findOne(); + const soapClient = await soap.createClientAsync(smsConfig.uri); + const params = { + user: smsConfig.user, + pass: smsConfig.password, + src: smsConfig.title, + dst: recipient, + msg: message + }; + + let xmlResponse; + let xmlResult; + let xmlParsed; + let status; + + try { + [xmlResponse] = await soapClient.sendSMSAsync(params); + xmlResult = xmlResponse.result.$value; + xmlParsed = await new Promise((resolve, reject) => { + xmlParser(xmlResult, (err, result) => { + if (err) + reject(err); + resolve(result); + }); + }); + [status] = xmlParsed['xtratelecom-sms-response'].sms; + } catch (e) { + console.error(e); + } + + const newSms = { + senderFk: userId, + destinationFk: recipientFk || null, + destination: recipient, + message: message, + statusCode: status.codigo, + status: status.descripcion + }; + + const sms = Self.create(newSms); + + if (status.codigo != 200) + throw new UserError(`We weren't able to send this SMS`); + + return sms; + }; +}; diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index ff4771330..692d1e226 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -77,6 +77,12 @@ "ClientSample": { "dataSource": "vn" }, + "Sms": { + "dataSource": "vn" + }, + "SmsConfig": { + "dataSource": "vn" + }, "TpvError": { "dataSource": "vn" }, diff --git a/modules/client/back/models/sms-config.json b/modules/client/back/models/sms-config.json new file mode 100644 index 000000000..3134f8674 --- /dev/null +++ b/modules/client/back/models/sms-config.json @@ -0,0 +1,29 @@ +{ + "name": "SmsConfig", + "description": "Sms configuration", + "base": "VnModel", + "options": { + "mysql": { + "table": "smsConfig" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "uri": { + "type": "String" + }, + "user": { + "type": "String" + }, + "password": { + "type": "String" + }, + "title": { + "type": "String" + } + } +} diff --git a/modules/client/back/models/sms.js b/modules/client/back/models/sms.js new file mode 100644 index 000000000..a823d864a --- /dev/null +++ b/modules/client/back/models/sms.js @@ -0,0 +1,4 @@ +module.exports = Self => { + // Methods + require('../methods/sms/send')(Self); +}; diff --git a/modules/client/back/models/sms.json b/modules/client/back/models/sms.json new file mode 100644 index 000000000..ec458e73d --- /dev/null +++ b/modules/client/back/models/sms.json @@ -0,0 +1,51 @@ +{ + "name": "Sms", + "description": "Sms sent to client", + "base": "VnModel", + "options": { + "mysql": { + "table": "sms" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "sender": { + "type": "String", + "required": true + }, + "destination": { + "type": "String", + "required": true + }, + "message": { + "type": "String", + "required": true + }, + "statusCode": { + "type": "Number", + "required": true + }, + "status": { + "type": "String" + }, + "created": { + "type": "Date" + } + }, + "relations": { + "sender": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "senderFk" + }, + "recipient": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "destinationFk" + } + } +} diff --git a/package-lock.json b/package-lock.json index 7c6549a1c..bce82042f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2187,8 +2187,7 @@ "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, "buffer-indexof": { "version": "1.1.1", @@ -2838,7 +2837,6 @@ "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, "requires": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", @@ -3665,17 +3663,17 @@ "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=" }, "domhandler": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.1.tgz", - "integrity": "sha1-iS5HAAqZvlW783dP/qBWHYh5wlk=", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", + "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", "requires": { "domelementtype": "1" } }, "domutils": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.6.2.tgz", - "integrity": "sha1-GVjMC0yUJuntNn+xyOhUiRsPo/8=", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz", + "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==", "requires": { "dom-serializer": "0", "domelementtype": "1" @@ -4881,7 +4879,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", - "dev": true, "requires": { "debug": "2.6.9", "encodeurl": "~1.0.1", @@ -4895,8 +4892,7 @@ "statuses": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" } } }, @@ -4953,6 +4949,11 @@ "parse-filepath": "^1.0.1" } }, + "first-chunk-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-0.1.0.tgz", + "integrity": "sha1-dV0+wU1JqG49L8wIvurVwMornAo=" + }, "flagged-respawn": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", @@ -5180,7 +5181,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5201,12 +5203,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5221,17 +5225,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5348,7 +5355,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5360,6 +5368,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5374,6 +5383,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5381,12 +5391,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5405,6 +5417,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5485,7 +5498,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5497,6 +5511,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5582,7 +5597,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5618,6 +5634,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5637,6 +5654,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5680,12 +5698,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -6799,16 +6819,41 @@ } }, "htmlparser2": { - "version": "3.9.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz", - "integrity": "sha1-G9+HrMoPP55T+k/M6w9LTLsAszg=", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", + "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", "requires": { - "domelementtype": "^1.3.0", + "domelementtype": "^1.3.1", "domhandler": "^2.3.0", "domutils": "^1.5.1", "entities": "^1.1.1", "inherits": "^2.0.1", - "readable-stream": "^2.0.2" + "readable-stream": "^3.1.1" + }, + "dependencies": { + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" + }, + "readable-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", + "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", + "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "http-deceiver": { @@ -7492,8 +7537,7 @@ "is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" }, "is-valid-glob": { "version": "1.0.0", @@ -10776,7 +10820,6 @@ "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -10945,7 +10988,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -13612,6 +13654,26 @@ } } }, + "soap": { + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/soap/-/soap-0.26.0.tgz", + "integrity": "sha512-tTS3lnGl6lfjQQuJgNnWOgC0Xa6qYQSwl2G7DX3kCdGmek/FTNmHDM/7icKP1KBMFfCrKpAWEbZiGefa92SCYw==", + "requires": { + "bluebird": "^3.5.0", + "concat-stream": "^1.5.1", + "debug": "^2.6.9", + "ejs": "~2.5.5", + "finalhandler": "^1.0.3", + "httpntlm": "^1.5.2", + "lodash": "^4.17.5", + "request": ">=2.9.0", + "sax": ">=0.6", + "serve-static": "^1.11.1", + "strip-bom": "~0.3.1", + "uuid": "^3.1.0", + "xml-crypto": "~0.8.0" + } + }, "socket.io": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", @@ -14229,6 +14291,15 @@ "ansi-regex": "^2.0.0" } }, + "strip-bom": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-0.3.1.tgz", + "integrity": "sha1-noo57/RW/5q8LwWfXyIluw8/fKU=", + "requires": { + "first-chunk-stream": "^0.1.0", + "is-utf8": "^0.2.0" + } + }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -15138,8 +15209,7 @@ "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "uglify-js": { "version": "3.4.9", @@ -16634,6 +16704,22 @@ "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", "dev": true }, + "xml-crypto": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/xml-crypto/-/xml-crypto-0.8.5.tgz", + "integrity": "sha1-K7z7PrM/OoKiGLgiv2craxwg5Tg=", + "requires": { + "xmldom": "=0.1.19", + "xpath.js": ">=0.0.3" + }, + "dependencies": { + "xmldom": { + "version": "0.1.19", + "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.19.tgz", + "integrity": "sha1-Yx/Ad3bv2EEYvyUXGzftTQdaCrw=" + } + } + }, "xml2js": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", @@ -16645,7 +16731,7 @@ }, "xmlbuilder": { "version": "9.0.7", - "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, "xmlcreate": { @@ -16665,6 +16751,11 @@ "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", "dev": true }, + "xpath.js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xpath.js/-/xpath.js-1.1.0.tgz", + "integrity": "sha512-jg+qkfS4K8E7965sqaUl8mRngXiKb3WZGfONgE18pr03FUQiuSV6G+Ej4tS55B+rIQSFEIw3phdVAQ4pPqNWfQ==" + }, "xregexp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", diff --git a/package.json b/package.json index 5a2ae2a94..fa63013f7 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,11 @@ "request": "^2.88.0", "request-promise-native": "^1.0.7", "require-yaml": "0.0.1", + "soap": "^0.26.0", "strong-error-handler": "^2.3.2", "uuid": "^3.3.2", - "vn-loopback": "file:./loopback" + "vn-loopback": "file:./loopback", + "xml2js": "^0.4.19" }, "devDependencies": { "@babel/core": "^7.3.3",