From 4e329a42013341e042924f3715ec3912f4917741 Mon Sep 17 00:00:00 2001 From: Bernat Date: Wed, 31 Jul 2019 07:46:24 +0200 Subject: [PATCH] Bug/Test #1607 ticket.updateDiscount and fix test --- db/dump/fixtures.sql | 3 ++- e2e/paths/03-worker-module/02_time_control.spec.js | 1 + modules/ticket/back/methods/ticket-request/confirm.js | 2 +- .../ticket/back/methods/ticket-request/specs/confirm.spec.js | 4 ++-- .../ticket/back/methods/ticket-request/specs/filter.spec.js | 2 +- modules/ticket/back/methods/ticket/getSales.js | 1 - modules/ticket/front/sale/index.html | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 3fecb432e..821df10d5 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1446,7 +1446,8 @@ INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `atenderFk` (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, NULL, 1.30, NULL, NULL, 11, CURDATE()); + (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()), + (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, CURDATE()); INSERT INTO `vn`.`ticketServiceType`(`id`, `name`) VALUES diff --git a/e2e/paths/03-worker-module/02_time_control.spec.js b/e2e/paths/03-worker-module/02_time_control.spec.js index 89273d26c..b6d6d1754 100644 --- a/e2e/paths/03-worker-module/02_time_control.spec.js +++ b/e2e/paths/03-worker-module/02_time_control.spec.js @@ -381,6 +381,7 @@ describe('Worker time control path', () => { it(`should check Hank Pym doesn't have hours set on the next months first week`, async() => { const wholeWeekHours = await nightmare + .waitToClick(selectors.workerTimeControl.nextMonthButton) .waitToClick(selectors.workerTimeControl.nextMonthButton) .waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText'); diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 02d1a33c5..92dd06dae 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -53,7 +53,7 @@ module.exports = Self => { false ]); - if (stock.available < ctx.args.quantity) + if (stock.available < 0) throw new UserError(`This item is not available`); diff --git a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js index cab7e8b8b..574469d86 100644 --- a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js @@ -39,8 +39,8 @@ describe('ticket-request confirm()', () => { }); it(`should throw an error if the item is not available`, async() => { - const requestId = 4; - const itemId = 1; + const requestId = 5; + const itemId = 4; const quantity = 99999; let ctx = {req: {accessToken: {userId: 9}}, args: { 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 ae73eb1da..24e74e4df 100644 --- a/modules/ticket/back/methods/ticket-request/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/filter.spec.js @@ -6,7 +6,7 @@ describe('ticket-request filter()', () => { let result = await app.models.TicketRequest.filter(ctx); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); }); it('should return the ticket request matching a generic search value which is the ticket ID', async() => { diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index 0c33d9db9..b59d678f2 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -54,7 +54,6 @@ module.exports = Self => { line.item = map[line.itemFk]; line.claim = claimMap[line.id]; } - return lines; }; }; diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index f1266bede..993b81003 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -86,7 +86,7 @@