mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 22:23:33 +01:00
tests: Restructure read-only pad export tests
This also adds coverage for `.etherpad` exports.
This commit is contained in:
parent
dbd76f0c5d
commit
0f5a4bd1f8
1 changed files with 45 additions and 16 deletions
|
@ -106,23 +106,52 @@ describe(__filename, function () {
|
||||||
.expect((res) => assert.equal(res.body.data.text, padText.toString()));
|
.expect((res) => assert.equal(res.body.data.text, padText.toString()));
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const authn of [false, true]) {
|
describe('export from read-only pad ID', function () {
|
||||||
it(`can export from read-only pad ID, authn ${authn}`, async function () {
|
let readOnlyId;
|
||||||
settings.requireAuthentication = authn;
|
|
||||||
const get = (ep) => {
|
// This ought to be before(), but it must run after the top-level beforeEach() above.
|
||||||
let req = agent.get(ep);
|
beforeEach(async function () {
|
||||||
if (authn) req = req.auth('user', 'user-password');
|
if (readOnlyId != null) return;
|
||||||
return req.expect(200);
|
await agent.post(`/p/${testPadId}/import`)
|
||||||
};
|
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
|
||||||
const ro = await get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
|
.expect(200);
|
||||||
.expect((res) => assert.ok(JSON.parse(res.text).data.readOnlyID));
|
const res = await agent.get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
|
||||||
const readOnlyId = JSON.parse(ro.text).data.readOnlyID;
|
.expect(200)
|
||||||
await get(`/p/${readOnlyId}/export/html`)
|
.expect('Content-Type', /json/)
|
||||||
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
|
.expect((res) => assert.equal(res.body.code, 0));
|
||||||
await get(`/p/${readOnlyId}/export/txt`)
|
readOnlyId = res.body.data.readOnlyID;
|
||||||
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
for (const authn of [false, true]) {
|
||||||
|
describe(`requireAuthentication = ${authn}`, function () {
|
||||||
|
// This ought to be before(), but it must run after the top-level beforeEach() above.
|
||||||
|
beforeEach(async function () {
|
||||||
|
settings.requireAuthentication = authn;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const exportType of ['html', 'txt', 'etherpad']) {
|
||||||
|
describe(`export to ${exportType}`, function () {
|
||||||
|
let text;
|
||||||
|
|
||||||
|
// This ought to be before(), but it must run after the top-level beforeEach() above.
|
||||||
|
beforeEach(async function () {
|
||||||
|
if (text != null) return;
|
||||||
|
let req = agent.get(`/p/${readOnlyId}/export/${exportType}`);
|
||||||
|
if (authn) req = req.auth('user', 'user-password');
|
||||||
|
const res = await req
|
||||||
|
.expect(200)
|
||||||
|
.buffer(true).parse(superagent.parse.text);
|
||||||
|
text = res.text;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('export OK', async function () {
|
||||||
|
assert.match(text, /This is the/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
describe('Import/Export tests requiring AbiWord/LibreOffice', function () {
|
describe('Import/Export tests requiring AbiWord/LibreOffice', function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
|
Loading…
Reference in a new issue