From 82c739eab2949251a79a4d0d6ff801ed4474ac1b Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 9 Nov 2020 18:25:02 +0100 Subject: [PATCH] stacktrace raw + e2e amends --- e2e/helpers/extensions.js | 35 ++++++++++++++----- .../05-ticket/01-sale/01_list_sales.spec.js | 2 +- e2e/paths/13-supplier/04_contact.spec.js | 1 + gulpfile.js | 24 ++++++------- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 8647483b0b..b8a7911912 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -247,7 +247,7 @@ let actions = { write: async function(selector, text) { let builtSelector = await this.selectorFormater(selector); - await this.waitForSelector(selector, {}); + await this.waitForSelector(selector); await this.type(builtSelector, text); await this.waitForTextInField(selector, text); }, @@ -340,6 +340,31 @@ let actions = { }); }, + waitForTextInField: async function(selector, text) { + let builtSelector = await this.selectorFormater(selector); + await this.waitForSelector(builtSelector); + const expectedText = text.toLowerCase(); + return new Promise((resolve, reject) => { + let attempts = 0; + const interval = setInterval(async() => { + const currentText = await this.evaluate(selector => { + return document.querySelector(selector).value.toLowerCase(); + }, builtSelector); + + if (currentText === expectedText || attempts === 40) { + clearInterval(interval); + resolve(currentText); + } + attempts += 1; + }, 100); + }).then(result => { + if (result === '') + return expect(result).toEqual(expectedText); + + return expect(result).toContain(expectedText); + }); + }, + selectorFormater: function(selector) { if (selector.includes('vn-textarea')) return `${selector} textarea`; @@ -350,14 +375,6 @@ let actions = { return `${selector} input`; }, - waitForTextInField: async function(selector, text) { - let builtSelector = await this.selectorFormater(selector); - await this.waitForSelector(builtSelector); - return await this.waitForFunction((selector, text) => { - return document.querySelector(selector).value.toLowerCase().includes(text.toLowerCase()); - }, {}, builtSelector, text); - }, - waitForInnerText: async function(selector) { await this.waitForSelector(selector, {}); await this.waitForFunction(selector => { diff --git a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js index 52474878e5..9876b319b3 100644 --- a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js +++ b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js @@ -1,7 +1,7 @@ import selectors from '../../../helpers/selectors.js'; import getBrowser from '../../../helpers/puppeteer'; -fdescribe('Ticket List sale path', () => { +describe('Ticket List sale path', () => { let browser; let page; diff --git a/e2e/paths/13-supplier/04_contact.spec.js b/e2e/paths/13-supplier/04_contact.spec.js index 2140ec81be..7338aa5886 100644 --- a/e2e/paths/13-supplier/04_contact.spec.js +++ b/e2e/paths/13-supplier/04_contact.spec.js @@ -62,6 +62,7 @@ describe('Supplier contact path', () => { }); it(`should check the new contact note was saved correctly`, async() => { + await page.waitForTextInField(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester'); const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactNotes, 'value'); expect(result).toContain('the end to end integration tester'); diff --git a/gulpfile.js b/gulpfile.js index db89b88989..75ebc08c9e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -187,7 +187,7 @@ function e2eSingleRun() { displaySpecDuration: true, }, summary: { - displayStacktrace: 'pretty', + displayStacktrace: 'raw', displayPending: false }, colors: { @@ -195,17 +195,17 @@ function e2eSingleRun() { successful: 'brightGreen', failed: 'brightRed' }, - stacktrace: { - filter: stacktrace => { - const lines = stacktrace.split('\n'); - const filtered = []; - for (let i = 1; i < lines.length; i++) { - if (/e2e\/paths/.test(lines[i])) - filtered.push(lines[i]); - } - return filtered.join('\n'); - } - } + // stacktrace: { + // filter: stacktrace => { + // const lines = stacktrace.split('\n'); + // const filtered = []; + // for (let i = 1; i < lines.length; i++) { + // if (/e2e\/paths/.test(lines[i])) + // filtered.push(lines[i]); + // } + // return filtered.join('\n'); + // } + // } }) ] }));