mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
tests: rather course (but it works) test coverage for session creation.
*will fail intentionally* In response to https://github.com/ether/etherpad-lite/issues/4898
This commit is contained in:
parent
f24353e806
commit
3f2c8c6dae
1 changed files with 62 additions and 0 deletions
62
src/tests/backend/specs/api/httpRouteSessionCreation.js
Normal file
62
src/tests/backend/specs/api/httpRouteSessionCreation.js
Normal file
|
@ -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 a new issue