tests: rather course (but it works) test coverage for session creation.
*will fail intentionally* In response to https://github.com/ether/etherpad-lite/issues/4898session-creation-tests
parent
f24353e806
commit
3f2c8c6dae
|
@ -0,0 +1,62 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const assert = require('assert').strict;
|
||||||
|
const common = require('../../common');
|
||||||
|
const settings = require('../../../../node/utils/Settings');
|
||||||
|
const fs = require('fs');
|
||||||
|
let agent;
|
||||||
|
|
||||||
|
const shouldCreateSession = [
|
||||||
|
'/p/foo',
|
||||||
|
'/p/foo/export/html',
|
||||||
|
];
|
||||||
|
const shouldNotCreateSession = [
|
||||||
|
'/',
|
||||||
|
'/api/',
|
||||||
|
'/favicon.ico',
|
||||||
|
'/locales.json',
|
||||||
|
'/pluginfw/plugin-definitions.json',
|
||||||
|
'/static/js/pad.js',
|
||||||
|
'/stats/',
|
||||||
|
];
|
||||||
|
|
||||||
|
const getDatabaseSize = () => {
|
||||||
|
const dbFile = settings.dbSettings.filename;
|
||||||
|
const database = fs.readFileSync(settings.dbSettings.filename, 'utf8');
|
||||||
|
return database.split('\n').length;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe(__filename, function () {
|
||||||
|
before(async function () { agent = await common.init(); });
|
||||||
|
|
||||||
|
describe('Session Creation on endpoint', function () {
|
||||||
|
if (settings.dbType !== 'dirty') this.skip;
|
||||||
|
|
||||||
|
this.timeout(100);
|
||||||
|
|
||||||
|
for (const endpoint of shouldNotCreateSession) {
|
||||||
|
it(endpoint, async function () {
|
||||||
|
const previousCount = getDatabaseSize();
|
||||||
|
await agent.get(endpoint)
|
||||||
|
.expect(200)
|
||||||
|
.expect(() => {
|
||||||
|
const newCount = getDatabaseSize();
|
||||||
|
assert(newCount === previousCount);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const endpoint of shouldCreateSession) {
|
||||||
|
const previousCount = getDatabaseSize();
|
||||||
|
it(endpoint, async function () {
|
||||||
|
await agent.get(endpoint)
|
||||||
|
.expect(200)
|
||||||
|
.expect(() => {
|
||||||
|
const newCount = getDatabaseSize();
|
||||||
|
assert(newCount > previousCount);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue