tests: timeouts for tests (#4773)

This commit is contained in:
John McLear 2021-02-13 19:00:06 +00:00 committed by GitHub
parent f9ec49d7ac
commit e585d321f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 368 additions and 4 deletions

View file

@ -43,6 +43,7 @@ describe(__filename, function () {
});
it('can obtain valid openapi definition document', async function () {
this.timeout(15000);
await agent.get('/api/openapi.json')
.expect(200)
.expect((res) => {
@ -56,6 +57,7 @@ describe(__filename, function () {
});
it('supports jsonp calls', async function () {
this.timeout(150);
await agent.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
.expect(200)
.expect('Content-Type', /javascript/)

View file

@ -19,6 +19,7 @@ const testPadId = makeid();
describe(__filename, function () {
describe('Connectivity For Character Encoding', function () {
it('can connect', function (done) {
this.timeout(250);
api.get('/api/')
.expect('Content-Type', /json/)
.expect(200, done);
@ -26,6 +27,7 @@ describe(__filename, function () {
});
describe('API Versioning', function () {
this.timeout(150);
it('finds the version tag', function (done) {
api.get('/api/')
.expect((res) => {
@ -39,6 +41,7 @@ describe(__filename, function () {
describe('Permission', function () {
it('errors with invalid APIKey', function (done) {
this.timeout(150);
// 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
const permErrorURL = `/api/${apiVersion}/createPad?apikey=password&padID=test`;
@ -49,6 +52,7 @@ describe(__filename, function () {
describe('createPad', function () {
it('creates a new Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to create new Pad');
@ -60,6 +64,7 @@ describe(__filename, function () {
describe('setHTML', function () {
it('Sets the HTML of a Pad attempting to weird utf8 encoded content', function (done) {
this.timeout(1000);
fs.readFile('tests/backend/specs/api/emojis.html', 'utf8', (err, html) => {
api.post(endPoint('setHTML'))
.send({
@ -77,6 +82,7 @@ describe(__filename, function () {
describe('getHTML', function () {
it('get the HTML of Pad with emojis', function (done) {
this.timeout(400);
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.html.indexOf('&#127484') === -1) {

View file

@ -35,6 +35,7 @@ describe(__filename, function () {
*/
describe('createPad', function () {
this.timeout(400);
it('creates a new Pad', function (done) {
api.get(`${endPoint('createPad')}&padID=${padID}`)
.expect((res) => {
@ -46,6 +47,7 @@ describe(__filename, function () {
});
describe('createAuthor', function () {
this.timeout(100);
it('Creates an author with a name set', function (done) {
api.get(endPoint('createAuthor'))
.expect((res) => {
@ -58,6 +60,7 @@ describe(__filename, function () {
});
describe('appendChatMessage', function () {
this.timeout(100);
it('Adds a chat message to the pad', function (done) {
api.get(`${endPoint('appendChatMessage')}&padID=${padID}&text=blalblalbha&authorID=${authorID}&time=${timestamp}`)
.expect((res) => {
@ -70,6 +73,7 @@ describe(__filename, function () {
describe('getChatHead', function () {
this.timeout(100);
it('Gets the head of chat', function (done) {
api.get(`${endPoint('getChatHead')}&padID=${padID}`)
.expect((res) => {
@ -83,6 +87,7 @@ describe(__filename, function () {
});
describe('getChatHistory', function () {
this.timeout(40);
it('Gets Chat History of a Pad', function (done) {
api.get(`${endPoint('getChatHistory')}&padID=${padID}`)
.expect((res) => {

View file

@ -236,6 +236,7 @@ describe(__filename, function () {
});
}
it('createPad', function (done) {
this.timeout(200);
api.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to create new Pad');
@ -245,6 +246,7 @@ describe(__filename, function () {
});
it('setHTML', function (done) {
this.timeout(150);
api.get(`${endPoint('setHTML')}&padID=${testPadId}&html=${encodeURIComponent(test.input)}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error(`Error:${testName}`);
@ -254,6 +256,7 @@ describe(__filename, function () {
});
it('getHTML', function (done) {
this.timeout(150);
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
const gotHtml = res.body.data.html;
@ -277,6 +280,7 @@ describe(__filename, function () {
});
it('getText', function (done) {
this.timeout(100);
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
const gotText = res.body.data.text;

View file

@ -26,10 +26,12 @@ const testPadId = makeid();
const testPadIdEnc = encodeURIComponent(testPadId);
describe(__filename, function () {
this.timeout(45000);
before(async function () { agent = await common.init(); });
describe('Connectivity', function () {
it('can connect', async function () {
this.timeout(250);
await agent.get('/api/')
.expect(200)
.expect('Content-Type', /json/);
@ -38,6 +40,7 @@ describe(__filename, function () {
describe('API Versioning', function () {
it('finds the version tag', async function () {
this.timeout(250);
await agent.get('/api/')
.expect(200)
.expect((res) => assert(res.body.currentVersion));
@ -93,6 +96,7 @@ describe(__filename, function () {
});
it('creates a new Pad, imports content to it, checks that content', async function () {
this.timeout(500);
await agent.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect(200)
.expect('Content-Type', /json/)
@ -106,6 +110,7 @@ describe(__filename, function () {
});
it('gets read only pad Id and exports the html and text for this pad', async function () {
this.timeout(250);
const ro = await agent.get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
.expect(200)
.expect((res) => assert.ok(JSON.parse(res.text).data.readOnlyID));
@ -132,6 +137,7 @@ describe(__filename, function () {
// For some reason word import does not work in testing..
// TODO: fix support for .doc files..
it('Tries to import .doc that uses soffice or abiword', async function () {
this.timeout(10000);
await agent.post(`/p/${testPadId}/import`)
.attach('file', wordDoc, {filename: '/test.doc', contentType: 'application/msword'})
.expect(200)
@ -139,6 +145,7 @@ describe(__filename, function () {
});
it('exports DOC', async function () {
this.timeout(3000);
await agent.get(`/p/${testPadId}/export/doc`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
@ -146,6 +153,7 @@ describe(__filename, function () {
});
it('Tries to import .docx that uses soffice or abiword', async function () {
this.timeout(3000);
await agent.post(`/p/${testPadId}/import`)
.attach('file', wordXDoc, {
filename: '/test.docx',
@ -157,6 +165,7 @@ describe(__filename, function () {
});
it('exports DOC from imported DOCX', async function () {
this.timeout(3000);
await agent.get(`/p/${testPadId}/export/doc`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
@ -164,6 +173,7 @@ describe(__filename, function () {
});
it('Tries to import .pdf that uses soffice or abiword', async function () {
this.timeout(3000);
await agent.post(`/p/${testPadId}/import`)
.attach('file', pdfDoc, {filename: '/test.pdf', contentType: 'application/pdf'})
.expect(200)
@ -171,6 +181,7 @@ describe(__filename, function () {
});
it('exports PDF', async function () {
this.timeout(3000);
await agent.get(`/p/${testPadId}/export/pdf`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
@ -178,6 +189,7 @@ describe(__filename, function () {
});
it('Tries to import .odt that uses soffice or abiword', async function () {
this.timeout(3000);
await agent.post(`/p/${testPadId}/import`)
.attach('file', odtDoc, {filename: '/test.odt', contentType: 'application/odt'})
.expect(200)
@ -185,6 +197,7 @@ describe(__filename, function () {
});
it('exports ODT', async function () {
this.timeout(3000);
await agent.get(`/p/${testPadId}/export/odt`)
.buffer(true).parse(superagent.parse['application/octet-stream'])
.expect(200)
@ -193,6 +206,7 @@ describe(__filename, function () {
}); // End of AbiWord/LibreOffice tests.
it('Tries to import .etherpad', async function () {
this.timeout(3000);
await agent.post(`/p/${testPadId}/import`)
.attach('file', etherpadDoc, {
filename: '/test.etherpad',
@ -203,6 +217,7 @@ describe(__filename, function () {
});
it('exports Etherpad', async function () {
this.timeout(3000);
await agent.get(`/p/${testPadId}/export/etherpad`)
.buffer(true).parse(superagent.parse.text)
.expect(200)
@ -210,6 +225,7 @@ describe(__filename, function () {
});
it('exports HTML for this Etherpad file', async function () {
this.timeout(3000);
await agent.get(`/p/${testPadId}/export/html`)
.expect(200)
.expect('content-type', 'text/html; charset=utf-8')
@ -217,6 +233,7 @@ describe(__filename, function () {
});
it('Tries to import unsupported file type', async function () {
this.timeout(3000);
settings.allowUnknownFileEnds = false;
await agent.post(`/p/${testPadId}/import`)
.attach('file', padText, {filename: '/test.xasdasdxx', contentType: 'weirdness/jobby'})
@ -252,6 +269,7 @@ describe(__filename, function () {
});
it('!authn !exist -> create', async function () {
this.timeout(100);
await agent.post(`/p/${testPadIdEnc}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
.expect(200);
@ -261,6 +279,7 @@ describe(__filename, function () {
});
it('!authn exist -> replace', async function () {
this.timeout(100);
const pad = await createTestPad('before import');
await agent.post(`/p/${testPadIdEnc}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
@ -270,6 +289,7 @@ describe(__filename, function () {
});
it('authn anonymous !exist -> fail', async function () {
this.timeout(100);
settings.requireAuthentication = true;
await agent.post(`/p/${testPadIdEnc}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
@ -278,6 +298,7 @@ describe(__filename, function () {
});
it('authn anonymous exist -> fail', async function () {
this.timeout(100);
settings.requireAuthentication = true;
const pad = await createTestPad('before import\n');
await agent.post(`/p/${testPadIdEnc}/import`)
@ -287,6 +308,7 @@ describe(__filename, function () {
});
it('authn user create !exist -> create', async function () {
this.timeout(100);
settings.requireAuthentication = true;
await agent.post(`/p/${testPadIdEnc}/import`)
.auth('user', 'user-password')
@ -298,6 +320,7 @@ describe(__filename, function () {
});
it('authn user modify !exist -> fail', async function () {
this.timeout(100);
settings.requireAuthentication = true;
authorize = () => 'modify';
await agent.post(`/p/${testPadIdEnc}/import`)
@ -308,6 +331,7 @@ describe(__filename, function () {
});
it('authn user readonly !exist -> fail', async function () {
this.timeout(100);
settings.requireAuthentication = true;
authorize = () => 'readOnly';
await agent.post(`/p/${testPadIdEnc}/import`)
@ -318,6 +342,7 @@ describe(__filename, function () {
});
it('authn user create exist -> replace', async function () {
this.timeout(100);
settings.requireAuthentication = true;
const pad = await createTestPad('before import\n');
await agent.post(`/p/${testPadIdEnc}/import`)
@ -328,6 +353,7 @@ describe(__filename, function () {
});
it('authn user modify exist -> replace', async function () {
this.timeout(100);
settings.requireAuthentication = true;
authorize = () => 'modify';
const pad = await createTestPad('before import\n');
@ -339,6 +365,7 @@ describe(__filename, function () {
});
it('authn user readonly exist -> fail', async function () {
this.timeout(100);
const pad = await createTestPad('before import\n');
settings.requireAuthentication = true;
authorize = () => 'readOnly';

View file

@ -15,6 +15,7 @@ const apiVersion = '1.2.14';
describe(__filename, function () {
describe('Connectivity for instance-level API tests', function () {
it('can connect', function (done) {
this.timeout(150);
api.get('/api/')
.expect('Content-Type', /json/)
.expect(200, done);
@ -23,6 +24,7 @@ describe(__filename, function () {
describe('getStats', function () {
it('Gets the stats of a running instance', function (done) {
this.timeout(100);
api.get(endPoint('getStats'))
.expect((res) => {
if (res.body.code !== 0) throw new Error('getStats() failed');

View file

@ -47,6 +47,7 @@ const expectedSpaceHtml = '<!doctype html><html><body><ul class="bullet"><li>one
describe(__filename, function () {
describe('Connectivity', function () {
it('can connect', function (done) {
this.timeout(200);
api.get('/api/')
.expect('Content-Type', /json/)
.expect(200, done);
@ -55,6 +56,7 @@ describe(__filename, function () {
describe('API Versioning', function () {
it('finds the version tag', function (done) {
this.timeout(150);
api.get('/api/')
.expect((res) => {
apiVersion = res.body.currentVersion;
@ -67,6 +69,7 @@ describe(__filename, function () {
describe('Permission', function () {
it('errors with invalid APIKey', function (done) {
this.timeout(150);
// 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
const permErrorURL = `/api/${apiVersion}/createPad?apikey=password&padID=test`;
@ -119,6 +122,7 @@ describe(__filename, function () {
describe('deletePad', function () {
it('deletes a Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('deletePad')}&padID=${testPadId}`)
.expect('Content-Type', /json/)
.expect(200, done); // @TODO: we shouldn't expect 200 here since the pad may not exist
@ -127,6 +131,7 @@ describe(__filename, function () {
describe('createPad', function () {
it('creates a new Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to create new Pad');
@ -138,6 +143,7 @@ describe(__filename, function () {
describe('getRevisionsCount', function () {
it('gets revision count of Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to get Revision Count');
@ -150,6 +156,7 @@ describe(__filename, function () {
describe('getSavedRevisionsCount', function () {
it('gets saved revisions count of Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions Count');
@ -162,6 +169,7 @@ describe(__filename, function () {
describe('listSavedRevisions', function () {
it('gets saved revision list of Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions List');
@ -174,6 +182,7 @@ describe(__filename, function () {
describe('getHTML', function () {
it('get the HTML of Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.html.length <= 1) throw new Error('Unable to get the HTML');
@ -185,6 +194,7 @@ describe(__filename, function () {
describe('listAllPads', function () {
it('list all pads', function (done) {
this.timeout(150);
api.get(endPoint('listAllPads'))
.expect((res) => {
if (res.body.data.padIDs.includes(testPadId) !== true) {
@ -198,6 +208,7 @@ describe(__filename, function () {
describe('deletePad', function () {
it('deletes a Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('deletePad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Deletion failed');
@ -209,6 +220,7 @@ describe(__filename, function () {
describe('listAllPads', function () {
it('list all pads', function (done) {
this.timeout(150);
api.get(endPoint('listAllPads'))
.expect((res) => {
if (res.body.data.padIDs.includes(testPadId) !== false) {
@ -222,6 +234,7 @@ describe(__filename, function () {
describe('getHTML', function () {
it('get the HTML of a Pad -- Should return a failure', function (done) {
this.timeout(150);
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 1) throw new Error('Pad deletion failed');
@ -233,6 +246,7 @@ describe(__filename, function () {
describe('createPad', function () {
it('creates a new Pad with text', function (done) {
this.timeout(200);
api.get(`${endPoint('createPad')}&padID=${testPadId}&text=testText`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Creation failed');
@ -244,6 +258,7 @@ describe(__filename, function () {
describe('getText', function () {
it('gets the Pad text and expect it to be testText with \n which is a line break', function (done) {
this.timeout(150);
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.text !== 'testText\n') throw new Error('Pad Creation with text');
@ -255,6 +270,7 @@ describe(__filename, function () {
describe('setText', function () {
it('creates a new Pad with text', function (done) {
this.timeout(200);
api.post(endPoint('setText'))
.send({
padID: testPadId,
@ -270,6 +286,7 @@ describe(__filename, function () {
describe('getText', function () {
it('gets the Pad text', function (done) {
this.timeout(150);
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.text !== 'testTextTwo\n') throw new Error('Setting Text');
@ -281,6 +298,7 @@ describe(__filename, function () {
describe('getRevisionsCount', function () {
it('gets Revision Count of a Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.revisions !== 1) throw new Error('Unable to get text revision count');
@ -292,6 +310,7 @@ describe(__filename, function () {
describe('saveRevision', function () {
it('saves Revision', function (done) {
this.timeout(150);
api.get(`${endPoint('saveRevision')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to save Revision');
@ -303,6 +322,7 @@ describe(__filename, function () {
describe('getSavedRevisionsCount', function () {
it('gets saved revisions count of Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('getSavedRevisionsCount')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions Count');
@ -315,6 +335,7 @@ describe(__filename, function () {
describe('listSavedRevisions', function () {
it('gets saved revision list of Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('listSavedRevisions')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Unable to get Saved Revisions List');
@ -326,6 +347,7 @@ describe(__filename, function () {
});
describe('padUsersCount', function () {
it('gets User Count of a Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('padUsersCount')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.padUsersCount !== 0) throw new Error('Incorrect Pad User count');
@ -337,6 +359,7 @@ describe(__filename, function () {
describe('getReadOnlyID', function () {
it('Gets the Read Only ID of a Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
.expect((res) => {
if (!res.body.data.readOnlyID) throw new Error('No Read Only ID for Pad');
@ -348,6 +371,7 @@ describe(__filename, function () {
describe('listAuthorsOfPad', function () {
it('Get Authors of the Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('listAuthorsOfPad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.authorIDs.length !== 0) throw new Error('# of Authors of pad is not 0');
@ -359,6 +383,7 @@ describe(__filename, function () {
describe('getLastEdited', function () {
it('Get When Pad was left Edited', function (done) {
this.timeout(150);
api.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
.expect((res) => {
if (!res.body.data.lastEdited) {
@ -374,6 +399,7 @@ describe(__filename, function () {
describe('setText', function () {
it('creates a new Pad with text', function (done) {
this.timeout(200);
api.post(endPoint('setText'))
.send({
padID: testPadId,
@ -389,6 +415,7 @@ describe(__filename, function () {
describe('getLastEdited', function () {
it('Get When Pad was left Edited', function (done) {
this.timeout(150);
api.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.lastEdited <= lastEdited) {
@ -402,6 +429,7 @@ describe(__filename, function () {
describe('padUsers', function () {
it('gets User Count of a Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('padUsers')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.padUsers.length !== 0) throw new Error('Incorrect Pad Users');
@ -413,6 +441,7 @@ describe(__filename, function () {
describe('deletePad', function () {
it('deletes a Pad', function (done) {
this.timeout(150);
api.get(`${endPoint('deletePad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Deletion failed');
@ -428,6 +457,7 @@ describe(__filename, function () {
describe('createPad', function () {
it('creates a new Pad with text', function (done) {
this.timeout(200);
api.get(`${endPoint('createPad')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Creation failed');
@ -439,6 +469,7 @@ describe(__filename, function () {
describe('setText', function () {
it('Sets text on a pad Id', function (done) {
this.timeout(150);
api.post(`${endPoint('setText')}&padID=${testPadId}`)
.field({text})
.expect((res) => {
@ -451,6 +482,7 @@ describe(__filename, function () {
describe('getText', function () {
it('Gets text on a pad Id', function (done) {
this.timeout(200);
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Get Text failed');
@ -463,6 +495,7 @@ describe(__filename, function () {
describe('setText', function () {
it('Sets text on a pad Id including an explicit newline', function (done) {
this.timeout(200);
api.post(`${endPoint('setText')}&padID=${testPadId}`)
.field({text: `${text}\n`})
.expect((res) => {
@ -475,6 +508,7 @@ describe(__filename, function () {
describe('getText', function () {
it("Gets text on a pad Id and doesn't have an excess newline", function (done) {
this.timeout(150);
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Get Text failed');
@ -487,6 +521,7 @@ describe(__filename, function () {
describe('getLastEdited', function () {
it('Gets when pad was last edited', function (done) {
this.timeout(150);
api.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.lastEdited === 0) throw new Error('Get Last Edited Failed');
@ -498,6 +533,7 @@ describe(__filename, function () {
describe('movePad', function () {
it('Move a Pad to a different Pad ID', function (done) {
this.timeout(200);
api.get(`${endPoint('movePad')}&sourceID=${testPadId}&destinationID=${newPadId}&force=true`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Moving Pad Failed');
@ -509,6 +545,7 @@ describe(__filename, function () {
describe('getText', function () {
it('Gets text on a pad Id', function (done) {
this.timeout(150);
api.get(`${endPoint('getText')}&padID=${newPadId}`)
.expect((res) => {
if (res.body.data.text !== `${text}\n`) throw new Error('Pad Get Text failed');
@ -520,6 +557,7 @@ describe(__filename, function () {
describe('movePad', function () {
it('Move a Pad to a different Pad ID', function (done) {
this.timeout(200);
api.get(`${endPoint('movePad')}&sourceID=${newPadId}&destinationID=${testPadId}&force=false`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Moving Pad Failed');
@ -531,6 +569,7 @@ describe(__filename, function () {
describe('getText', function () {
it('Gets text on a pad Id', function (done) {
this.timeout(150);
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.data.text !== `${text}\n`) throw new Error('Pad Get Text failed');
@ -542,6 +581,7 @@ describe(__filename, function () {
describe('getLastEdited', function () {
it('Gets when pad was last edited', function (done) {
this.timeout(150);
api.get(`${endPoint('getLastEdited')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.lastEdited === 0) throw new Error('Get Last Edited Failed');
@ -553,6 +593,7 @@ describe(__filename, function () {
describe('appendText', function () {
it('Append text to a pad Id', function (done) {
this.timeout(150);
api.get(`${endPoint('appendText', '1.2.13')}&padID=${testPadId}&text=hello`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Append Text failed');
@ -564,6 +605,7 @@ describe(__filename, function () {
describe('getText', function () {
it('Gets text on a pad Id', function (done) {
this.timeout(150);
api.get(`${endPoint('getText')}&padID=${testPadId}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Pad Get Text failed');
@ -577,6 +619,7 @@ describe(__filename, function () {
describe('setHTML', function () {
it('Sets the HTML of a Pad attempting to pass ugly HTML', function (done) {
this.timeout(200);
const html = '<div><b>Hello HTML</title></head></div>';
api.post(endPoint('setHTML'))
.send({
@ -593,6 +636,7 @@ describe(__filename, function () {
describe('setHTML', function () {
it('Sets the HTML of a Pad with complex nested lists of different types', function (done) {
this.timeout(200);
api.post(endPoint('setHTML'))
.send({
padID: testPadId,
@ -608,6 +652,7 @@ describe(__filename, function () {
describe('getHTML', function () {
it('Gets back the HTML of a Pad with complex nested lists of different types', function (done) {
this.timeout(150);
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
const receivedHtml = res.body.data.html.replace('<br></body>', '</body>').toLowerCase();
@ -631,6 +676,7 @@ describe(__filename, function () {
describe('setHTML', function () {
it('Sets the HTML of a Pad with white space between list items', function (done) {
this.timeout(200);
api.get(`${endPoint('setHTML')}&padID=${testPadId}&html=${ulSpaceHtml}`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('List HTML cant be imported');
@ -642,6 +688,7 @@ describe(__filename, function () {
describe('getHTML', function () {
it('Gets back the HTML of a Pad with complex nested lists of different types', function (done) {
this.timeout(150);
api.get(`${endPoint('getHTML')}&padID=${testPadId}`)
.expect((res) => {
const receivedHtml = res.body.data.html.replace('<br></body>', '</body>').toLowerCase();
@ -664,6 +711,7 @@ describe(__filename, function () {
describe('createPad', function () {
it('errors if pad can be created', function (done) {
this.timeout(150);
const badUrlChars = ['/', '%23', '%3F', '%26'];
async.map(
badUrlChars,
@ -681,6 +729,7 @@ describe(__filename, function () {
describe('copyPad', function () {
it('copies the content of a existent pad', function (done) {
this.timeout(200);
api.get(`${endPoint('copyPad')}&sourceID=${testPadId}&destinationID=${copiedPadId}&force=true`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Copy Pad Failed');
@ -703,6 +752,7 @@ describe(__filename, function () {
});
it('returns a successful response', function (done) {
this.timeout(200);
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${newPad}&force=false`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Copy Pad Without History Failed');
@ -713,6 +763,7 @@ describe(__filename, function () {
// this test validates if the source pad's text and attributes are kept
it('creates a new pad with the same content as the source pad', function (done) {
this.timeout(200);
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${newPad}&force=false`)
.expect((res) => {
if (res.body.code !== 0) throw new Error('Copy Pad Without History Failed');
@ -742,6 +793,7 @@ describe(__filename, function () {
const padId = makeid();
const padWithNonExistentGroup = `notExistentGroup$${padId}`;
it('throws an error', function (done) {
this.timeout(150);
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${padWithNonExistentGroup}&force=true`)
.expect((res) => {
// code 1, it means an error has happened
@ -760,6 +812,7 @@ describe(__filename, function () {
context('and force is false', function () {
it('throws an error', function (done) {
this.timeout(150);
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${padIdExistent}&force=false`)
.expect((res) => {
// code 1, it means an error has happened
@ -771,6 +824,7 @@ describe(__filename, function () {
context('and force is true', function () {
it('returns a successful response', function (done) {
this.timeout(200);
api.get(`${endPoint('copyPadWithoutHistory')}&sourceID=${sourcePadId}&destinationID=${padIdExistent}&force=true`)
.expect((res) => {
// code 1, it means an error has happened

View file

@ -15,6 +15,7 @@ let padID = makeid();
describe(__filename, function () {
describe('API Versioning', function () {
it('errors if can not connect', async function () {
this.timeout(200);
await api.get('/api/')
.expect(200)
.expect((res) => {
@ -56,6 +57,7 @@ describe(__filename, function () {
describe('API: Group creation and deletion', function () {
it('createGroup', async function () {
this.timeout(100);
await api.get(endPoint('createGroup'))
.expect(200)
.expect('Content-Type', /json/)
@ -67,6 +69,7 @@ describe(__filename, function () {
});
it('listSessionsOfGroup for empty group', async function () {
this.timeout(100);
await api.get(`${endPoint('listSessionsOfGroup')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -77,6 +80,7 @@ describe(__filename, function () {
});
it('deleteGroup', async function () {
this.timeout(100);
await api.get(`${endPoint('deleteGroup')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -86,6 +90,7 @@ describe(__filename, function () {
});
it('createGroupIfNotExistsFor', async function () {
this.timeout(100);
await api.get(`${endPoint('createGroupIfNotExistsFor')}&groupMapper=management`)
.expect(200)
.expect('Content-Type', /json/)
@ -98,6 +103,7 @@ describe(__filename, function () {
// Test coverage for https://github.com/ether/etherpad-lite/issues/4227
// Creates a group, creates 2 sessions, 2 pads and then deletes the group.
it('createGroup', async function () {
this.timeout(100);
await api.get(endPoint('createGroup'))
.expect(200)
.expect('Content-Type', /json/)
@ -109,6 +115,7 @@ describe(__filename, function () {
});
it('createAuthor', async function () {
this.timeout(100);
await api.get(endPoint('createAuthor'))
.expect(200)
.expect('Content-Type', /json/)
@ -120,6 +127,7 @@ describe(__filename, function () {
});
it('createSession', async function () {
this.timeout(100);
await api.get(`${endPoint('createSession')
}&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
.expect(200)
@ -132,6 +140,7 @@ describe(__filename, function () {
});
it('createSession', async function () {
this.timeout(100);
await api.get(`${endPoint('createSession')
}&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
.expect(200)
@ -144,6 +153,7 @@ describe(__filename, function () {
});
it('createGroupPad', async function () {
this.timeout(100);
await api.get(`${endPoint('createGroupPad')}&groupID=${groupID}&padName=x1234567`)
.expect(200)
.expect('Content-Type', /json/)
@ -153,6 +163,7 @@ describe(__filename, function () {
});
it('createGroupPad', async function () {
this.timeout(100);
await api.get(`${endPoint('createGroupPad')}&groupID=${groupID}&padName=x12345678`)
.expect(200)
.expect('Content-Type', /json/)
@ -162,6 +173,7 @@ describe(__filename, function () {
});
it('deleteGroup', async function () {
this.timeout(100);
await api.get(`${endPoint('deleteGroup')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -174,6 +186,7 @@ describe(__filename, function () {
describe('API: Author creation', function () {
it('createGroup', async function () {
this.timeout(100);
await api.get(endPoint('createGroup'))
.expect(200)
.expect('Content-Type', /json/)
@ -185,6 +198,7 @@ describe(__filename, function () {
});
it('createAuthor', async function () {
this.timeout(100);
await api.get(endPoint('createAuthor'))
.expect(200)
.expect('Content-Type', /json/)
@ -195,6 +209,7 @@ describe(__filename, function () {
});
it('createAuthor with name', async function () {
this.timeout(100);
await api.get(`${endPoint('createAuthor')}&name=john`)
.expect(200)
.expect('Content-Type', /json/)
@ -206,6 +221,7 @@ describe(__filename, function () {
});
it('createAuthorIfNotExistsFor', async function () {
this.timeout(100);
await api.get(`${endPoint('createAuthorIfNotExistsFor')}&authorMapper=chris`)
.expect(200)
.expect('Content-Type', /json/)
@ -216,6 +232,7 @@ describe(__filename, function () {
});
it('getAuthorName', async function () {
this.timeout(100);
await api.get(`${endPoint('getAuthorName')}&authorID=${authorID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -228,6 +245,7 @@ describe(__filename, function () {
describe('API: Sessions', function () {
it('createSession', async function () {
this.timeout(100);
await api.get(`${endPoint('createSession')
}&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
.expect(200)
@ -240,6 +258,7 @@ describe(__filename, function () {
});
it('getSessionInfo', async function () {
this.timeout(100);
await api.get(`${endPoint('getSessionInfo')}&sessionID=${sessionID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -252,6 +271,7 @@ describe(__filename, function () {
});
it('listSessionsOfGroup', async function () {
this.timeout(100);
await api.get(`${endPoint('listSessionsOfGroup')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -262,6 +282,7 @@ describe(__filename, function () {
});
it('deleteSession', async function () {
this.timeout(100);
await api.get(`${endPoint('deleteSession')}&sessionID=${sessionID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -271,6 +292,7 @@ describe(__filename, function () {
});
it('getSessionInfo of deleted session', async function () {
this.timeout(100);
await api.get(`${endPoint('getSessionInfo')}&sessionID=${sessionID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -282,6 +304,7 @@ describe(__filename, function () {
describe('API: Group pad management', function () {
it('listPads', async function () {
this.timeout(100);
await api.get(`${endPoint('listPads')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -292,6 +315,7 @@ describe(__filename, function () {
});
it('createGroupPad', async function () {
this.timeout(100);
await api.get(`${endPoint('createGroupPad')}&groupID=${groupID}&padName=${padID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -302,6 +326,7 @@ describe(__filename, function () {
});
it('listPads after creating a group pad', async function () {
this.timeout(100);
await api.get(`${endPoint('listPads')}&groupID=${groupID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -314,6 +339,7 @@ describe(__filename, function () {
describe('API: Pad security', function () {
it('getPublicStatus', async function () {
this.timeout(100);
await api.get(`${endPoint('getPublicStatus')}&padID=${padID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -324,6 +350,7 @@ describe(__filename, function () {
});
it('setPublicStatus', async function () {
this.timeout(100);
await api.get(`${endPoint('setPublicStatus')}&padID=${padID}&publicStatus=true`)
.expect(200)
.expect('Content-Type', /json/)
@ -333,6 +360,7 @@ describe(__filename, function () {
});
it('getPublicStatus after changing public status', async function () {
this.timeout(100);
await api.get(`${endPoint('getPublicStatus')}&padID=${padID}`)
.expect(200)
.expect('Content-Type', /json/)
@ -349,6 +377,7 @@ describe(__filename, function () {
describe('API: Misc', function () {
it('listPadsOfAuthor', async function () {
this.timeout(100);
await api.get(`${endPoint('listPadsOfAuthor')}&authorID=${authorID}`)
.expect(200)
.expect('Content-Type', /json/)