From 1b1bca28bd429e246ff0af0cfc0488606baa6999 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 22 Mar 2023 10:13:59 +0100 Subject: [PATCH] refs #5410 add frontTest --- CHANGELOG.md | 4 +- db/changes/231201/00-mailACL.sql | 2 + modules/client/front/defaulter/index.spec.js | 43 +++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 db/changes/231201/00-mailACL.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 708fd7bd9..65ed1f645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- (Clientes -> Morosos) Ahora se puede filtrar por las columnas "Desde" y "Fecha Ú. O." +- (Clientes -> Morosos) Ahora se puede filtrar por las columnas "Desde" y "Fecha Ú. O.". También se envia un email al comercial cuando se añade una nota. ### Changed - ### Fixed -- +- (Clientes -> Morosos) Ahora se mantienen los elementos seleccionados al hacer sroll. ## [2310.01] - 2023-03-23 diff --git a/db/changes/231201/00-mailACL.sql b/db/changes/231201/00-mailACL.sql new file mode 100644 index 000000000..ac687818d --- /dev/null +++ b/db/changes/231201/00-mailACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId) +VALUES('Mail', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index 6b80a7c36..30c40132d 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -80,15 +80,17 @@ describe('client defaulter', () => { controller.defaulter = {observation: 'My new observation'}; const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}]; + const mailParams = [{subject: 'Comment added to client', body: 'Added observation', receiver: 'undefined@verdnatura.es', replyTo: 'undefined@verdnatura.es'}]; jest.spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('GET', `Defaulters/filter`).respond(200); $httpBackend.expect('POST', `ClientObservations`, params).respond(200, params); + $httpBackend.expect('POST', `Mails`, mailParams).respond(200); controller.onResponse(); $httpBackend.flush(); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Observation saved!'); + expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Email sended!'); }); }); @@ -135,5 +137,44 @@ describe('client defaulter', () => { expect(end).toContain('23:59:59'); }); }); + + describe('reCheck()', () => { + it(`should recheck buys`, () => { + controller.$.model.data = [ + {checked: false, clientFk: 1}, + {checked: false, clientFk: 2}, + {checked: false, clientFk: 3}, + {checked: false, clientFk: 4}, + ]; + controller.checkedDefaulers = [1, 2]; + + controller.reCheck(); + + expect(controller.$.model.data[0].checked).toEqual(true); + expect(controller.$.model.data[1].checked).toEqual(true); + expect(controller.$.model.data[2].checked).toEqual(false); + expect(controller.$.model.data[3].checked).toEqual(false); + }); + }); + + describe('saveChecked()', () => { + it(`should check buy`, () => { + const buyCheck = 3; + controller.checkedDefaulers = [1, 2]; + + controller.saveChecked(buyCheck); + + expect(controller.checkedDefaulers[2]).toEqual(buyCheck); + }); + + it(`should uncheck buy`, () => { + const buyUncheck = 3; + controller.checkedDefaulers = [1, 2, 3]; + + controller.saveChecked(buyUncheck); + + expect(controller.checkedDefaulers[2]).toEqual(undefined); + }); + }); }); });