Skip to content

Commit

Permalink
Fix login tests
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Jul 29, 2018
1 parent 104c37d commit ae70f07
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions tests/ui-regression/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ module.exports = {
*/
headless: true,

slowMo: 0,

};
4 changes: 3 additions & 1 deletion tests/ui-regression/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ module.exports = {
}
this.browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
headless: config.headless
headless: config.headless,
slowMo: config.slowMo,
});
this.pageBase = await this.browser.newPage();
this.pageCompare = await this.browser.newPage();
Expand All @@ -65,6 +66,7 @@ module.exports = {
},

performLogin: async function (page, baseUrl) {
await page.bringToFront();
await page.goto(baseUrl + '/index.php/login', {waitUntil: 'networkidle0'});
await page.type('#user', 'admin');
await page.type('#password', 'admin');
Expand Down
6 changes: 3 additions & 3 deletions tests/ui-regression/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
},
"author": "",
"dependencies": {
"fs": "0.0.1-security",
"chai": "^4.1.2",
"mocha": "^5.0.0",
"fs": "0.0.1-security",
"mocha": "^5.2.0",
"mocha-json-report": "0.0.2",
"pixelmatch": "^4.0.2",
"png-js": "^0.1.1",
"pngjs2": "^2.0.0",
"polyserve": "^0.23.0",
"puppeteer": "^1.0.0"
"puppeteer": "^1.6.1"
}
}
8 changes: 7 additions & 1 deletion tests/ui-regression/test/loginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ describe('login', function () {
this.timeout(30000);
await helper.resetBrowser();
return helper.takeAndCompare(this, '/', async function (page) {
await page.waitForSelector('input#user');
await page.type('#user', 'admin');
await page.type('#password', 'admin');
const inputElement = await page.$('input[type=submit]');
await inputElement.click();
await page.waitForNavigation({waitUntil: 'networkidle0'});
await page.waitForNavigation({waitUntil: 'networkidle2'});
await page.waitForSelector('#header');
await page.$eval('body', function (e) {
// force relative timestamp to fixed value, since it breaks screenshot diffing
$('.live-relative-timestamp').removeClass('live-relative-timestamp').text('5 minutes ago');
});
return await helper.delay(100);
}, {viewport: resolution});
})
Expand Down

0 comments on commit ae70f07

Please sign in to comment.