diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 32c531f7cc..687172a2f7 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -40,16 +40,12 @@ let actions = { }, login: async function(userName) { - try { - await this.expectURL('#!/login'); - } catch (e) { - await this.goto(`${defaultURL}/#!/login`); - let dialog = await this.evaluate(() => { - return document.querySelector('button[response="accept"]'); - }); - if (dialog) - await this.waitToClick('button[response="accept"]'); - } + await this.goto(`${defaultURL}/#!/login`); + let dialog = await this.evaluate(() => { + return document.querySelector('button[response="accept"]'); + }); + if (dialog) + await this.waitToClick('button[response="accept"]'); await this.doLogin(userName); await this.waitForFunction(() => { @@ -175,7 +171,7 @@ let actions = { }, waitToClick: async function(selector) { - await this.waitForSelector(selector, {}); + await this.waitForSelector(selector); await this.click(selector); }, @@ -327,11 +323,17 @@ let actions = { }, hideSnackbar: async function() { - await this.waitToClick('#shapes .shown button'); + await this.evaluate(() => { + let hideButton = document.querySelector('#shapes .shown button'); + if (hideButton) + return document.querySelector('#shapes .shown button').click(); + }); }, - waitForLastShape: async function(selector) { - await this.wait(selector); + waitForLastSnackbar: async function() { + const selector = 'vn-snackbar .shown .text'; + + await this.waitForSelector(selector); let snackBarText = await this.evaluate(selector => { const shape = document.querySelector(selector); @@ -341,12 +343,6 @@ let actions = { return snackBarText; }, - waitForLastSnackbar: async function() { - await this.waitFor(1000); // this needs a refactor to be somehow dynamic ie: page.waitForResponse(urlOrPredicate[, options]) or something to fire waitForLastShape once the request is completed - await this.waitForSpinnerLoad(); - return await this.waitForLastShape('vn-snackbar .shown .text'); - }, - accessToSearchResult: async function(searchValue) { await this.clearInput('vn-searchbar'); await this.write('vn-searchbar', searchValue); diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index ed05909d02..1ca0726c0f 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -28,7 +28,7 @@ export async function getBrowser() { }); }); page = extendPage(page); - page.setDefaultTimeout(5000); + page.setDefaultTimeout(10000); await page.goto(defaultURL, {waitUntil: 'networkidle0'}); return {page, close: browser.close.bind(browser)}; } diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index 8f1a116ee6..27ed5049ae 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -101,7 +101,6 @@ describe('Client create path', async() => { }); it('should click on the Clients button of the top bar menu', async() => { - await page.waitFor(500); await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.clientsButton); diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index af4ccf5d6c..c10f455b0f 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -63,14 +63,16 @@ describe('Client Add address path', () => { expect(result).toEqual('Data saved!'); }); - it(`should click on the first address button to confirm the new address exists and it's the default one`, async() => { + it(`should confirm the new address exists and it's the default one`, async() => { const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText'); expect(result).toContain('320 Park Avenue New York'); }); it(`should click on the make default icon of the second address`, async() => { + await page.waitForContentLoaded(); await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar); + await page.waitForContentLoaded(); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); diff --git a/e2e/paths/04-item/02_basic_data.spec.js b/e2e/paths/04-item/02_basic_data.spec.js index 64827ed9ba..acc527dcdc 100644 --- a/e2e/paths/04-item/02_basic_data.spec.js +++ b/e2e/paths/04-item/02_basic_data.spec.js @@ -51,7 +51,6 @@ describe('Item Edit basic data path', () => { }); it(`should save with the new intrastat`, async() => { - await page.waitFor(250); await page.waitForTextInField(selectors.itemBasicData.intrastat, 'Tropical Flowers'); await page.waitToClick(selectors.itemBasicData.submitBasicDataButton); const result = await page.waitForLastSnackbar(); diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index 89cfcc4637..bfaa8cac7b 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -105,7 +105,7 @@ export default class Controller extends Component { this.hideTimeout = setTimeout(() => { this.hide(shape); this.lastShape = null; - }, data.timeout || 9000); + }, data.timeout || 3000); this.lastShape = { data: data,