From e8a178d5f407d53448f1e29c14d32a9e804c822d Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 12 Feb 2020 14:36:05 +0100 Subject: [PATCH] #2006 e2e route.summary plus refactors --- db/dump/fixtures.sql | 26 ++++---- e2e/helpers/extensions.js | 23 +++---- e2e/helpers/puppeteer.js | 12 ++++ e2e/helpers/selectors.js | 8 ++- e2e/paths/02-client/14_balance.spec.js | 2 +- e2e/paths/02-client/17_dms.spec.js | 2 +- e2e/paths/04-item/01_summary.spec.js | 7 +-- e2e/paths/04-item/09_regularize.spec.js | 3 +- e2e/paths/06-claim/05_summary.spec.js | 6 +- e2e/paths/08-route/01_summary.spec.js | 61 +++++++++++++++++++ .../{01_create.spec.js => 03_create.spec.js} | 1 - ...{03_tickets.spec.js => 04_tickets.spec.js} | 0 front/core/module.js | 2 +- modules/route/front/summary/index.html | 4 +- 14 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 e2e/paths/08-route/01_summary.spec.js rename e2e/paths/08-route/{01_create.spec.js => 03_create.spec.js} (98%) rename e2e/paths/08-route/{03_tickets.spec.js => 04_tickets.spec.js} (100%) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7b7651a9d..ef913eb21 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -35,7 +35,7 @@ INSERT INTO `vn`.`packagingConfig`(`upperGap`) UPDATE `account`.`role` SET id = 100 WHERE id = 0; INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`) - SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'es' + SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'EN' FROM `account`.`role` WHERE id <> 20 ORDER BY id; @@ -55,18 +55,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`) VALUES - (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es'), - (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en'), - (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr'), - (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'es'), - (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt'), - (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'es'), - (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'es'), - (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'es'), - (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'es'), - (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'es'), - (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'es'), - (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'es'); + (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'ES'), + (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'EN'), + (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'FR'), + (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'ES'), + (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'PT'), + (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'EN'), + (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'EN'), + (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'EN'), + (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'EN'), + (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'EN'), + (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'), + (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'); INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) VALUES diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index ea8f50626..816eea064 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -1,4 +1,3 @@ -/* eslint no-invalid-this: "off" */ import {url as defaultURL} from './config'; let actions = { @@ -31,20 +30,6 @@ let actions = { }, selector); }, - changeLanguageToEnglish: async function() { - let langSelector = '.user-popover vn-autocomplete[ng-model="$ctrl.lang"]'; - - await this.waitToClick('#user'); - await this.waitForSelector(`${langSelector} input`, {}); - - let lang = await this.waitToGetProperty(langSelector, 'value'); - if (lang !== 'English') - await this.autocompleteSearch(langSelector, 'English'); - - await this.keyboard.press('Escape'); - await this.waitForSelector(langSelector, {hidden: true}); - }, - doLogin: async function(userName, password = 'nightmare') { await this.waitForSelector(`vn-login vn-textfield[ng-model="$ctrl.user"]`, {visible: true}); await this.clearInput(`vn-login vn-textfield[ng-model="$ctrl.user"]`); @@ -70,7 +55,6 @@ let actions = { await this.waitForFunction(() => { return document.location.hash === '#!/'; }, {}); - await this.changeLanguageToEnglish(); }, selectModule: async function(moduleName) { @@ -534,6 +518,13 @@ let actions = { }, selector); }, + closePopup: async function(selector) { + await Promise.all([ + this.keyboard.press('Escape'), + this.waitForSelector('.vn-popup', {hidden: true}), + ]); + }, + waitForContentLoaded: async function() { await this.waitFor(1000); // to be implemented in base of a directive loaded once al modules are done loading, further investigation required. diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index 351a26669..ed05909d0 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -15,6 +15,18 @@ export async function getBrowser() { slowMo: 0, // slow down by ms }); let page = (await browser.pages())[0]; + await page.evaluateOnNewDocument(() => { + Object.defineProperty(navigator, 'language', { + get: function() { + return 'en'; + } + }); + Object.defineProperty(navigator, 'languages', { + get: function() { + return ['en']; + } + }); + }); page = extendPage(page); page.setDefaultTimeout(5000); await page.goto(defaultURL, {waitUntil: 'networkidle0'}); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index ed232ef3b..564745752 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -643,7 +643,13 @@ export default { volume: 'vn-route-descriptor vn-label-value[label="Volume"] > section > span' }, routeSummary: { - routeId: 'vn-route-summary > vn-card > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span' + header: 'vn-route-summary > vn-card > h5', + routeId: 'vn-route-summary > vn-card > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span', + cost: 'vn-route-summary vn-label-value[label="Cost"]', + firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(2) > span', + firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor', + firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span', + firstClientDescriptor: '.vn-popover.shown vn-client-descriptor', }, routeBasicData: { worker: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.workerFk"]', diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index 52d179383..f45937deb 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -39,7 +39,7 @@ describe('Client balance path', () => { }); it('should click the new payment button', async() => { - await page.keyboard.press('Escape'); + await page.closePopup(); await page.reloadSection('client.card.balance.index'); let url = await page.expectURL('/balance'); diff --git a/e2e/paths/02-client/17_dms.spec.js b/e2e/paths/02-client/17_dms.spec.js index 01a197c84..9891fd3f4 100644 --- a/e2e/paths/02-client/17_dms.spec.js +++ b/e2e/paths/02-client/17_dms.spec.js @@ -27,7 +27,7 @@ describe('Client DMS', () => { it(`should click on the first document line worker name making the descriptor visible`, async() => { await page.waitToClick(selectors.dms.firstDocWorker); - await page.wait(selectors.dms.firstDocWorkerDescriptor); + await page.waitForSelector(selectors.dms.firstDocWorkerDescriptor); const visible = await page.isVisible(selectors.dms.firstDocWorkerDescriptor); expect(visible).toBeTruthy(); diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js index 0196e0930..97fef9ca9 100644 --- a/e2e/paths/04-item/01_summary.spec.js +++ b/e2e/paths/04-item/01_summary.spec.js @@ -68,9 +68,8 @@ describe('Item summary path', () => { }); it(`should close the summary popup`, async() => { - await page.keyboard.press('Escape'); - await page.waitUntilNotPresent(selectors.itemSummary.basicData); - await page.waitFor(selectors.itemSummary.basicData, {hidden: true}); + await page.closePopup(); + await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); }); it('should search for other item', async() => { @@ -125,7 +124,7 @@ describe('Item summary path', () => { }); it(`should now close the summary popup`, async() => { - await page.keyboard.press('Escape'); + await page.closePopup(); await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); }); diff --git a/e2e/paths/04-item/09_regularize.spec.js b/e2e/paths/04-item/09_regularize.spec.js index e43429aa0..7f63694b9 100644 --- a/e2e/paths/04-item/09_regularize.spec.js +++ b/e2e/paths/04-item/09_regularize.spec.js @@ -27,8 +27,7 @@ describe('Item regularize path', () => { const userLocalWarehouse = await page .waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value'); - await page.keyboard.press('Escape'); - await page.waitForSelector('.user-popover.vn-popover', {hidden: true}); + await page.closePopup(); expect(userLocalWarehouse).toContain('Warehouse Four'); }); diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index a9d97533c..9dab65954 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -60,8 +60,7 @@ describe('claim Summary path', () => { it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => { await page.waitForSelector(selectors.claimSummary.itemDescriptorPopoverItemDiaryButton, {visible: true}); - await page.keyboard.press('Escape'); - await page.waitFor(1000); + await page.closePopup(); }); it('should display the claim development details', async() => { @@ -81,8 +80,7 @@ describe('claim Summary path', () => { it(`should check the url for the go to clientlink of the descriptor is for the right client id`, async() => { await page.waitForSelector(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton, {visible: true}); - await page.keyboard.press('Escape'); - await page.waitFor(1000); + await page.closePopup(); }); it(`should click on the first action ticket ID making the ticket descriptor visible`, async() => { diff --git a/e2e/paths/08-route/01_summary.spec.js b/e2e/paths/08-route/01_summary.spec.js new file mode 100644 index 000000000..c062b9b08 --- /dev/null +++ b/e2e/paths/08-route/01_summary.spec.js @@ -0,0 +1,61 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Route summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'route'); + await page.waitToClick('vn-route-index vn-tbody > a:nth-child(1)'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the first route summary section', async() => { + let url = await page.expectURL('#!/route/1/summary'); + + expect(url).toBe(true); + }); + + it(`should display details from the route on the header`, async() => { + await page.waitForTextInElement(selectors.routeSummary.header, 'first route'); + const result = await page.waitToGetProperty(selectors.routeSummary.header, 'innerText'); + + expect(result).toContain('first route'); + }); + + it('should display some route details like the cost', async() => { + const result = await page.waitToGetProperty(selectors.routeSummary.cost, 'innerText'); + + expect(result).toContain('€10.00'); + }); + + it('should click on the first ticket ID making the descriptor popover visible', async() => { + await page.waitToClick(selectors.routeSummary.firstTicketID); + await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor); + const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor); + + expect(visible).toBe(true); + }); + + it('should close the ticket descriptor', async() => { + await page.closePopup(); + }); + + it('should click on the first alias making the client descriptor popover visible', async() => { + await page.waitToClick(selectors.routeSummary.firstAlias); + await page.waitForSelector(selectors.routeSummary.firstClientDescriptor); + const visible = await page.isVisible(selectors.routeSummary.firstClientDescriptor); + + expect(visible).toBe(true); + }); + + it('should close the client descriptor', async() => { + await page.closePopup(); + }); +}); diff --git a/e2e/paths/08-route/01_create.spec.js b/e2e/paths/08-route/03_create.spec.js similarity index 98% rename from e2e/paths/08-route/01_create.spec.js rename to e2e/paths/08-route/03_create.spec.js index 14d5273b3..11ffd500b 100644 --- a/e2e/paths/08-route/01_create.spec.js +++ b/e2e/paths/08-route/03_create.spec.js @@ -37,7 +37,6 @@ describe('Route create path', () => { beforeAll(async() => { await page.login('delivery'); await page.selectModule('route'); - await page.changeLanguageToEnglish(); }); it('should again click on the add new route button and open the creation form', async() => { diff --git a/e2e/paths/08-route/03_tickets.spec.js b/e2e/paths/08-route/04_tickets.spec.js similarity index 100% rename from e2e/paths/08-route/03_tickets.spec.js rename to e2e/paths/08-route/04_tickets.spec.js diff --git a/front/core/module.js b/front/core/module.js index 0c52fd565..82a954892 100644 --- a/front/core/module.js +++ b/front/core/module.js @@ -80,7 +80,7 @@ export function config($translateProvider, $translatePartialLoaderProvider, $ani let langs = ['en', 'es']; let langAliases = { en_US: 'en', - en_UK: 'en', + en_GB: 'en', es_ES: 'es', es_AR: 'es' }; diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 0ec6c47fe..527f7fe96 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -84,8 +84,8 @@ {{ticket.packages}} {{ticket.volume}} {{ticket.warehouse.name}} - {{ticket.client.postcode}} - {{ticket.client.street}} + {{ticket.address.postalCode}} + {{ticket.address.street}}