From a61a6e7c6ab4c9e85a8ad508cd5bce0628d3feae Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 19 Oct 2020 20:49:38 +0200 Subject: [PATCH] e2e path updated + test fix --- e2e/helpers/selectors.js | 13 +++++- e2e/paths/02-client/01_create_client.spec.js | 42 +++++++++++++++---- e2e/paths/12-entry/04_create.spec.js | 4 +- modules/client/front/postcode/city/index.html | 2 +- modules/client/front/postcode/index.html | 2 +- .../client/front/postcode/province/index.html | 2 +- 6 files changed, 52 insertions(+), 13 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index e586f38ed..3bcce51a2 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -42,13 +42,24 @@ export default { taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]', socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]', street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]', + addPostCode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"] vn-icon-button[icon="add_circle"]', + addProvince: 'vn-autocomplete[ng-model="$ctrl.location.provinceFk"] vn-icon-button[icon="add_circle"]', + addCity: 'vn-autocomplete[ng-model="$ctrl.location.townFk"] vn-icon-button[icon="add_circle"]', + newProvinceName: 'vn-textfield[ng-model="$ctrl.province.name"]', + newCityName: 'vn-textfield[ng-model="$ctrl.city.name"]', + newCityProvince: 'vn-autocomplete[ng-model="$ctrl.city.provinceFk"]', + newPostcode: 'vn-textfield[ng-model="$ctrl.location.code"]', postcode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"]', city: 'vn-client-create vn-datalist[ng-model="$ctrl.client.city"]', - province: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', + province: 'vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]', + dialogCountry: 'vn-autocomplete[ng-model="$ctrl.province.countryFk"]', userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]', email: 'vn-client-create vn-textfield[ng-model="$ctrl.client.email"]', salesPerson: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', + saveNewProvicenButton: '#saveProvince', + saveNewCityButton: '#saveCity', + saveNewPoscode: '#savePostcode', createButton: 'vn-client-create button[type=submit]' }, clientDescriptor: { diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index f7a996f48..202f27064 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -8,7 +8,7 @@ describe('Client create path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('employee', 'client'); + await page.loginAndModule(' deliveryBoss', 'client'); }); afterAll(async() => { @@ -45,14 +45,40 @@ describe('Client create path', () => { expect(message.text).toBe('Some fields are invalid'); }); + it(`should create a new province`, async() => { + await page.waitToClick(selectors.createClientView.addPostCode); + await page.waitToClick(selectors.createClientView.addProvince); + await page.write(selectors.createClientView.newProvinceName, 'Massachusetts'); + await page.autocompleteSearch(selectors.createClientView.dialogCountry, 'España'); + await page.waitToClick(selectors.createClientView.saveNewProvicenButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toBe('The province has been created'); + }); + + it(`should create a new city`, async() => { + await page.waitToClick(selectors.createClientView.addCity); + await page.write(selectors.createClientView.newCityName, 'Boston'); + await page.autocompleteSearch(selectors.createClientView.newCityProvince, 'Massachusetts'); + await page.waitToClick(selectors.createClientView.saveNewCityButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toBe('The city has been created'); + }); + + it(`should create a new post code`, async() => { + await page.write(selectors.createClientView.newPostcode, '61616'); + await page.waitToClick(selectors.createClientView.saveNewPoscode); + + const message = await page.waitForSnackbar(); + + expect(message.text).toBe('The postcode has been created. You can save the data now'); + }); + it(`should attempt to create a new user with all it's data but wrong email`, async() => { await page.write(selectors.createClientView.name, 'Carol Danvers'); await page.write(selectors.createClientView.socialName, 'AVG tax'); await page.write(selectors.createClientView.street, 'Many places'); - await page.autocompleteSearch(selectors.createClientView.country, 'España'); - await page.autocompleteSearch(selectors.createClientView.province, 'Province one'); - await page.write(selectors.createClientView.city, 'Valencia'); - await page.write(selectors.createClientView.postcode, '46000'); await page.clearInput(selectors.createClientView.email); await page.write(selectors.createClientView.email, 'incorrect email format'); await page.waitToClick(selectors.createClientView.createButton); @@ -82,14 +108,14 @@ describe('Client create path', () => { const clientCountry = await page .waitToGetProperty(selectors.createClientView.country, 'value'); - expect(clientCity).toEqual('Valencia'); - expect(clientProvince).toContain('Province one'); + expect(clientCity).toEqual('Boston'); + expect(clientProvince).toContain('Massachusetts'); expect(clientCountry).toEqual('España'); }); it(`should create a new user with all correct data`, async() => { await page.clearInput(selectors.createClientView.postcode); - await page.write(selectors.createClientView.postcode, '46000'); + await page.write(selectors.createClientView.postcode, '61616'); await page.waitToClick(selectors.createClientView.createButton); const message = await page.waitForSnackbar(); diff --git a/e2e/paths/12-entry/04_create.spec.js b/e2e/paths/12-entry/04_create.spec.js index 8cf23813b..20fa6b23d 100644 --- a/e2e/paths/12-entry/04_create.spec.js +++ b/e2e/paths/12-entry/04_create.spec.js @@ -26,7 +26,9 @@ describe('Entry create path', () => { await page.autocompleteSearch(selectors.entryIndex.newEntryCompany, 'ORN'); await page.waitToClick(selectors.entryIndex.saveNewEntry); - await page.waitFor(500); + await page.waitForNavigation({ + waitUntil: 'load', + }); await page.waitForState('entry.card.basicData'); }); }); diff --git a/modules/client/front/postcode/city/index.html b/modules/client/front/postcode/city/index.html index f84632792..a83505222 100644 --- a/modules/client/front/postcode/city/index.html +++ b/modules/client/front/postcode/city/index.html @@ -22,6 +22,6 @@ - + \ No newline at end of file diff --git a/modules/client/front/postcode/index.html b/modules/client/front/postcode/index.html index ca4e10a03..8f9f35eb8 100644 --- a/modules/client/front/postcode/index.html +++ b/modules/client/front/postcode/index.html @@ -61,7 +61,7 @@ - + diff --git a/modules/client/front/postcode/province/index.html b/modules/client/front/postcode/province/index.html index e7338575c..03836901c 100644 --- a/modules/client/front/postcode/province/index.html +++ b/modules/client/front/postcode/province/index.html @@ -22,6 +22,6 @@ - + \ No newline at end of file