mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
tests: Refine copyPadWithoutHistory
tests
This commit is contained in:
parent
d74dd235a4
commit
ed78b56079
1 changed files with 22 additions and 33 deletions
|
@ -48,22 +48,16 @@ const ulSpaceHtml = '<!doctype html><html><body><ul class="bullet"> <li>one</li>
|
||||||
const expectedSpaceHtml = '<!doctype html><html><body><ul class="bullet"><li>one</ul></body></html>';
|
const expectedSpaceHtml = '<!doctype html><html><body><ul class="bullet"><li>one</ul></body></html>';
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
before(async function () { agent = await common.init(); });
|
before(async function () {
|
||||||
|
agent = await common.init();
|
||||||
describe('Sanity checks', function () {
|
const res = await agent.get('/api/')
|
||||||
it('can connect', async function () {
|
|
||||||
await agent.get('/api/')
|
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-Type', /json/);
|
.expect('Content-Type', /json/);
|
||||||
});
|
|
||||||
|
|
||||||
it('finds the version tag', async function () {
|
|
||||||
const res = await agent.get('/api/')
|
|
||||||
.expect(200);
|
|
||||||
apiVersion = res.body.currentVersion;
|
apiVersion = res.body.currentVersion;
|
||||||
assert(apiVersion);
|
assert(apiVersion);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Sanity checks', function () {
|
||||||
it('errors with invalid APIKey', async function () {
|
it('errors with invalid APIKey', async function () {
|
||||||
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
|
// This is broken because Etherpad doesn't handle HTTP codes properly see #2343
|
||||||
// If your APIKey is password you deserve to fail all tests anyway
|
// If your APIKey is password you deserve to fail all tests anyway
|
||||||
|
@ -523,37 +517,32 @@ describe(__filename, function () {
|
||||||
assert.equal(receivedHtml, expectedHtml);
|
assert.equal(receivedHtml, expectedHtml);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when try copy a pad with a group that does not exist', function () {
|
it('copying to a non-existent group throws an error', async function () {
|
||||||
const padId = makeid();
|
const padWithNonExistentGroup = `notExistentGroup$${newPad}`;
|
||||||
const padWithNonExistentGroup = `notExistentGroup$${padId}`;
|
|
||||||
it('throws an error', async function () {
|
|
||||||
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
||||||
`&sourceID=${sourcePadId}` +
|
`&sourceID=${sourcePadId}` +
|
||||||
`&destinationID=${padWithNonExistentGroup}&force=true`)
|
`&destinationID=${padWithNonExistentGroup}&force=true`)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
assert.equal(res.body.code, 1);
|
assert.equal(res.body.code, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('copying to an existing pad', function () {
|
||||||
|
beforeEach(async function () {
|
||||||
|
await createNewPadWithHtml(newPad, ulHtml);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when try copy a pad and destination pad already exist', function () {
|
it('force=false fails', async function () {
|
||||||
const padIdExistent = makeid();
|
|
||||||
|
|
||||||
before(async function () {
|
|
||||||
await createNewPadWithHtml(padIdExistent, ulHtml);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('force=false throws an error', async function () {
|
|
||||||
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
||||||
`&sourceID=${sourcePadId}` +
|
`&sourceID=${sourcePadId}` +
|
||||||
`&destinationID=${padIdExistent}&force=false`)
|
`&destinationID=${newPad}&force=false`)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
assert.equal(res.body.code, 1);
|
assert.equal(res.body.code, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('force=true returns a successful response', async function () {
|
it('force=true succeeds', async function () {
|
||||||
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
const res = await agent.get(`${endPoint('copyPadWithoutHistory')}` +
|
||||||
`&sourceID=${sourcePadId}` +
|
`&sourceID=${sourcePadId}` +
|
||||||
`&destinationID=${padIdExistent}&force=true`)
|
`&destinationID=${newPad}&force=true`)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
assert.equal(res.body.code, 0);
|
assert.equal(res.body.code, 0);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue