From b0ec7ce15b7b8c905db78e2666827ed548e223e7 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 28 Jan 2020 11:56:26 +0100 Subject: [PATCH] updated e2e --- e2e/helpers/puppeteer.js | 1 + e2e/helpers/selectors.js | 6 +++-- .../02-client-module/05_add_address.spec.js | 21 ++++++++++++++-- .../client/front/address/create/index.html | 14 +++++------ modules/client/front/address/create/index.js | 7 ++++++ modules/client/front/address/edit/index.html | 24 +++++++++---------- modules/client/front/address/edit/index.js | 7 ++++++ 7 files changed, 57 insertions(+), 23 deletions(-) diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index cd445bdbe..01496be20 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -6,6 +6,7 @@ import {url as defaultURL} from './config'; export async function getBrowser() { const browser = await Puppeteer.launch({ args: [ + '--no-sandbox', `--window-size=${ 1920 },${ 1080 }` ], defaultViewport: null, diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f6bdcf1b7..282fb8bab 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -103,11 +103,13 @@ export default { streetAddressInput: '[ng-model="$ctrl.address.street"]', postcodeInput: '[ng-model="$ctrl.address.postalCode"]', cityInput: '[ng-model="$ctrl.address.city"]', - provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.provinceFk"]', - agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeFk"]', + provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.provinceId"]', + agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeId"]', phoneInput: '[ng-model="$ctrl.address.phone"]', mobileInput: '[ng-model="$ctrl.address.mobile"]', defaultAddress: 'vn-client-address-index div:nth-child(1) div[name="street"]', + incotermsAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.incotermsId"]', + customsAgentAutocomplete: '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', secondEditAddress: 'vn-client-address-index div:nth-child(2) > a', diff --git a/e2e/paths/02-client-module/05_add_address.spec.js b/e2e/paths/02-client-module/05_add_address.spec.js index 67afbfdbe..8eb4a86bf 100644 --- a/e2e/paths/02-client-module/05_add_address.spec.js +++ b/e2e/paths/02-client-module/05_add_address.spec.js @@ -26,7 +26,7 @@ describe('Client Add address path', () => { it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => { await page.waitToClick(selectors.clientAddresses.defaultCheckboxInput); - await page.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one'); + await page.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province five'); await page.write(selectors.clientAddresses.cityInput, 'Valencia'); await page.write(selectors.clientAddresses.postcodeInput, '46000'); await page.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement'); @@ -38,12 +38,29 @@ describe('Client Add address path', () => { expect(result).toEqual('Some fields are invalid'); }); - it(`should create a new address with all it's data`, async() => { + + it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => { await page.write(selectors.clientAddresses.consigneeInput, 'Bruce Bunner'); await page.write(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York'); await page.waitToClick(selectors.clientAddresses.saveButton); const result = await page.waitForLastSnackbar(); + expect(result).toEqual('Incoterms is required for a non UEE member'); + }); + + it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => { + await page.autocompleteSearch(selectors.clientAddresses.incotermsAutocomplete, 'Free Alongside Ship'); + await page.waitToClick(selectors.clientAddresses.saveButton); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('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.customsAgentAutocomplete, 'Agent one'); + await page.waitToClick(selectors.clientAddresses.saveButton); + const result = await page.waitForLastSnackbar(); + expect(result).toEqual('Data saved!'); }); diff --git a/modules/client/front/address/create/index.html b/modules/client/front/address/create/index.html index fabc12bf9..1c70a1cbd 100644 --- a/modules/client/front/address/create/index.html +++ b/modules/client/front/address/create/index.html @@ -131,14 +131,14 @@ show-field="fiscalName" value-field="id" label="Customs agent"> + + + + - - diff --git a/modules/client/front/address/create/index.js b/modules/client/front/address/create/index.js index 95e67f7e9..f21ec73ff 100644 --- a/modules/client/front/address/create/index.js +++ b/modules/client/front/address/create/index.js @@ -40,6 +40,13 @@ export default class Controller extends Component { }); } + showCustomAgent(event) { + if (event.defaultPrevented) return; + event.preventDefault(); + + this.$.customAgent.show(); + } + onCustomAgentAccept() { return this.$http.post(`CustomsAgents`, this.newCustomsAgent) .then(res => this.address.customsAgentFk = res.data.id); diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index ed331de2e..035608120 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -15,7 +15,7 @@ vn-id="model" url="AddressObservations" fields="['id', 'addressFk', 'observationTypeFk', 'description']" - link="{addressFk: $ctrl.$stateParams.addressId}" + link="{addressFk: $ctrl.$params.addressId}" data="observations" auto-load="true"> @@ -59,7 +59,7 @@ + + + + - - Notes
diff --git a/modules/client/front/address/edit/index.js b/modules/client/front/address/edit/index.js index df0f33256..4e5ed7237 100644 --- a/modules/client/front/address/edit/index.js +++ b/modules/client/front/address/edit/index.js @@ -28,6 +28,13 @@ export default class Controller extends Component { }); } + showCustomAgent(event) { + if (event.defaultPrevented) return; + event.preventDefault(); + + this.$.customAgent.show(); + } + onCustomAgentAccept() { return this.$http.post(`CustomsAgents`, this.newCustomsAgent) .then(res => this.address.customsAgentFk = res.data.id);