From dbe6161c69b1961446f0d5670e0df6f70ef83fc8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 16 Oct 2019 09:54:02 +0200 Subject: [PATCH] Tests fixed --- e2e/helpers/extensions.js | 25 +++++++++++++------ e2e/helpers/selectors.js | 4 +-- .../05-ticket-module/12_descriptor.spec.js | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 022b282d3..ee964b534 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -12,6 +12,7 @@ let asyncActions = { clickIfExists: async function(selector) { let exists = await this.exists(selector); if (exists) await this.click(selector); + return exists; }, // Salix specific extensions @@ -29,8 +30,16 @@ let asyncActions = { login: async function(userName) { if (currentUser !== userName) { - this.clickIfExists('#logout') - .clickIfExists('.vn-dialog.shown button[response=ACCEPT]'); + let logoutClicked = await this.clickIfExists('#logout'); + + if (logoutClicked) { + let buttonSelector = '.vn-dialog.shown button[response=ACCEPT]'; + this.wait(buttonSelector => { + return document.querySelector(buttonSelector) != null + || location.hash == '#!/login'; + }, buttonSelector); + await this.clickIfExists(buttonSelector); + } try { await this.waitForURL('#!/login'); @@ -86,7 +95,7 @@ let asyncActions = { pickTime: async function(selector, time) { await this.wait(selector) .evaluate((selector, time) => { - let input = document.querySelector(selector); + let input = document.querySelector(selector).$ctrl.input; input.value = time; input.dispatchEvent(new Event('change')); }, selector, time); @@ -481,11 +490,6 @@ let actions = { }, }; -Object.keys(actions).forEach(function(name) { - let fn = actions[name]; - Nightmare.action(name, fn); -}); - for (let name in asyncActions) { let fn = asyncActions[name]; @@ -495,3 +499,8 @@ for (let name in asyncActions) { .then(res => done(null, res), done); }); } + +Object.keys(actions).forEach(function(name) { + let fn = actions[name]; + Nightmare.action(name, fn); +}); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 4d1c4f3e9..bc68f96e4 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -363,7 +363,7 @@ export default { moreMenuMakeInvoice: '.vn-popover.shown .vn-drop-down li[name="Make invoice"]', moreMenuChangeShippedHour: '.vn-popover.shown .vn-drop-down li[name="Change shipped hour"]', changeShippedHourDialog: 'vn-ticket-descriptor vn-dialog[vn-id="changeShippedDialog"]', - changeShippedHourInput: 'vn-ticket-descriptor vn-dialog[vn-id="changeShippedDialog"] vn-input-time[vn-id="newShipped"]', + changeShippedHourInput: 'vn-dialog[vn-id="changeShippedDialog"] [ng-model="$ctrl.newShipped"]', addStowawayDialogFirstTicket: 'vn-ticket-descriptor > vn-add-stowaway > vn-dialog vn-table vn-tbody vn-tr', shipButton: 'vn-ticket-descriptor > div > div.body > div.quicklinks vn-icon[icon="icon-stowaway"]', thursdayButton: 'vn-ticket-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-tool-bar > vn-button:nth-child(4)', @@ -671,7 +671,7 @@ export default { saveButton: 'vn-worker-pbx vn-submit[label="Save"] input' }, workerTimeControl: { - timeDialogInput: 'vn-worker-time-control > vn-dialog input', + timeDialogInput: '.vn-dialog.shown [ng-model="$ctrl.newTime"]', mondayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button > button > vn-icon', tuesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button > button > vn-icon', wednesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button > button > vn-icon', diff --git a/e2e/paths/05-ticket-module/12_descriptor.spec.js b/e2e/paths/05-ticket-module/12_descriptor.spec.js index 5c80bbfe8..b9c6c7c87 100644 --- a/e2e/paths/05-ticket-module/12_descriptor.spec.js +++ b/e2e/paths/05-ticket-module/12_descriptor.spec.js @@ -34,7 +34,7 @@ describe('Ticket descriptor path', () => { const result = await nightmare .waitToClick(selectors.ticketDescriptor.moreMenu) .waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour) - .write(selectors.ticketDescriptor.changeShippedHourInput, '08:15') + .pickTime(selectors.ticketDescriptor.changeShippedHourInput, '08:15') .waitToClick(selectors.ticketDescriptor.acceptChangeHourButton) .waitForLastSnackbar();