Fix new settings and login tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-07-16 22:06:44 +02:00
parent 138a527cc4
commit f7d2cdbd97
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
8 changed files with 28 additions and 17 deletions

View File

@ -54,4 +54,6 @@ module.exports = {
*/
headless: true,
slowMo: 0,
};

View File

@ -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();
@ -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');
@ -96,6 +98,7 @@ module.exports = {
deviceScaleFactor: options.viewport.scale
})
]);
await this.delay(100);
}
let fileName = test.test.title
if (route !== undefined) {
@ -113,7 +116,7 @@ module.exports = {
} catch (err) {
failed = err;
}
await this.delay(500);
await this.delay(100);
await Promise.all([
this.pageBase.screenshot({
path: `${this._outputDirectory}/${fileName}.base.png`,

View File

@ -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"
}
}

View File

@ -39,7 +39,7 @@ describe('apps', function () {
}, {viewport: resolution, waitUntil: 'networkidle2'});
});
['installed', 'enabled', 'disabled', 'app-bundles'].forEach(function(endpoint) {
['your-apps', 'enabled', 'disabled', 'app-bundles'].forEach(function(endpoint) {
it('apps.' + endpoint + '.' + resolution.title, async function () {
return helper.takeAndCompare(this, undefined, async function (page) {
try {

View File

@ -31,7 +31,7 @@ describe('install', function () {
config.resolutions.forEach(function (resolution) {
it('show-page.' + resolution.title, async function () {
// (test, route, prepare, action, options
return helper.takeAndCompare(this, '/index.php', async (page) => {
return helper.takeAndCompare(this, 'index.php', async (page) => {
await helper.delay(100);
await page.$eval('body', function (e) {
$('#adminlogin').blur();
@ -61,7 +61,7 @@ describe('install', function () {
helper.pageBase.setDefaultNavigationTimeout(5*60*1000);
helper.pageCompare.setDefaultNavigationTimeout(5*60*1000);
// just run for one resolution since we can only install once
return helper.takeAndCompare(this, '/index.php', async function (page) {
return helper.takeAndCompare(this, 'index.php', async function (page) {
const login = await page.type('#adminlogin', 'admin');
const password = await page.type('#adminpass', 'admin');
const inputElement = await page.$('input[type=submit]');

View File

@ -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});
})

View File

@ -37,7 +37,7 @@ describe('public', function () {
*/
config.resolutions.forEach(function (resolution) {
it('file-share-invalid.' + resolution.title, async function () {
return helper.takeAndCompare(this, '/index.php/s/invalid', async function () {
return helper.takeAndCompare(this, 'index.php/s/invalid', async function () {
}, {waitUntil: 'networkidle2', viewport: resolution});
});
});
@ -48,7 +48,7 @@ describe('public', function () {
var shareLink = {};
it('file-share-link', async function () {
return helper.takeAndCompare(this, '/index.php/apps/files', async function (page) {
return helper.takeAndCompare(this, 'index.php/apps/files', async function (page) {
const element = await page.$('[data-file="welcome.txt"] .action-share');
await element.click('[data-file="welcome.txt"] .action-share');
await page.waitForSelector('input.linkCheckbox');
@ -71,7 +71,7 @@ describe('public', function () {
config.resolutions.forEach(function (resolution) {
it('file-share-valid.' + resolution.title, async function () {
return helper.takeAndCompare(this, '/index.php/apps/files', async function (page) {
return helper.takeAndCompare(this, 'index.php/apps/files', async function (page) {
await page.goto(shareLink[page.url()]);
await helper.delay(500);
}, {waitUntil: 'networkidle2', viewport: resolution});
@ -89,7 +89,7 @@ describe('public', function () {
});
it('file-unshare', async function () {
return helper.takeAndCompare(this, '/index.php/apps/files', async function (page) {
return helper.takeAndCompare(this, 'index.php/apps/files', async function (page) {
const element = await page.$('[data-file="welcome.txt"] .action-share');
await element.click('[data-file="welcome.txt"] .action-share');
await page.waitForSelector('input.linkCheckbox');

View File

@ -33,24 +33,24 @@ describe('settings', function () {
config.resolutions.forEach(function (resolution) {
it('personal.' + resolution.title, async function () {
return helper.takeAndCompare(this, '/index.php/settings/user', async function (page) {
return helper.takeAndCompare(this, 'index.php/settings/user', async function (page) {
}, {viewport: resolution});
});
it('admin.' + resolution.title, async function () {
return helper.takeAndCompare(this, '/index.php/settings/admin', async function (page) {
return helper.takeAndCompare(this, 'index.php/settings/admin', async function (page) {
}, {viewport: resolution});
});
['sharing', 'security', 'theming', 'encryption', 'additional', 'tips-tricks'].forEach(function(endpoint) {
it('admin.' + endpoint + '.' + resolution.title, async function () {
return helper.takeAndCompare(this, '/index.php/settings/admin/' + endpoint, async function (page) {
return helper.takeAndCompare(this, 'index.php/settings/admin/' + endpoint, async function (page) {
}, {viewport: resolution, waitUntil: 'networkidle2'});
});
});
it('usermanagement.' + resolution.title, async function () {
return helper.takeAndCompare(this, '/index.php/settings/users', async function (page) {
return helper.takeAndCompare(this, 'index.php/settings/users', async function (page) {
}, {viewport: resolution});
});