From e585d321f9357dacf4a3a0d1e079e44e3bf6d798 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 13 Feb 2021 19:00:06 +0000 Subject: [PATCH] tests: timeouts for tests (#4773) --- src/tests/backend/specs/api/api.js | 2 + .../backend/specs/api/characterEncoding.js | 6 ++ src/tests/backend/specs/api/chat.js | 5 + src/tests/backend/specs/api/importexport.js | 4 + .../backend/specs/api/importexportGetPost.js | 27 ++++++ src/tests/backend/specs/api/instance.js | 2 + src/tests/backend/specs/api/pad.js | 54 +++++++++++ .../backend/specs/api/sessionsAndGroups.js | 29 ++++++ src/tests/backend/specs/contentcollector.js | 1 + src/tests/backend/specs/hooks.js | 94 +++++++++++++++++++ src/tests/backend/specs/socketio.js | 25 +++++ src/tests/backend/specs/specialpages.js | 2 + src/tests/backend/specs/webaccess.js | 47 ++++++++++ src/tests/frontend/specs/alphabet.js | 1 + src/tests/frontend/specs/bold.js | 2 + src/tests/frontend/specs/change_user_color.js | 3 +- src/tests/frontend/specs/change_user_name.js | 2 + src/tests/frontend/specs/chat.js | 5 +- .../frontend/specs/chat_load_messages.js | 3 + .../frontend/specs/clear_authorship_colors.js | 2 + src/tests/frontend/specs/delete.js | 1 + src/tests/frontend/specs/drag_and_drop.js | 2 + src/tests/frontend/specs/embed_value.js | 4 + src/tests/frontend/specs/enter.js | 1 + src/tests/frontend/specs/font_type.js | 1 + src/tests/frontend/specs/indentation.js | 6 ++ src/tests/frontend/specs/italic.js | 2 + src/tests/frontend/specs/language.js | 3 + ...ultiple_authors_clear_authorship_colors.js | 1 + src/tests/frontend/specs/ordered_list.js | 7 ++ src/tests/frontend/specs/pad_modal.js | 5 + src/tests/frontend/specs/redo.js | 2 + src/tests/frontend/specs/scrollTo.js | 4 +- .../specs/select_formatting_buttons.js | 3 + src/tests/frontend/specs/strikethrough.js | 1 + src/tests/frontend/specs/timeslider_follow.js | 1 + src/tests/frontend/specs/timeslider_labels.js | 1 + .../specs/timeslider_numeric_padID.js | 1 + .../frontend/specs/timeslider_revisions.js | 1 + src/tests/frontend/specs/undo.js | 3 + src/tests/frontend/specs/unordered_list.js | 5 + .../frontend/specs/urls_become_clickable.js | 1 + 42 files changed, 368 insertions(+), 4 deletions(-) diff --git a/src/tests/backend/specs/api/api.js b/src/tests/backend/specs/api/api.js index 070632b0b..cd8506519 100644 --- a/src/tests/backend/specs/api/api.js +++ b/src/tests/backend/specs/api/api.js @@ -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/) diff --git a/src/tests/backend/specs/api/characterEncoding.js b/src/tests/backend/specs/api/characterEncoding.js index 211885a28..00183e12a 100644 --- a/src/tests/backend/specs/api/characterEncoding.js +++ b/src/tests/backend/specs/api/characterEncoding.js @@ -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('🇼') === -1) { diff --git a/src/tests/backend/specs/api/chat.js b/src/tests/backend/specs/api/chat.js index e2ddf0540..570a8aaaa 100644 --- a/src/tests/backend/specs/api/chat.js +++ b/src/tests/backend/specs/api/chat.js @@ -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) => { diff --git a/src/tests/backend/specs/api/importexport.js b/src/tests/backend/specs/api/importexport.js index 1c93c11c4..960f019bd 100644 --- a/src/tests/backend/specs/api/importexport.js +++ b/src/tests/backend/specs/api/importexport.js @@ -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; diff --git a/src/tests/backend/specs/api/importexportGetPost.js b/src/tests/backend/specs/api/importexportGetPost.js index ce03c5768..73b58a2f3 100644 --- a/src/tests/backend/specs/api/importexportGetPost.js +++ b/src/tests/backend/specs/api/importexportGetPost.js @@ -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'; diff --git a/src/tests/backend/specs/api/instance.js b/src/tests/backend/specs/api/instance.js index 833c75d5a..ab465033e 100644 --- a/src/tests/backend/specs/api/instance.js +++ b/src/tests/backend/specs/api/instance.js @@ -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'); diff --git a/src/tests/backend/specs/api/pad.js b/src/tests/backend/specs/api/pad.js index 92467cb1f..c94ad810d 100644 --- a/src/tests/backend/specs/api/pad.js +++ b/src/tests/backend/specs/api/pad.js @@ -47,6 +47,7 @@ const expectedSpaceHtml = '