diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 782756df3c..fb0dd2d0c0 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -13,8 +13,15 @@ let actions = { return exists; }, - parsedUrl: async function() { - return new URL(await this.url()); + expectURL: async function(expectedHash) { + try { + await this.waitForFunction(expectedHash => { + return document.location.hash.includes(expectedHash); + }, {}, expectedHash); + } catch (error) { + throw new Error(`failed to reach URL containing: ${expectedHash}`); + } + return true; }, waitUntilNotPresent: async function(selector) { @@ -48,7 +55,7 @@ let actions = { login: async function(userName) { try { - await this.waitForURL('#!/login'); + await this.expectURL('#!/login'); } catch (e) { await this.goto(`${defaultURL}/#!/login`); let dialog = await this.evaluate(() => { @@ -72,7 +79,7 @@ let actions = { let selector = `vn-home a[ui-sref="${moduleName}.index"]`; await this.waitToClick(selector); - await this.waitForURL(snakeName); + await this.expectURL(snakeName); }, loginAndModule: async function(userName, moduleName) { @@ -265,7 +272,7 @@ let actions = { waitForNumberOfElements: async function(selector, count) { return await this.waitForFunction((selector, count) => { - return document.querySelectorAll(selector).length === count; + return document.querySelectorAll(selector).length == count; }, {}, selector, count); }, @@ -286,8 +293,8 @@ let actions = { }, waitForTextInElement: async function(selector, text) { - await this.wait(selector); - return await this.wait((selector, text) => { + await this.waitForSelector(selector); + return await this.waitForFunction((selector, text) => { return document.querySelector(selector).innerText.toLowerCase().includes(text.toLowerCase()); }, {}, selector, text); }, @@ -332,16 +339,6 @@ let actions = { }, selector); }, - waitForURL: async function(hashURL) { - try { - await this.waitForFunction(expectedHash => { - return document.location.hash.includes(expectedHash); - }, {}, hashURL); - } catch (error) { - throw new Error(`failed to reach URL containing: ${hashURL}`); - } - }, - hideSnackbar: async function() { await this.waitToClick('#shapes .shown button'); }, @@ -460,7 +457,7 @@ let actions = { }, isDisabled: async function(selector) { - await this.wait(selector); + await this.waitForSelector(selector); return await this.evaluate(selector => { let element = document.querySelector(selector); return element.$ctrl.disabled; diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index 01496be20f..b21aac9b21 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -4,18 +4,25 @@ import {extendPage} from './extensions'; import {url as defaultURL} from './config'; export async function getBrowser() { + let headless = true; const browser = await Puppeteer.launch({ args: [ '--no-sandbox', `--window-size=${ 1920 },${ 1080 }` ], defaultViewport: null, - headless: false, + headless: headless, slowMo: 0, // slow down by ms }); let page = (await browser.pages())[0]; page = extendPage(page); page.setDefaultTimeout(5000); + // if (headless) { + // await page.setExtraHTTPHeaders({ + // 'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8' + // }); + // } + // await page.setCacheEnabled(false); await page.goto(defaultURL, {waitUntil: 'networkidle0'}); return {page, close: browser.close.bind(browser)}; } diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 8d215446c7..f36e90f320 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -502,7 +502,7 @@ export default { newServiceTypeName: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newServiceType.name"]', newServiceTypeExpense: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.newServiceType.expenseFk"]', serviceLine: 'vn-ticket-service > form > vn-card > vn-one:nth-child(2) > vn-horizontal', - saveServiceButton: `button[type=submit]`, + saveServiceButton: 'button[type=submit]', saveServiceTypeButton: '.vn-dialog.shown tpl-buttons > button' }, createStateView: { diff --git a/e2e/paths/01-login/01_login.spec.js b/e2e/paths/01-login/01_login.spec.js index ff9752b2be..abb0220115 100644 --- a/e2e/paths/01-login/01_login.spec.js +++ b/e2e/paths/01-login/01_login.spec.js @@ -36,8 +36,8 @@ describe('Login path', async() => { it('should log in', async() => { await page.doLogin('employee', 'nightmare'); await page.waitForNavigation(); - let url = await page.parsedUrl(); + let url = await page.expectURL('#!/'); - expect(url.hash).toEqual('#!/'); + expect(url).toBe(true); }); }); diff --git a/e2e/paths/02-client-module/01_create_client.spec.js b/e2e/paths/02-client-module/01_create_client.spec.js index 4fe76c9597..29525df493 100644 --- a/e2e/paths/02-client-module/01_create_client.spec.js +++ b/e2e/paths/02-client-module/01_create_client.spec.js @@ -26,9 +26,9 @@ describe('Client create path', async() => { it('should now access to the create client view by clicking the create-client floating button', async() => { await page.waitToClick(selectors.clientsIndex.createClientButton); await page.wait(selectors.createClientView.createButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/client/create'); - expect(url.hash).toEqual('#!/client/create'); + expect(url).toBe(true); }); it('should receive an error when clicking the create button having all the form fields empty', async() => { @@ -107,17 +107,16 @@ describe('Client create path', async() => { await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.clientsButton); await page.wait(selectors.clientsIndex.createClientButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/client/index'); - expect(url.hash).toEqual('#!/client/index'); + expect(url).toBe(true); }); it(`should search for the user Carol Danvers to confirm it exists`, async() => { await page.waitForContentLoaded(); await page.accessToSearchResult('Carol Danvers'); - await page.waitForURL('#!/client/114/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/client/114/summary'); - expect(url.hash).toEqual('#!/client/114/summary'); + expect(url).toBe(true); }); }); diff --git a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js index 854f41f5bf..34fc5a9c79 100644 --- a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js @@ -36,10 +36,9 @@ describe('Client Edit fiscalData path', () => { it(`should click on the fiscal data button`, async() => { await page.waitToClick(selectors.clientFiscalData.fiscalDataButton); - await page.waitForURL('fiscal-data'); - const url = await page.parsedUrl(); + let url = await page.expectURL('fiscal-data'); - expect(url.hash).toContain('fiscal-data'); + expect(url).toBe(true); }); it('should not be able to edit the verified data checkbox', async() => { @@ -123,10 +122,9 @@ describe('Client Edit fiscalData path', () => { // confirm all addresses have now EQtax checked step 1 it(`should click on the addresses button to access to the client's addresses`, async() => { await page.waitToClick(selectors.clientAddresses.addressesButton); - await page.waitForURL('/address/index'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/address/index'); - expect(url.hash).toContain('/address/index'); + expect(url).toBe(true); }); // confirm all addresses have now EQtax checked step 2 @@ -260,10 +258,9 @@ describe('Client Edit fiscalData path', () => { // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 1 it(`should click on the addresses button to access to the client's addresses`, async() => { await page.waitToClick(selectors.clientAddresses.addressesButton); - await page.waitForURL('/address/index'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/address/index'); - expect(url.hash).toContain('/address/index'); + expect(url).toBe(true); }); // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 2 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 43b663ae6d..af4ccf5d6c 100644 --- a/e2e/paths/02-client-module/05_add_address.spec.js +++ b/e2e/paths/02-client-module/05_add_address.spec.js @@ -18,10 +18,9 @@ describe('Client Add address path', () => { it(`should click on the add new address button to access to the new address form`, async() => { await page.waitToClick(selectors.clientAddresses.createAddress); - await page.waitForURL('address/create'); - const url = await page.parsedUrl(); + let url = await page.expectURL('address/create'); - expect(url.hash).toContain('address/create'); + expect(url).toBe(true); }); it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => { @@ -87,10 +86,9 @@ describe('Client Add address path', () => { it(`should click on the edit icon of the default address`, async() => { await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand'); await page.waitToClick(selectors.clientAddresses.firstEditAddress); - await page.waitForURL('/edit'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/edit'); - expect(url.hash).toContain('/edit'); + expect(url).toBe(true); }); it(`should click on the active checkbox and receive an error to save it because it is the default address`, async() => { @@ -105,9 +103,8 @@ describe('Client Add address path', () => { it(`should go back to the addreses section by clicking the cancel button`, async() => { await page.waitToClick(selectors.clientAddresses.cancelEditAddressButton); await page.waitToClick('.vn-confirm.shown button[response="accept"]'); - await page.waitForURL('address/index'); - const url = await page.parsedUrl(); + let url = await page.expectURL('address/index'); - expect(url.hash).toContain('address/index'); + expect(url).toBe(true); }); }); diff --git a/e2e/paths/02-client-module/06_add_address_notes.spec.js b/e2e/paths/02-client-module/06_add_address_notes.spec.js index 59e2bf5fb1..58a9496982 100644 --- a/e2e/paths/02-client-module/06_add_address_notes.spec.js +++ b/e2e/paths/02-client-module/06_add_address_notes.spec.js @@ -19,10 +19,9 @@ describe('Client add address notes path', () => { it(`should click on the edit icon of the default address`, async() => { await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street'); await page.waitToClick(selectors.clientAddresses.firstEditAddress); - await page.waitForURL('/edit'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/edit'); - expect(url.hash).toContain('/edit'); + expect(url).toBe(true); }); it('should not save a description without observation type', async() => { diff --git a/e2e/paths/02-client-module/08_add_notes.spec.js b/e2e/paths/02-client-module/08_add_notes.spec.js index 44b876cd95..8f1a9244d9 100644 --- a/e2e/paths/02-client-module/08_add_notes.spec.js +++ b/e2e/paths/02-client-module/08_add_notes.spec.js @@ -18,10 +18,9 @@ describe('Client Add notes path', () => { it(`should click on the add note button`, async() => { await page.waitToClick(selectors.clientNotes.addNoteFloatButton); - await page.waitForURL('/note/create'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/note/create'); - expect(url.hash).toContain('/note/create'); + expect(url).toBe(true); }); it(`should create a note`, async() => { diff --git a/e2e/paths/02-client-module/09_add_credit.spec.js b/e2e/paths/02-client-module/09_add_credit.spec.js index b90c629f53..1cb06fb36f 100644 --- a/e2e/paths/02-client-module/09_add_credit.spec.js +++ b/e2e/paths/02-client-module/09_add_credit.spec.js @@ -18,10 +18,9 @@ describe('Client Add credit path', () => { it(`should click on the add credit button`, async() => { await page.waitToClick(selectors.clientCredit.addCreditFloatButton); - await page.waitForURL('/credit/create'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/credit/create'); - expect(url.hash).toContain('/credit/create'); + expect(url).toBe(true); }); it(`should edit the credit`, async() => { diff --git a/e2e/paths/02-client-module/10_add_greuge.spec.js b/e2e/paths/02-client-module/10_add_greuge.spec.js index 86407f3c66..c934a42f1d 100644 --- a/e2e/paths/02-client-module/10_add_greuge.spec.js +++ b/e2e/paths/02-client-module/10_add_greuge.spec.js @@ -18,10 +18,9 @@ describe('Client Add greuge path', () => { it(`should click on the add greuge button`, async() => { await page.waitToClick(selectors.clientGreuge.addGreugeFloatButton); - await page.waitForURL('greuge/create'); - const url = await page.parsedUrl(); + let url = await page.expectURL('greuge/create'); - expect(url.hash).toContain('greuge/create'); + expect(url).toBe(true); }); it(`should receive an error if all fields are empty but date and type on submit`, async() => { diff --git a/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js b/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js index 06db0a672d..bb6b8b51ab 100644 --- a/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js +++ b/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js @@ -113,12 +113,12 @@ describe('Client lock verified data path', () => { }); describe('as salesAssistant', () => { - beforeAll(async() => { + it('should log in as salesAssistant then get to the client fiscal data', async() => { await page.forceReloadSection('client.card.fiscalData'); await page.loginAndModule('salesAssistant', 'client'); await page.accessToSearchResult('Hank Pym'); await page.accessToSection('client.card.fiscalData'); - }); + }, 20000); it('should confirm verified data button is enabled for salesAssistant', async() => { const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox); diff --git a/e2e/paths/02-client-module/13_log.spec.js b/e2e/paths/02-client-module/13_log.spec.js index a24c7cf4eb..462d66347a 100644 --- a/e2e/paths/02-client-module/13_log.spec.js +++ b/e2e/paths/02-client-module/13_log.spec.js @@ -27,10 +27,9 @@ describe('Client log path', () => { it('should navigate to the log section', async() => { await page.waitToClick(selectors.clientLog.logButton); - await page.waitForURL('log'); - let url = await page.parsedUrl(); + let url = await page.expectURL('log'); - expect(url.hash).toContain('log'); + expect(url).toBe(true); }); it('should check the previous value of the last logged change', async() => { diff --git a/e2e/paths/02-client-module/14_balance.spec.js b/e2e/paths/02-client-module/14_balance.spec.js index 9d5ff471ac..d70d11508e 100644 --- a/e2e/paths/02-client-module/14_balance.spec.js +++ b/e2e/paths/02-client-module/14_balance.spec.js @@ -42,17 +42,14 @@ describe('Client balance path', () => { it('should click the new payment button', async() => { await page.keyboard.press('Escape'); await page.reloadSection('client.card.balance.index'); - await page.waitForURL('/balance'); + let url = await page.expectURL('/balance'); - let url = await page.parsedUrl(); - - expect(url.hash).toContain('/balance'); + expect(url).toBe(true); }); it('should create a new payment that clears the debt', async() => { await page.waitToClick(selectors.clientBalance.newPaymentButton); await page.waitForContentLoaded(); - await page.waitForSelector('.vn-dialog.vn-popup.shown', {visible: true}); await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt'); await page.waitToClick(selectors.clientBalance.saveButton); let result = await page.waitForLastSnackbar(); @@ -116,12 +113,13 @@ describe('Client balance path', () => { await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.clientsButton); await page.wait(selectors.clientsIndex.createClientButton); - let url = await page.parsedUrl(); + let url = await page.expectURL('#!/client/index'); - expect(url.hash).toEqual('#!/client/index'); + expect(url).toBe(true); }); it('should now search for the user Petter Parker', async() => { + await page.waitForContentLoaded(); await page.write(selectors.clientsIndex.topbarSearch, 'Petter Parker'); await page.waitToClick(selectors.clientsIndex.searchButton); await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1); @@ -135,10 +133,9 @@ describe('Client balance path', () => { await page.waitToClick(selectors.clientsIndex.searchResult); await page.waitForContentLoaded(); await page.waitToClick(selectors.clientBalance.balanceButton); - await page.waitForURL('/balance'); - let url = await page.parsedUrl(); + let url = await page.expectURL('/balance'); - expect(url.hash).toContain('/balance'); + expect(url).toBe(true); }); it('should not be able to click the new payment button as it isnt present', async() => { diff --git a/e2e/paths/04-item-module/01_summary.spec.js b/e2e/paths/04-item-module/01_summary.spec.js index 2e32f85e2a..0196e09308 100644 --- a/e2e/paths/04-item-module/01_summary.spec.js +++ b/e2e/paths/04-item-module/01_summary.spec.js @@ -131,10 +131,9 @@ describe('Item summary path', () => { it(`should navigate to the one of the items detailed section`, async() => { await page.waitToClick(selectors.itemsIndex.searchResult); - await page.waitForURL('summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('summary'); - expect(url.hash).toContain('summary'); + expect(url).toBe(true); }); it(`should check the descritor edit button is not visible for employee`, async() => { diff --git a/e2e/paths/04-item-module/08_create_and_clone.spec.js b/e2e/paths/04-item-module/08_create_and_clone.spec.js index ca70fc47d5..7d6a8e54d6 100644 --- a/e2e/paths/04-item-module/08_create_and_clone.spec.js +++ b/e2e/paths/04-item-module/08_create_and_clone.spec.js @@ -27,27 +27,24 @@ describe('Item Create/Clone path', () => { it('should access to the create item view by clicking the create floating button', async() => { await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.wait(selectors.itemCreateView.createButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/item/create'); - expect(url.hash).toEqual('#!/item/create'); + expect(url).toBe(true); }); it('should return to the item index by clickig the cancel button', async() => { await page.waitToClick(selectors.itemCreateView.cancelButton); - await page.wait(selectors.itemsIndex.createItemButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/item/index'); - expect(url.hash).toEqual('#!/item/index'); + expect(url).toBe(true); }); it('should now access to the create item view by clicking the create floating button', async() => { await page.waitForContentLoaded(); await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.wait(selectors.itemCreateView.createButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/item/create'); - expect(url.hash).toEqual('#!/item/create'); + expect(url).toBe(true); }); it('should create the Infinity Gauntlet item', async() => { @@ -89,10 +86,9 @@ describe('Item Create/Clone path', () => { it('should return to the items index by clicking the return to items button', async() => { await page.waitToClick(selectors.itemBasicData.goToItemIndexButton); await page.wait(selectors.itemsIndex.createItemButton); - await page.waitForURL('#!/item/index'); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/item/index'); - expect(url.hash).toContain('#!/item/index'); + expect(url).toBe(true); }); it(`should search for the item Infinity Gauntlet`, async() => { @@ -109,10 +105,9 @@ describe('Item Create/Clone path', () => { await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet'); await page.waitToClick(selectors.itemsIndex.searchResultCloneButton); await page.waitToClick(selectors.itemsIndex.acceptClonationAlertButton); - await page.waitForURL('tags'); - const url = await page.parsedUrl(); + let url = await page.expectURL('tags'); - expect(url.hash).toContain('tags'); + expect(url).toBe(true); }); it('should search for the item Infinity Gauntlet and find two', async() => { diff --git a/e2e/paths/04-item-module/09_regularize.spec.js b/e2e/paths/04-item-module/09_regularize.spec.js index 17c9136ac6..76e92f8a63 100644 --- a/e2e/paths/04-item-module/09_regularize.spec.js +++ b/e2e/paths/04-item-module/09_regularize.spec.js @@ -46,10 +46,9 @@ describe('Item regularize path', () => { it(`should click on the search result to access to the item tax`, async() => { await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm'); await page.waitToClick(selectors.itemsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it('should open the regularize dialog and check the warehouse matches the local user settings', async() => { @@ -76,9 +75,9 @@ describe('Item regularize path', () => { page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}), page.waitToClick(selectors.globalItems.ticketsButton) ]); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/ticket/index'); - expect(url.hash).toEqual('#!/ticket/index'); + expect(url).toBe(true); }); it('should clear the user local settings now', async() => { @@ -103,10 +102,9 @@ describe('Item regularize path', () => { it(`should click on the search result to access to the ticket summary`, async() => { await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Missing'); await page.waitToClick(selectors.ticketsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should check the ticket sale quantity is showing a negative value`, async() => { @@ -128,10 +126,9 @@ describe('Item regularize path', () => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.itemsButton); - await page.wait(selectors.itemsIndex.topbarSearch); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/item/index'); - expect(url.hash).toEqual('#!/item/index'); + expect(url).toBe(true); }); it('should search for the item once again', async() => { @@ -147,10 +144,9 @@ describe('Item regularize path', () => { it(`should click on the search result to access to the item tax`, async() => { await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm'); await page.waitToClick(selectors.itemsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it('should regularize the item once more', async() => { @@ -172,9 +168,9 @@ describe('Item regularize path', () => { page.waitToClick(selectors.globalItems.ticketsButton) ]); await page.waitForTransitionEnd('vn-searchbar'); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/ticket/index'); - expect(url.hash).toEqual('#!/ticket/index'); + expect(url).toBe(true); }); it('should search for the ticket with id 25 once again', async() => { @@ -189,10 +185,9 @@ describe('Item regularize path', () => { it(`should now click on the search result to access to the ticket summary`, async() => { await page.waitForTextInElement(selectors.ticketsIndex.searchResult, '25'); await page.waitToClick(selectors.ticketsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should check the ticket contains now two sales`, async() => { diff --git a/e2e/paths/04-item-module/11_item_log.spec.js b/e2e/paths/04-item-module/11_item_log.spec.js index 0de362565e..213365c120 100644 --- a/e2e/paths/04-item-module/11_item_log.spec.js +++ b/e2e/paths/04-item-module/11_item_log.spec.js @@ -25,10 +25,9 @@ describe('Item log path', () => { it('should access to the create item view by clicking the create floating button', async() => { await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.wait(selectors.itemCreateView.createButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/item/create'); - expect(url.hash).toEqual('#!/item/create'); + expect(url).toBe(true); }); it('should create the Knowledge artifact item', async() => { @@ -45,19 +44,17 @@ describe('Item log path', () => { it('should return to the items index by clicking the return to items button', async() => { await page.waitToClick(selectors.itemBasicData.goToItemIndexButton); await page.wait(selectors.itemsIndex.createItemButton); - await page.waitForURL('#!/item/index'); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/item/index'); - expect(url.hash).toContain('#!/item/index'); + expect(url).toBe(true); }); it(`should search for the created item and navigate to it's log section`, async() => { await page.accessToSearchResult('Knowledge artifact'); await page.accessToSection('item.card.log'); - await page.waitForURL('/log'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/log'); - expect(url.hash).toContain('/log'); + expect(url).toBe(true); }); it(`should confirm the log is showing 5 entries`, async() => { diff --git a/e2e/paths/05-ticket-module/05_tracking_state.spec.js b/e2e/paths/05-ticket-module/05_tracking_state.spec.js index b6f39bf31f..108e8776f7 100644 --- a/e2e/paths/05-ticket-module/05_tracking_state.spec.js +++ b/e2e/paths/05-ticket-module/05_tracking_state.spec.js @@ -21,9 +21,9 @@ describe('Ticket Create new tracking state path', () => { it('should access to the create state view by clicking the create floating button', async() => { await page.waitToClick(selectors.ticketTracking.createStateButton); await page.waitForSelector(selectors.createStateView.state, {visible: true}); - let url = await page.parsedUrl(); + let url = await page.expectURL('tracking/edit'); - expect(url.hash).toContain('tracking/edit'); + expect(url).toBe(true); }); it(`should attempt create a new state but receive an error if state is empty`, async() => { @@ -51,10 +51,9 @@ describe('Ticket Create new tracking state path', () => { it('should now access to the create state view by clicking the create floating button', async() => { await page.waitToClick(selectors.ticketTracking.createStateButton); - await page.waitForURL('tracking/edit'); - let url = await page.parsedUrl(); + let url = await page.expectURL('tracking/edit'); - expect(url.hash).toContain('tracking/edit'); + expect(url).toBe(true); }); it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => { diff --git a/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js b/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js index 670d426270..f677625cde 100644 --- a/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js @@ -68,10 +68,9 @@ describe('Ticket Edit basic data path', () => { it(`should click next`, async() => { await page.waitToClick(selectors.ticketBasicData.nextStepButton); - await page.waitForURL('data/step-two'); - let url = await page.parsedUrl(); + let url = await page.expectURL('data/step-two'); - expect(url.hash).toContain('data/step-two'); + expect(url).toBe(true); }); it(`should have a price diference`, async() => { @@ -83,18 +82,16 @@ describe('Ticket Edit basic data path', () => { it(`should then click next to move on to step three`, async() => { await page.waitToClick(selectors.ticketBasicData.nextStepButton); - await page.waitForURL('data/step-three'); - let url = await page.parsedUrl(); + let url = await page.expectURL('data/step-three'); - expect(url.hash).toContain('data/step-three'); + expect(url).toBe(true); }); it(`should select a new reason for the changes made then click on finalize`, async() => { await page.autocompleteSearch(selectors.ticketBasicData.chargesReason, 'Cambiar los precios en el ticket'); await page.waitToClick(selectors.ticketBasicData.finalizeButton); - await page.waitForURL('summary'); - let url = await page.parsedUrl(); + let url = await page.expectURL('summary'); - expect(url.hash).toContain('summary'); + expect(url).toBe(true); }); }); diff --git a/e2e/paths/05-ticket-module/09_weekly.spec.js b/e2e/paths/05-ticket-module/09_weekly.spec.js index d41398bdda..e88018ad52 100644 --- a/e2e/paths/05-ticket-module/09_weekly.spec.js +++ b/e2e/paths/05-ticket-module/09_weekly.spec.js @@ -42,11 +42,9 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForContentLoaded(); + let url = await page.expectURL('#!/ticket/index'); - const url = await page.parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + expect(url).toBe(true); }); it('should confirm the ticket 11 was added to thursday', async() => { @@ -60,11 +58,9 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForURL('#!/ticket/index'); + let url = await page.expectURL('#!/ticket/index'); - const url = await page.parsedUrl(); - - expect(url.hash).toEqual('#!/ticket/index'); + expect(url).toBe(true); }); it('should now search for the ticket 11', async() => { @@ -79,10 +75,9 @@ describe('Ticket descriptor path', () => { it(`should click on the search result to access to the ticket`, async() => { await page.waitToClick(selectors.ticketsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it('should add the ticket to saturday turn using the descriptor more menu', async() => { @@ -99,10 +94,9 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.ticketsButton); - await page.wait(selectors.ticketsIndex.topbarSearch); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/ticket/index'); - expect(url.hash).toEqual('#!/ticket/index'); + expect(url).toBe(true); }); it('should confirm the ticket 11 was added on saturday', async() => { diff --git a/e2e/paths/05-ticket-module/10_request.spec.js b/e2e/paths/05-ticket-module/10_request.spec.js index e3f1f59e47..ce2c3a324f 100644 --- a/e2e/paths/05-ticket-module/10_request.spec.js +++ b/e2e/paths/05-ticket-module/10_request.spec.js @@ -30,10 +30,9 @@ describe('Ticket purchase request path', () => { }); it(`should have been redirected to the request index`, async() => { - await page.waitForURL('/request'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/request'); - expect(url.hash).toContain('/request'); + expect(url).toBe(true); }); it(`should confirm the new request was added`, async() => { diff --git a/e2e/paths/05-ticket-module/11_diary.spec.js b/e2e/paths/05-ticket-module/11_diary.spec.js index 6f470e07f6..b529ee1ffb 100644 --- a/e2e/paths/05-ticket-module/11_diary.spec.js +++ b/e2e/paths/05-ticket-module/11_diary.spec.js @@ -28,20 +28,18 @@ xdescribe('Ticket diary path', () => { it(`should click on the search result to access to the ticket summary`, async() => { await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Bat cave'); await page.waitToClick(selectors.ticketsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should navigate to the item diary from the 1st sale item id descriptor popover`, async() => { await page.waitToClick(selectors.ticketSummary.firstSaleItemId); await page.waitForTransitionEnd('.vn-popover'); await page.waitToClick(selectors.ticketSummary.popoverDiaryButton); - await page.waitForURL('/diary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/diary'); - expect(url.hash).toContain('/diary'); + expect(url).toBe(true); }); it(`should check the second line id is marked as message`, async() => { diff --git a/e2e/paths/05-ticket-module/12_descriptor.spec.js b/e2e/paths/05-ticket-module/12_descriptor.spec.js index c01785165f..6e3864b481 100644 --- a/e2e/paths/05-ticket-module/12_descriptor.spec.js +++ b/e2e/paths/05-ticket-module/12_descriptor.spec.js @@ -28,10 +28,9 @@ describe('Ticket descriptor path', () => { it(`should click on the search result to access to the ticket summary`, async() => { await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Cerebro'); await page.waitToClick(selectors.ticketsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should update the shipped hour using the descriptor menu`, async() => { @@ -62,9 +61,9 @@ describe('Ticket descriptor path', () => { }); it('should have been relocated to the ticket index', async() => { - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/ticket/index'); - expect(url.hash).toEqual('#!/ticket/index'); + expect(url).toBe(true); }); it(`should search for the deleted ticket and check it's date`, async() => { @@ -92,10 +91,9 @@ describe('Ticket descriptor path', () => { it(`should now click on the search result to access to the ticket summary`, async() => { await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Many Places'); await page.waitToClick(selectors.ticketsIndex.searchResult); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it('should open the add stowaway dialog', async() => { @@ -126,10 +124,9 @@ describe('Ticket descriptor path', () => { it(`should navigate back to the added ticket using the descriptors ship button`, async() => { await page.waitToClick(selectors.ticketDescriptor.shipButton); - await page.waitForURL('#!/ticket/17/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/ticket/17/summary'); - expect(url.hash).toContain('#!/ticket/17/summary'); + expect(url).toBe(true); }); it('should delete the stowaway', async() => { @@ -153,10 +150,9 @@ describe('Ticket descriptor path', () => { await page.loginAndModule('adminBoss', 'ticket'); await page.accessToSearchResult(invoiceableTicketId); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL(`ticket/${invoiceableTicketId}/summary`); - expect(url.hash).toContain(`ticket/${invoiceableTicketId}/summary`); + expect(url).toBe(true); }); it(`should make sure the ticket doesn't have an invoiceOutFk yet`, async() => { diff --git a/e2e/paths/05-ticket-module/13_services.spec.js b/e2e/paths/05-ticket-module/13_services.spec.js index 4a1e12505a..cafc5f27cf 100644 --- a/e2e/paths/05-ticket-module/13_services.spec.js +++ b/e2e/paths/05-ticket-module/13_services.spec.js @@ -44,10 +44,9 @@ describe('Ticket services path', () => { await page.loginAndModule('administrative', 'ticket'); await page.accessToSearchResult(editableTicketId); await page.accessToSection('ticket.card.service'); - await page.waitForURL('/service'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/service'); - expect(url.hash).toContain('/service'); + expect(url).toBe(true); }); it('should click on the add button to prepare the form to create a new service', async() => { @@ -86,6 +85,7 @@ describe('Ticket services path', () => { await page.autocompleteSearch(selectors.ticketService.newServiceTypeExpense, 'Retencion'); await page.waitToClick(selectors.ticketService.saveServiceTypeButton); await page.write(selectors.ticketService.firstPrice, '999'); + await page.waitFor(1000); // time needed for the button to be clickable await page.waitToClick(selectors.ticketService.saveServiceButton); const result = await page.waitForLastSnackbar(); @@ -124,6 +124,7 @@ describe('Ticket services path', () => { it('should delete the service', async() => { await page.waitToClick(selectors.ticketService.fistDeleteServiceButton); await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0); + await page.waitFor(1000); // without this wait it fails to click the save button await page.waitToClick(selectors.ticketService.saveServiceButton); const result = await page.waitForLastSnackbar(); diff --git a/e2e/paths/05-ticket-module/14_create_ticket.spec.js b/e2e/paths/05-ticket-module/14_create_ticket.spec.js index 9e68db9fdb..e501ea0ef9 100644 --- a/e2e/paths/05-ticket-module/14_create_ticket.spec.js +++ b/e2e/paths/05-ticket-module/14_create_ticket.spec.js @@ -17,10 +17,9 @@ describe('Ticket create path', () => { it('should open the new ticket form', async() => { await page.waitToClick(selectors.ticketsIndex.newTicketButton); - await page.wait(selectors.createTicketView.client); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/ticket/create'); - expect(url.hash).toEqual('#!/ticket/create'); + expect(url).toBe(true); }); it('should succeed to create a ticket', async() => { @@ -36,9 +35,8 @@ describe('Ticket create path', () => { }); it('should check the url is now the summary of the ticket', async() => { - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); }); diff --git a/e2e/paths/05-ticket-module/15_create_ticket_from_client.spec.js b/e2e/paths/05-ticket-module/15_create_ticket_from_client.spec.js index 4f7090bd3a..80bb217fb0 100644 --- a/e2e/paths/05-ticket-module/15_create_ticket_from_client.spec.js +++ b/e2e/paths/05-ticket-module/15_create_ticket_from_client.spec.js @@ -20,10 +20,9 @@ describe('Ticket create from client path', () => { await page.waitForContentLoaded(); await page.waitToClick(selectors.clientDescriptor.moreMenu); await page.waitToClick(selectors.clientDescriptor.simpleTicketButton); - await page.waitForURL('#!/ticket/create?clientFk=102'); - const url = await page.parsedUrl(); + let url = await page.expectURL('clientFk=102'); - expect(url.hash).toContain('clientFk=102'); + expect(url).toBe(true); }); it('should check if the client details are the expected ones', async() => { diff --git a/e2e/paths/05-ticket-module/16_summary.spec.js b/e2e/paths/05-ticket-module/16_summary.spec.js index 17c1ca71d6..e7c6507d79 100644 --- a/e2e/paths/05-ticket-module/16_summary.spec.js +++ b/e2e/paths/05-ticket-module/16_summary.spec.js @@ -18,10 +18,9 @@ describe('Ticket Summary path', () => { it('should navigate to the target ticket summary section', async() => { await page.loginAndModule('employee', 'ticket'); await page.accessToSearchResult(ticketId); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should display details from the ticket and it's client on the top of the header`, async() => { @@ -76,10 +75,9 @@ describe('Ticket Summary path', () => { it('should log in as production then navigate to the summary of the same ticket', async() => { await page.loginAndModule('production', 'ticket'); await page.accessToSearchResult(ticketId); - await page.waitForURL('/summary'); - let url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it('should click on the SET OK button', async() => { diff --git a/e2e/paths/06-claim-module/01_basic_data.spec.js b/e2e/paths/06-claim-module/01_basic_data.spec.js index e2116b2eea..9718fb5834 100644 --- a/e2e/paths/06-claim-module/01_basic_data.spec.js +++ b/e2e/paths/06-claim-module/01_basic_data.spec.js @@ -31,10 +31,9 @@ describe('Claim edit basic data path', () => { }); it(`should have been redirected to the next section of claims as the role is salesAssistant`, async() => { - await page.waitForURL('/detail'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/detail'); - expect(url.hash).toContain('/detail'); + expect(url).toBe(true); }); it('should confirm the claim state was edited', async() => { diff --git a/e2e/paths/06-claim-module/02_development.spec.js b/e2e/paths/06-claim-module/02_development.spec.js index 8f8f98b16c..351dee50f4 100644 --- a/e2e/paths/06-claim-module/02_development.spec.js +++ b/e2e/paths/06-claim-module/02_development.spec.js @@ -32,10 +32,9 @@ describe('Claim development', () => { }, 15000); it(`should redirect to the next section of claims as the role is salesAssistant`, async() => { - await page.waitForURL('/action'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/action'); - expect(url.hash).toContain('/action'); + expect(url).toBe(true); }); it('should edit a development', async() => { diff --git a/e2e/paths/06-claim-module/03_detail.spec.js b/e2e/paths/06-claim-module/03_detail.spec.js index 71b09e29be..cf758919eb 100644 --- a/e2e/paths/06-claim-module/03_detail.spec.js +++ b/e2e/paths/06-claim-module/03_detail.spec.js @@ -56,10 +56,9 @@ xdescribe('Claim detail', () => { await page.loginAndModule('salesAssistant', 'claim'); await page.accessToSearchResult('1'); await page.accessToSection('claim.card.detail'); - await page.waitForURL('/detail'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/detail'); - expect(url.hash).toContain('/detail'); + expect(url).toBe(true); }); it('should edit de second item claimed discount', async() => { @@ -100,10 +99,9 @@ xdescribe('Claim detail', () => { }); it(`should have been redirected to the next section in claims`, async() => { - await page.waitForURL('/development'); - const url = await page.parsedUrl(); + let url = await page.expectURL('development'); - expect(url.hash).toContain('development'); + expect(url).toBe(true); }); it('should navigate back to claim.detail to confirm the claim contains now two items', async() => { diff --git a/e2e/paths/06-claim-module/05_summary.spec.js b/e2e/paths/06-claim-module/05_summary.spec.js index 71f8b72526..a9d97533cd 100644 --- a/e2e/paths/06-claim-module/05_summary.spec.js +++ b/e2e/paths/06-claim-module/05_summary.spec.js @@ -18,10 +18,9 @@ describe('claim Summary path', () => { it('should navigate to the target claim summary section', async() => { await page.loginAndModule('employee', 'claim'); await page.accessToSearchResult(claimId); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should display details from the claim and it's client on the top of the header`, async() => { diff --git a/e2e/paths/06-claim-module/06_descriptor.spec.js b/e2e/paths/06-claim-module/06_descriptor.spec.js index 83dbec5fd7..8e6b3fd051 100644 --- a/e2e/paths/06-claim-module/06_descriptor.spec.js +++ b/e2e/paths/06-claim-module/06_descriptor.spec.js @@ -18,10 +18,9 @@ describe('claim Descriptor path', () => { it('should now navigate to the target claim summary section', async() => { await page.loginAndModule('employee', 'claim'); await page.accessToSearchResult(claimId); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should not be able to see the delete claim button of the descriptor more menu`, async() => { @@ -33,10 +32,9 @@ describe('claim Descriptor path', () => { it(`should log in as salesAssistant and navigate to the target claim`, async() => { await page.loginAndModule('salesAssistant', 'claim'); await page.accessToSearchResult(claimId); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should be able to see the delete claim button of the descriptor more menu`, async() => { @@ -53,10 +51,9 @@ describe('claim Descriptor path', () => { }); it(`should have been relocated to the claim index`, async() => { - await page.waitForURL('/claim/index'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/claim/index'); - expect(url.hash).toContain('/claim/index'); + expect(url).toBe(true); }); it(`should search for the deleted claim to find no results`, async() => { diff --git a/e2e/paths/07-order-module/01_edit_basic_data.spec.js b/e2e/paths/07-order-module/01_edit_basic_data.spec.js index e4c20cbe26..2cbee95f7d 100644 --- a/e2e/paths/07-order-module/01_edit_basic_data.spec.js +++ b/e2e/paths/07-order-module/01_edit_basic_data.spec.js @@ -41,10 +41,9 @@ describe('Order edit basic data path', () => { await page.accessToSection('order.card.basicData'); await page.waitForContentLoaded(); await page.waitForSelector(selectors.orderBasicData.observation, {visible: true}); - await page.waitForURL('basic-data'); - const url = await page.parsedUrl(); + let url = await page.expectURL(`#!/order/${orderId}/basic-data`); - expect(url.hash).toEqual(`#!/order/${orderId}/basic-data`); + expect(url).toBe(true); }); it('should not be able to change anything', async() => { @@ -63,10 +62,9 @@ describe('Order edit basic data path', () => { await page.waitToClick(selectors.orderBasicData.acceptButton); await page.waitForContentLoaded(); await page.waitToClick(selectors.ordersIndex.createOrderButton); - await page.waitForURL('#!/order/create'); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/order/create'); - expect(url.hash).toContain('#!/order/create'); + expect(url).toBe(true); }); it('should now create a new one', async() => { @@ -74,18 +72,16 @@ describe('Order edit basic data path', () => { await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today); await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency'); await page.waitToClick(selectors.createOrderView.createButton); - await page.waitForURL('/catalog'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/catalog'); - expect(url.hash).toContain('/catalog'); + expect(url).toBe(true); }); it('should navigate to the basic data section of the new order', async() => { await page.accessToSection('order.card.basicData'); - await page.wait(selectors.orderBasicData.observation); - const url = await page.parsedUrl(); + let url = await page.expectURL('/basic-data'); - expect(url.hash).toContain('/basic-data'); + expect(url).toBe(true); }); it('should be able to modify all the properties', async() => { diff --git a/e2e/paths/07-order-module/02_catalog.spec.js b/e2e/paths/07-order-module/02_catalog.spec.js index cbd8585b00..d67dd3c929 100644 --- a/e2e/paths/07-order-module/02_catalog.spec.js +++ b/e2e/paths/07-order-module/02_catalog.spec.js @@ -17,10 +17,9 @@ describe('Order catalog', () => { it('should open the create new order form', async() => { await page.waitToClick(selectors.ordersIndex.createOrderButton); - await page.waitForURL('order/create'); - const url = await page.parsedUrl(); + let url = await page.expectURL('order/create'); - expect(url.hash).toContain('order/create'); + expect(url).toBe(true); }); it('should create a new order', async() => { @@ -30,16 +29,15 @@ describe('Order catalog', () => { await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today); await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency'); await page.waitToClick(selectors.createOrderView.createButton); - await page.waitForURL('/catalog'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/catalog'); - - expect(url.hash).toContain('/catalog'); + expect(url).toBe(true); }); it('should add the realm and type filters and obtain results', async() => { await page.waitForContentLoaded(); await page.waitToClick(selectors.orderCatalog.plantRealmButton); + await page.waitForContentLoaded(); await page.autocompleteSearch(selectors.orderCatalog.type, 'Anthurium'); await page.waitForNumberOfElements('section.product', 4); const result = await page.countElement('section.product'); @@ -70,6 +68,7 @@ describe('Order catalog', () => { it('should remove the tag filters and have 4 results', async() => { await page.waitForContentLoaded(); await page.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton); + await page.waitForContentLoaded(); await page.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton); await page.waitForNumberOfElements('.product', 4); const result = await page.countElement('section.product'); diff --git a/e2e/paths/07-order-module/03_lines.spec.js b/e2e/paths/07-order-module/03_lines.spec.js index 99c8a221b8..21fceac447 100644 --- a/e2e/paths/07-order-module/03_lines.spec.js +++ b/e2e/paths/07-order-module/03_lines.spec.js @@ -40,10 +40,11 @@ describe('Order lines', () => { it('should confirm the whole order and redirect to ticket index filtered by clientFk', async() => { await page.waitToClick(selectors.orderLine.confirmOrder); - await page.waitForURL('ticket/index'); - const url = await page.parsedUrl(); - expect(url.hash).toContain('ticket/index'); - expect(url.hash).toContain('clientFk'); + let hashPartOne = await page.expectURL('ticket/index'); + let hashPartTwo = await page.expectURL('clientFk'); + + expect(hashPartOne).toBe(true); + expect(hashPartTwo).toBe(true); }); }); diff --git a/e2e/paths/08-route-module/01_create.spec.js b/e2e/paths/08-route-module/01_create.spec.js index 656cc0bc3e..14d5273b31 100644 --- a/e2e/paths/08-route-module/01_create.spec.js +++ b/e2e/paths/08-route-module/01_create.spec.js @@ -19,10 +19,9 @@ describe('Route create path', () => { it('should click on the add new route button and open the creation form', async() => { await page.waitForContentLoaded(); await page.waitToClick(selectors.routeIndex.addNewRouteButton); - await page.wait(selectors.createRouteView.worker); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/route/create'); - expect(url.hash).toEqual('#!/route/create'); + expect(url).toBe(true); }); it(`should attempt to create a new route but fail since employee has no access rights`, async() => { @@ -43,10 +42,9 @@ describe('Route create path', () => { it('should again click on the add new route button and open the creation form', async() => { await page.waitToClick(selectors.routeIndex.addNewRouteButton); - await page.wait(selectors.createRouteView.worker); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/route/create'); - expect(url.hash).toEqual('#!/route/create'); + expect(url).toBe(true); }); it(`should create a new route`, async() => { @@ -62,10 +60,9 @@ describe('Route create path', () => { }); it(`should confirm the redirection to the created route summary`, async() => { - await page.wait(selectors.routeSummary.routeId); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); }); }); diff --git a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js b/e2e/paths/09-invoice-out-module/01_descriptor.spec.js index f26eaa47aa..a51ae9d8f3 100644 --- a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js +++ b/e2e/paths/09-invoice-out-module/01_descriptor.spec.js @@ -31,10 +31,9 @@ describe('InvoiceOut descriptor path', () => { await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.invoiceOutButton); await page.wait(selectors.invoiceOutIndex.topbarSearch); - await page.waitForURL('#!/invoice-out/index'); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/invoice-out/index'); - expect(url.hash).toEqual('#!/invoice-out/index'); + expect(url).toBe(true); }); it('should search for the target invoiceOut', async() => { @@ -49,10 +48,9 @@ describe('InvoiceOut descriptor path', () => { it(`should click on the search result to access to the invoiceOut summary`, async() => { await page.accessToSearchResult('T2222222'); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it('should delete the invoiceOut using the descriptor more menu', async() => { @@ -65,9 +63,9 @@ describe('InvoiceOut descriptor path', () => { }); it('should have been relocated to the invoiceOut index', async() => { - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/invoice-out/index'); - expect(url.hash).toEqual('#!/invoice-out/index'); + expect(url).toBe(true); }); it(`should search for the deleted invouceOut to find no results`, async() => { @@ -83,10 +81,9 @@ describe('InvoiceOut descriptor path', () => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.ticketsButton); - await page.wait(selectors.ticketsIndex.topbarSearch); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/ticket/index'); - expect(url.hash).toEqual('#!/ticket/index'); + expect(url).toBe(true); }); it('should search for tickets with an specific invoiceOut to find no results', async() => { @@ -105,19 +102,17 @@ describe('InvoiceOut descriptor path', () => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.invoiceOutButton); - await page.wait(selectors.invoiceOutIndex.topbarSearch); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/invoice-out/index'); - expect(url.hash).toEqual('#!/invoice-out/index'); + expect(url).toBe(true); }); it(`should search and access to the invoiceOut summary`, async() => { await page.waitForContentLoaded(); await page.accessToSearchResult('T1111111'); - await page.waitForURL('/summary'); - const url = await page.parsedUrl(); + let url = await page.expectURL('/summary'); - expect(url.hash).toContain('/summary'); + expect(url).toBe(true); }); it(`should check the invoiceOut is booked in the summary data`, async() => { @@ -147,6 +142,7 @@ describe('InvoiceOut descriptor path', () => { let expectedDate = `${day}/${month}/${today.getFullYear()}`; + await page.waitForContentLoaded(); const result = await page .waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText'); diff --git a/e2e/smokes/01_client_path.spec.js b/e2e/smokes/01_client_path.spec.js index 4ac4d331de..6c106b2eb2 100644 --- a/e2e/smokes/01_client_path.spec.js +++ b/e2e/smokes/01_client_path.spec.js @@ -16,18 +16,16 @@ describe('create client path', () => { it('should access to the create client view by clicking the create-client floating button', async() => { await page.waitToClick(selectors.clientsIndex.createClientButton); - await page.wait(selectors.createClientView.createButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/client/create'); - expect(url.hash).toEqual('#!/client/create'); + expect(url).toBe(true); }); it('should cancel the client creation to go back to clients index', async() => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.waitToClick(selectors.globalItems.clientsButton); - await page.wait(selectors.clientsIndex.createClientButton); - const url = await page.parsedUrl(); + let url = await page.expectURL('#!/client/index'); - expect(url.hash).toEqual('#!/client/index'); + expect(url).toBe(true); }); });