diff --git a/db/changes/10190-PostErte/00-ACL.sql b/db/changes/10190-PostErte/00-ACL.sql index d19901d48..2a2673fcc 100644 --- a/db/changes/10190-PostErte/00-ACL.sql +++ b/db/changes/10190-PostErte/00-ACL.sql @@ -1 +1,4 @@ UPDATE `salix`.`ACL` SET `accessType`='WRITE' WHERE `id`='213'; + +INSERT IGNORE INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('CustomsAgent', '*', '*', 'ALLOW', 'ROLE', 'employee'); + diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2f36dc584..b12c470f5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -122,6 +122,12 @@ export default { 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"]', + 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"]', 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', diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index 2fe238fea..f16408b34 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -61,12 +61,18 @@ describe('Client Add address path', () => { expect(message.text).toBe('Customs agent is required for a non UEE member'); }); - it(`should create a new address with all it's data`, async() => { - await page.autocompleteSearch(selectors.clientAddresses.customsAgent, 'Agent one'); + it(`should create a new custom agent and then save the address`, async() => { + await page.waitToClick(selectors.clientAddresses.addNewCustomsAgent); + await page.write(selectors.clientAddresses.newCustomsAgentFiscalID, 'ID'); + await page.write(selectors.clientAddresses.newCustomsAgentFiscalName, 'name'); + await page.write(selectors.clientAddresses.newCustomsAgentStreet, 'street'); + await page.write(selectors.clientAddresses.newCustomsAgentPhone, '555555555'); + await page.waitToClick(selectors.clientAddresses.saveNewCustomsAgentButton); + await page.waitToClick(selectors.clientAddresses.saveButton); const message = await page.waitForSnackbar(); - expect(message.type).toBe('success'); + expect(message.text).toBe('Data saved!'); }); it(`should navigate back to the addresses index`, async() => { diff --git a/modules/client/front/address/create/index.js b/modules/client/front/address/create/index.js index b1629073d..79774cf93 100644 --- a/modules/client/front/address/create/index.js +++ b/modules/client/front/address/create/index.js @@ -29,7 +29,7 @@ export default class Controller extends Section { onCustomAgentAccept() { return this.$http.post(`CustomsAgents`, this.newCustomsAgent) - .then(res => this.address.customsAgentFk = res.data.id); + .then(res => this.address.customsAgentId = res.data.id); } get town() { diff --git a/modules/client/front/address/create/index.spec.js b/modules/client/front/address/create/index.spec.js index fb6567dce..4f332e75e 100644 --- a/modules/client/front/address/create/index.spec.js +++ b/modules/client/front/address/create/index.spec.js @@ -123,7 +123,7 @@ describe('Client', () => { controller.onCustomAgentAccept(); $httpBackend.flush(); - expect(controller.address.customsAgentFk).toEqual(1); + expect(controller.address.customsAgentId).toEqual(1); }); }); }); diff --git a/modules/client/front/address/edit/index.spec.js b/modules/client/front/address/edit/index.spec.js index b67138b6d..c4c1a78b5 100644 --- a/modules/client/front/address/edit/index.spec.js +++ b/modules/client/front/address/edit/index.spec.js @@ -64,7 +64,7 @@ describe('Client', () => { }); describe('onCustomAgentAccept()', () => { - it(`should create a new customs agent and then set the customsAgentFk property on the address`, () => { + it(`should now create a new customs agent and then set the customsAgentFk property on the address`, () => { const expectedResult = {id: 1, fiscalName: 'Customs agent one'}; $httpBackend.when('POST', 'CustomsAgents').respond(200, expectedResult); controller.onCustomAgentAccept();