DEV: Update preview step to be more reliable.

This commit is contained in:
Guo Xiang Tan 2018-06-05 16:58:15 +08:00
parent d3e610eed9
commit 478c86e0a4
3 changed files with 15 additions and 32 deletions

View File

@ -11,6 +11,6 @@
"chrome-launcher": "^0.10.0",
"chrome-remote-interface": "^0.25.4",
"eslint": "^4.13.1",
"puppeteer": "^0.13.0"
"puppeteer": "^1.4.0"
}
}

View File

@ -15,7 +15,7 @@ const path = require('path');
(async () => {
const browser = await puppeteer.launch({
// when debugging localy setting headless to "false" can be very helpful
headless: true,
headless: false,
args: ["--disable-local-storage"]
});
const page = await browser.newPage();
@ -59,11 +59,11 @@ const path = require('path');
return exec(description, fn, assertion);
};
page.on('console', msg => console.log(`PAGE LOG: ${msg.text}`));
page.on('console', msg => console.log(`PAGE LOG: ${msg.text()}`));
page.on('response', resp => {
if (resp.status !== 200) {
console.log("FAILED HTTP REQUEST TO " + resp.url + " Status is: " + resp.status);
if (resp.status() !== 200) {
console.log("FAILED HTTP REQUEST TO " + resp.url() + " Status is: " + resp.status());
}
return resp;
});
@ -218,27 +218,10 @@ const path = require('path');
return page.type("#reply-control .d-editor-input", post);
});
await assert("waiting for the preview", () => {
let promise = page.waitForSelector(".d-editor-preview p",
await exec("waiting for the preview", () => {
return page.waitForXPath("//div[contains(@class, 'd-editor-preview') and contains(.//p, 'I can even write a reply')]",
{ visible: true }
);
promise = promise.then(() => {
return page.evaluate(() => {
return document.querySelector(".d-editor-preview").innerText;
});
});
return promise;
}, output => {
const expected = "I can even write a reply";
const matched = output.match(expected);
if (!matched) {
console.log(`Expected '${output}' to match '${expected}'`);
}
return matched;
});
await exec("submit the topic", () => {

View File

@ -672,9 +672,9 @@ lru-cache@^4.0.1:
pseudomap "^1.0.2"
yallist "^2.1.2"
mime@^1.3.4:
version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
mime@^2.0.3:
version "2.3.1"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369"
mimic-fn@^1.0.0:
version "1.1.0"
@ -795,14 +795,14 @@ pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
puppeteer@^0.13.0:
version "0.13.0"
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-0.13.0.tgz#2e6956205f2c640964c2107f620ae1eef8bde8fd"
puppeteer@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.4.0.tgz#437f0f3450d76e437185c0bf06f446e80f184692"
dependencies:
debug "^2.6.8"
debug "^3.1.0"
extract-zip "^1.6.5"
https-proxy-agent "^2.1.0"
mime "^1.3.4"
mime "^2.0.3"
progress "^2.0.0"
proxy-from-env "^1.0.0"
rimraf "^2.6.1"