1
preline
diff --git a/tests/backend/specs/api/pad.js b/tests/backend/specs/api/pad.js
index cf198edcb..004469bfb 100644
--- a/tests/backend/specs/api/pad.js
+++ b/tests/backend/specs/api/pad.js
@@ -107,9 +107,9 @@ describe(__filename, function () {
-> setText(padId, "hello world")
-> getLastEdited(padID) -- Should be when pad was made
-> getText(padId) -- Should be "hello world"
- -> movePad(padID, newPadId) -- Should provide consistant pad data
+ -> movePad(padID, newPadId) -- Should provide consistent pad data
-> getText(newPadId) -- Should be "hello world"
- -> movePad(newPadID, originalPadId) -- Should provide consistant pad data
+ -> movePad(newPadID, originalPadId) -- Should provide consistent pad data
-> getText(originalPadId) -- Should be "hello world"
-> getLastEdited(padID) -- Should not be 0
-> appendText(padID, "hello")
diff --git a/tests/backend/specs/api/sessionsAndGroups.js b/tests/backend/specs/api/sessionsAndGroups.js
index bb3e28719..239a079f1 100644
--- a/tests/backend/specs/api/sessionsAndGroups.js
+++ b/tests/backend/specs/api/sessionsAndGroups.js
@@ -100,6 +100,83 @@ describe(__filename, function () {
assert(res.body.data.groupID);
});
});
+
+ // 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 () {
+ await api.get(endPoint('createGroup'))
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .expect((res) => {
+ assert.equal(res.body.code, 0);
+ assert(res.body.data.groupID);
+ groupID = res.body.data.groupID;
+ });
+ });
+
+ it('createAuthor', async function () {
+ await api.get(endPoint('createAuthor'))
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .expect((res) => {
+ assert.equal(res.body.code, 0);
+ assert(res.body.data.authorID);
+ authorID = res.body.data.authorID;
+ });
+ });
+
+ it('createSession', async function () {
+ await api.get(`${endPoint('createSession')
+ }&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .expect((res) => {
+ assert.equal(res.body.code, 0);
+ assert(res.body.data.sessionID);
+ sessionID = res.body.data.sessionID;
+ });
+ });
+
+ it('createSession', async function () {
+ await api.get(`${endPoint('createSession')
+ }&authorID=${authorID}&groupID=${groupID}&validUntil=999999999999`)
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .expect((res) => {
+ assert.equal(res.body.code, 0);
+ assert(res.body.data.sessionID);
+ sessionID = res.body.data.sessionID;
+ });
+ });
+
+ it('createGroupPad', async function () {
+ await api.get(`${endPoint('createGroupPad')}&groupID=${groupID}&padName=x1234567`)
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .expect((res) => {
+ assert.equal(res.body.code, 0);
+ });
+ });
+
+ it('createGroupPad', async function () {
+ await api.get(`${endPoint('createGroupPad')}&groupID=${groupID}&padName=x12345678`)
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .expect((res) => {
+ assert.equal(res.body.code, 0);
+ });
+ });
+
+ it('deleteGroup', async function () {
+ await api.get(`${endPoint('deleteGroup')}&groupID=${groupID}`)
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .expect((res) => {
+ assert.equal(res.body.code, 0);
+ });
+ });
+ // End of coverage for https://github.com/ether/etherpad-lite/issues/4227
+
});
describe('API: Author creation', function () {
diff --git a/tests/backend/specs/contentcollector.js b/tests/backend/specs/contentcollector.js
index 13a1cf116..22d18380c 100644
--- a/tests/backend/specs/contentcollector.js
+++ b/tests/backend/specs/contentcollector.js
@@ -140,7 +140,7 @@ const tests = {
wantText: [' word1 word2 word3'],
},
nonBreakingSpacePreceededBySpaceBetweenWords: {
- description: 'A non-breaking space preceeded by a normal space',
+ description: 'A non-breaking space preceded by a normal space',
html: ' word1 word2 word3
',
wantLineAttribs: ['+l'],
wantText: [' word1 word2 word3'],
@@ -240,7 +240,7 @@ pre
],
},
preIntroducesASpace: {
- description: 'pre should be on a new line not preceeded by a space',
+ description: 'pre should be on a new line not preceded by a space',
html: `
1
preline
diff --git a/tests/backend/specs/hooks.js b/tests/backend/specs/hooks.js
index 21fb41bb5..77ac8a57c 100644
--- a/tests/backend/specs/hooks.js
+++ b/tests/backend/specs/hooks.js
@@ -1,11 +1,8 @@
'use strict';
-
-function m(mod) { return `${__dirname}/../../../src/${mod}`; }
-
const assert = require('assert').strict;
-const hooks = require(m('static/js/pluginfw/hooks'));
-const plugins = require(m('static/js/pluginfw/plugin_defs'));
-const sinon = require(m('node_modules/sinon'));
+const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
+const plugins = require('ep_etherpad-lite/static/js/pluginfw/plugin_defs');
+const sinon = require('ep_etherpad-lite/node_modules/sinon');
describe(__filename, function () {
const hookName = 'testHook';
@@ -209,7 +206,7 @@ describe(__filename, function () {
// Test various ways a hook might attempt to settle twice. (Examples: call the callback a second
// time, or call the callback and then return a value.)
describe('bad hook function behavior (double settle)', function () {
- beforeEach(function () {
+ beforeEach(async function () {
sinon.stub(console, 'error');
});
@@ -413,6 +410,90 @@ describe(__filename, function () {
});
});
+ describe('hooks.callFirst', function () {
+ it('no registered hooks (undefined) -> []', async function () {
+ delete plugins.hooks.testHook;
+ assert.deepEqual(hooks.callFirst(hookName), []);
+ });
+
+ it('no registered hooks (empty list) -> []', async function () {
+ testHooks.length = 0;
+ assert.deepEqual(hooks.callFirst(hookName), []);
+ });
+
+ it('passes hook name => {}', async function () {
+ hook.hook_fn = (hn) => { assert.equal(hn, hookName); };
+ hooks.callFirst(hookName);
+ });
+
+ it('undefined context => {}', async function () {
+ hook.hook_fn = (hn, ctx) => { assert.deepEqual(ctx, {}); };
+ hooks.callFirst(hookName);
+ });
+
+ it('null context => {}', async function () {
+ hook.hook_fn = (hn, ctx) => { assert.deepEqual(ctx, {}); };
+ hooks.callFirst(hookName, null);
+ });
+
+ it('context unmodified', async function () {
+ const wantContext = {};
+ hook.hook_fn = (hn, ctx) => { assert.equal(ctx, wantContext); };
+ hooks.callFirst(hookName, wantContext);
+ });
+
+ it('predicate never satisfied -> calls all in order', async function () {
+ const gotCalls = [];
+ testHooks.length = 0;
+ for (let i = 0; i < 3; i++) {
+ const hook = makeHook();
+ hook.hook_fn = () => { gotCalls.push(i); };
+ testHooks.push(hook);
+ }
+ assert.deepEqual(hooks.callFirst(hookName), []);
+ assert.deepEqual(gotCalls, [0, 1, 2]);
+ });
+
+ it('stops when predicate is satisfied', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(), makeHook('val1'), makeHook('val2'));
+ assert.deepEqual(hooks.callFirst(hookName), ['val1']);
+ });
+
+ it('skips values that do not satisfy predicate (undefined)', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(), makeHook('val1'));
+ assert.deepEqual(hooks.callFirst(hookName), ['val1']);
+ });
+
+ it('skips values that do not satisfy predicate (empty list)', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook([]), makeHook('val1'));
+ assert.deepEqual(hooks.callFirst(hookName), ['val1']);
+ });
+
+ it('null satisifes the predicate', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(null), makeHook('val1'));
+ assert.deepEqual(hooks.callFirst(hookName), [null]);
+ });
+
+ it('non-empty arrays are returned unmodified', async function () {
+ const want = ['val1'];
+ testHooks.length = 0;
+ testHooks.push(makeHook(want), makeHook(['val2']));
+ assert.equal(hooks.callFirst(hookName), want); // Note: *NOT* deepEqual!
+ });
+
+ it('value can be passed via callback', async function () {
+ const want = {};
+ hook.hook_fn = (hn, ctx, cb) => { cb(want); };
+ const got = hooks.callFirst(hookName);
+ assert.deepEqual(got, [want]);
+ assert.equal(got[0], want); // Note: *NOT* deepEqual!
+ });
+ });
+
describe('callHookFnAsync', function () {
const callHookFnAsync = hooks.exportedForTestingOnly.callHookFnAsync; // Convenience shorthand.
@@ -587,7 +668,7 @@ describe(__filename, function () {
// Test various ways a hook might attempt to settle twice. (Examples: call the callback a second
// time, or call the callback and then return a value.)
describe('bad hook function behavior (double settle)', function () {
- beforeEach(function () {
+ beforeEach(async function () {
sinon.stub(console, 'error');
});
@@ -935,4 +1016,243 @@ describe(__filename, function () {
});
});
});
+
+ describe('hooks.callAllSerial', function () {
+ describe('basic behavior', function () {
+ it('calls all asynchronously, serially, in order', async function () {
+ const gotCalls = [];
+ testHooks.length = 0;
+ for (let i = 0; i < 3; i++) {
+ const hook = makeHook();
+ hook.hook_fn = async () => {
+ gotCalls.push(i);
+ // Check gotCalls asynchronously to ensure that the next hook function does not start
+ // executing before this hook function has resolved.
+ return await new Promise((resolve) => {
+ setImmediate(() => {
+ assert.deepEqual(gotCalls, [...Array(i + 1).keys()]);
+ resolve(i);
+ });
+ });
+ };
+ testHooks.push(hook);
+ }
+ assert.deepEqual(await hooks.callAllSerial(hookName), [0, 1, 2]);
+ assert.deepEqual(gotCalls, [0, 1, 2]);
+ });
+
+ it('passes hook name', async function () {
+ hook.hook_fn = async (hn) => { assert.equal(hn, hookName); };
+ await hooks.callAllSerial(hookName);
+ });
+
+ it('undefined context -> {}', async function () {
+ hook.hook_fn = async (hn, ctx) => { assert.deepEqual(ctx, {}); };
+ await hooks.callAllSerial(hookName);
+ });
+
+ it('null context -> {}', async function () {
+ hook.hook_fn = async (hn, ctx) => { assert.deepEqual(ctx, {}); };
+ await hooks.callAllSerial(hookName, null);
+ });
+
+ it('context unmodified', async function () {
+ const wantContext = {};
+ hook.hook_fn = async (hn, ctx) => { assert.equal(ctx, wantContext); };
+ await hooks.callAllSerial(hookName, wantContext);
+ });
+ });
+
+ describe('result processing', function () {
+ it('no registered hooks (undefined) -> []', async function () {
+ delete plugins.hooks[hookName];
+ assert.deepEqual(await hooks.callAllSerial(hookName), []);
+ });
+
+ it('no registered hooks (empty list) -> []', async function () {
+ testHooks.length = 0;
+ assert.deepEqual(await hooks.callAllSerial(hookName), []);
+ });
+
+ it('flattens one level', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(1), makeHook([2]), makeHook([[3]]));
+ assert.deepEqual(await hooks.callAllSerial(hookName), [1, 2, [3]]);
+ });
+
+ it('filters out undefined', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(), makeHook([2]), makeHook([[3]]), makeHook(Promise.resolve()));
+ assert.deepEqual(await hooks.callAllSerial(hookName), [2, [3]]);
+ });
+
+ it('preserves null', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(null), makeHook([2]), makeHook(Promise.resolve(null)));
+ assert.deepEqual(await hooks.callAllSerial(hookName), [null, 2, null]);
+ });
+
+ it('all undefined -> []', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(), makeHook(Promise.resolve()));
+ assert.deepEqual(await hooks.callAllSerial(hookName), []);
+ });
+ });
+ });
+
+ describe('hooks.aCallFirst', function () {
+ it('no registered hooks (undefined) -> []', async function () {
+ delete plugins.hooks.testHook;
+ assert.deepEqual(await hooks.aCallFirst(hookName), []);
+ });
+
+ it('no registered hooks (empty list) -> []', async function () {
+ testHooks.length = 0;
+ assert.deepEqual(await hooks.aCallFirst(hookName), []);
+ });
+
+ it('passes hook name => {}', async function () {
+ hook.hook_fn = (hn) => { assert.equal(hn, hookName); };
+ await hooks.aCallFirst(hookName);
+ });
+
+ it('undefined context => {}', async function () {
+ hook.hook_fn = (hn, ctx) => { assert.deepEqual(ctx, {}); };
+ await hooks.aCallFirst(hookName);
+ });
+
+ it('null context => {}', async function () {
+ hook.hook_fn = (hn, ctx) => { assert.deepEqual(ctx, {}); };
+ await hooks.aCallFirst(hookName, null);
+ });
+
+ it('context unmodified', async function () {
+ const wantContext = {};
+ hook.hook_fn = (hn, ctx) => { assert.equal(ctx, wantContext); };
+ await hooks.aCallFirst(hookName, wantContext);
+ });
+
+ it('default predicate: predicate never satisfied -> calls all in order', async function () {
+ const gotCalls = [];
+ testHooks.length = 0;
+ for (let i = 0; i < 3; i++) {
+ const hook = makeHook();
+ hook.hook_fn = () => { gotCalls.push(i); };
+ testHooks.push(hook);
+ }
+ assert.deepEqual(await hooks.aCallFirst(hookName), []);
+ assert.deepEqual(gotCalls, [0, 1, 2]);
+ });
+
+ it('calls hook functions serially', async function () {
+ const gotCalls = [];
+ testHooks.length = 0;
+ for (let i = 0; i < 3; i++) {
+ const hook = makeHook();
+ hook.hook_fn = async () => {
+ gotCalls.push(i);
+ // Check gotCalls asynchronously to ensure that the next hook function does not start
+ // executing before this hook function has resolved.
+ return await new Promise((resolve) => {
+ setImmediate(() => {
+ assert.deepEqual(gotCalls, [...Array(i + 1).keys()]);
+ resolve();
+ });
+ });
+ };
+ testHooks.push(hook);
+ }
+ assert.deepEqual(await hooks.aCallFirst(hookName), []);
+ assert.deepEqual(gotCalls, [0, 1, 2]);
+ });
+
+ it('default predicate: stops when satisfied', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(), makeHook('val1'), makeHook('val2'));
+ assert.deepEqual(await hooks.aCallFirst(hookName), ['val1']);
+ });
+
+ it('default predicate: skips values that do not satisfy (undefined)', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(), makeHook('val1'));
+ assert.deepEqual(await hooks.aCallFirst(hookName), ['val1']);
+ });
+
+ it('default predicate: skips values that do not satisfy (empty list)', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook([]), makeHook('val1'));
+ assert.deepEqual(await hooks.aCallFirst(hookName), ['val1']);
+ });
+
+ it('default predicate: null satisifes', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(null), makeHook('val1'));
+ assert.deepEqual(await hooks.aCallFirst(hookName), [null]);
+ });
+
+ it('custom predicate: called for each hook function', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(0), makeHook(1), makeHook(2));
+ let got = 0;
+ await hooks.aCallFirst(hookName, null, null, (val) => { ++got; return false; });
+ assert.equal(got, 3);
+ });
+
+ it('custom predicate: boolean false/true continues/stops iteration', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(1), makeHook(2), makeHook(3));
+ let nCall = 0;
+ const predicate = (val) => {
+ assert.deepEqual(val, [++nCall]);
+ return nCall === 2;
+ };
+ assert.deepEqual(await hooks.aCallFirst(hookName, null, null, predicate), [2]);
+ assert.equal(nCall, 2);
+ });
+
+ it('custom predicate: non-boolean falsy/truthy continues/stops iteration', async function () {
+ testHooks.length = 0;
+ testHooks.push(makeHook(1), makeHook(2), makeHook(3));
+ let nCall = 0;
+ const predicate = (val) => {
+ assert.deepEqual(val, [++nCall]);
+ return nCall === 2 ? {} : null;
+ };
+ assert.deepEqual(await hooks.aCallFirst(hookName, null, null, predicate), [2]);
+ assert.equal(nCall, 2);
+ });
+
+ it('custom predicate: array value passed unmodified to predicate', async function () {
+ const want = [0];
+ hook.hook_fn = () => want;
+ const predicate = (got) => { assert.equal(got, want); }; // Note: *NOT* deepEqual!
+ await hooks.aCallFirst(hookName, null, null, predicate);
+ });
+
+ it('custom predicate: normalized value passed to predicate (undefined)', async function () {
+ const predicate = (got) => { assert.deepEqual(got, []); };
+ await hooks.aCallFirst(hookName, null, null, predicate);
+ });
+
+ it('custom predicate: normalized value passed to predicate (null)', async function () {
+ hook.hook_fn = () => null;
+ const predicate = (got) => { assert.deepEqual(got, [null]); };
+ await hooks.aCallFirst(hookName, null, null, predicate);
+ });
+
+ it('non-empty arrays are returned unmodified', async function () {
+ const want = ['val1'];
+ testHooks.length = 0;
+ testHooks.push(makeHook(want), makeHook(['val2']));
+ assert.equal(await hooks.aCallFirst(hookName), want); // Note: *NOT* deepEqual!
+ });
+
+ it('value can be passed via callback', async function () {
+ const want = {};
+ hook.hook_fn = (hn, ctx, cb) => { cb(want); };
+ const got = await hooks.aCallFirst(hookName);
+ assert.deepEqual(got, [want]);
+ assert.equal(got[0], want); // Note: *NOT* deepEqual!
+ });
+ });
});
diff --git a/tests/backend/specs/webaccess.js b/tests/backend/specs/webaccess.js
index 0843c3538..90558e327 100644
--- a/tests/backend/specs/webaccess.js
+++ b/tests/backend/specs/webaccess.js
@@ -1,11 +1,9 @@
'use strict';
-function m(mod) { return `${__dirname}/../../../src/${mod}`; }
-
const assert = require('assert').strict;
const common = require('../common');
-const plugins = require(m('static/js/pluginfw/plugin_defs'));
-const settings = require(m('node/utils/Settings'));
+const plugins = require('ep_etherpad-lite/static/js/pluginfw/plugin_defs');
+const settings = require('ep_etherpad-lite/node/utils/Settings');
describe(__filename, function () {
this.timeout(30000);
@@ -13,6 +11,13 @@ describe(__filename, function () {
const backups = {};
const authHookNames = ['preAuthorize', 'authenticate', 'authorize'];
const failHookNames = ['preAuthzFailure', 'authnFailure', 'authzFailure', 'authFailure'];
+ const makeHook = (hookName, hookFn) => ({
+ hook_fn: hookFn,
+ hook_fn_name: `fake_plugin/${hookName}`,
+ hook_name: hookName,
+ part: {plugin: 'fake_plugin'},
+ });
+
before(async function () { agent = await common.init(); });
beforeEach(async function () {
backups.hooks = {};
@@ -154,7 +159,10 @@ describe(__filename, function () {
const h0 = new Handler(hookName, '_0');
const h1 = new Handler(hookName, '_1');
handlers[hookName] = [h0, h1];
- plugins.hooks[hookName] = [{hook_fn: h0.handle.bind(h0)}, {hook_fn: h1.handle.bind(h1)}];
+ plugins.hooks[hookName] = [
+ makeHook(hookName, h0.handle.bind(h0)),
+ makeHook(hookName, h1.handle.bind(h1)),
+ ];
}
});
@@ -217,7 +225,7 @@ describe(__filename, function () {
this.timeout(100);
handlers.preAuthorize[0].innerHandle = () => [false];
let called = false;
- plugins.hooks.preAuthzFailure = [{hook_fn: (hookName, {req, res}, cb) => {
+ plugins.hooks.preAuthzFailure = [makeHook('preAuthzFailure', (hookName, {req, res}, cb) => {
assert.equal(hookName, 'preAuthzFailure');
assert(req != null);
assert(res != null);
@@ -225,7 +233,7 @@ describe(__filename, function () {
called = true;
res.status(200).send('injected');
return cb([true]);
- }}];
+ })];
await agent.get('/admin/').auth('admin', 'admin-password').expect(200, 'injected');
assert(called);
});
@@ -441,11 +449,11 @@ describe(__filename, function () {
};
const handlers = {};
- beforeEach(function () {
+ beforeEach(async function () {
failHookNames.forEach((hookName) => {
const handler = new Handler(hookName);
handlers[hookName] = handler;
- plugins.hooks[hookName] = [{hook_fn: handler.handle.bind(handler)}];
+ plugins.hooks[hookName] = [makeHook(hookName, handler.handle.bind(handler))];
});
settings.requireAuthentication = true;
settings.requireAuthorization = true;
diff --git a/tests/frontend/helper.js b/tests/frontend/helper.js
index 37c5af3b1..c38175fe1 100644
--- a/tests/frontend/helper.js
+++ b/tests/frontend/helper.js
@@ -1,5 +1,5 @@
'use strict';
-const helper = {}; // eslint-disable-line
+const helper = {}; // eslint-disable-line no-redeclare
(function () {
let $iframe; const
@@ -181,7 +181,7 @@ const helper = {}; // eslint-disable-line
};
helper.waitFor = function (conditionFunc, timeoutTime = 1900, intervalTime = 10) {
- const deferred = $.Deferred(); // eslint-disable-line
+ const deferred = new $.Deferred();
const _fail = deferred.fail.bind(deferred);
let listenForFail = false;
diff --git a/tests/frontend/helper/methods.js b/tests/frontend/helper/methods.js
index 4c7fe1204..157ba6aba 100644
--- a/tests/frontend/helper/methods.js
+++ b/tests/frontend/helper/methods.js
@@ -6,12 +6,12 @@
*/
helper.spyOnSocketIO = function () {
helper.contentWindow().pad.socket.on('message', (msg) => {
- if (msg.type == 'COLLABROOM') {
- if (msg.data.type == 'ACCEPT_COMMIT') {
+ if (msg.type === 'COLLABROOM') {
+ if (msg.data.type === 'ACCEPT_COMMIT') {
helper.commits.push(msg);
- } else if (msg.data.type == 'USER_NEWINFO') {
+ } else if (msg.data.type === 'USER_NEWINFO') {
helper.userInfos.push(msg);
- } else if (msg.data.type == 'CHAT_MESSAGE') {
+ } else if (msg.data.type === 'CHAT_MESSAGE') {
helper.chatMessages.push(msg);
}
}
diff --git a/tests/frontend/helper/ui.js b/tests/frontend/helper/ui.js
index 0f3e64169..7ab8b990d 100644
--- a/tests/frontend/helper/ui.js
+++ b/tests/frontend/helper/ui.js
@@ -1,3 +1,5 @@
+'use strict';
+
/**
* the contentWindow is either the normal pad or timeslider
*
diff --git a/tests/frontend/runner.js b/tests/frontend/runner.js
index 55ef2acf3..efc138883 100644
--- a/tests/frontend/runner.js
+++ b/tests/frontend/runner.js
@@ -170,7 +170,7 @@ $(() => {
}
});
- // initalize the test helper
+ // initialize the test helper
helper.init(() => {
// configure and start the test framework
const grep = getURLParameter('grep');
diff --git a/tests/frontend/specs/authorship_of_editions.js b/tests/frontend/specs/authorship_of_editions.js
index 539220417..c82ddd0fc 100644
--- a/tests/frontend/specs/authorship_of_editions.js
+++ b/tests/frontend/specs/authorship_of_editions.js
@@ -7,10 +7,11 @@ describe('author of pad edition', function () {
// author 1 creates a new pad with some content (regular lines and lists)
before(function (done) {
- var padId = helper.newPad(() => {
+ const padId = helper.newPad(() => {
// make sure pad has at least 3 lines
const $firstLine = helper.padInner$('div').first();
- const threeLines = ['regular line', 'line with ordered list', 'line with unordered list'].join('
');
+ const threeLines = ['regular line', 'line with ordered list', 'line with unordered list']
+ .join('
');
$firstLine.html(threeLines);
// wait for lines to be processed by Etherpad
@@ -45,7 +46,8 @@ describe('author of pad edition', function () {
setTimeout(() => {
// Expire cookie, so author is changed after reloading the pad.
// See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie
- helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
+ helper.padChrome$.document.cookie =
+ 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
helper.newPad(done, padId);
}, 10000);
@@ -62,26 +64,25 @@ describe('author of pad edition', function () {
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(REGULAR_LINE, 'x', done);
});
- it('marks only the new content as changes of the second user on a line with ordered list', function (done) {
+
+ it('marks only the new content as changes of the second user on a ' +
+ 'line with ordered list', function (done) {
this.timeout(1000);
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(LINE_WITH_ORDERED_LIST, 'y', done);
});
- it('marks only the new content as changes of the second user on a line with unordered list', function (done) {
+ it('marks only the new content as changes of the second user on ' +
+ 'a line with unordered list', function (done) {
this.timeout(1000);
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(LINE_WITH_UNORDERED_LIST, 'z', done);
});
/* ********************** Helper functions ************************ */
- var getLine = function (lineNumber) {
- return helper.padInner$('div').eq(lineNumber);
- };
+ const getLine = (lineNumber) => helper.padInner$('div').eq(lineNumber);
- const getAuthorFromClassList = function (classes) {
- return classes.find((cls) => cls.startsWith('author'));
- };
+ const getAuthorFromClassList = (classes) => classes.find((cls) => cls.startsWith('author'));
- var changeLineAndCheckOnlyThatChangeIsFromThisAuthor = function (lineNumber, textChange, done) {
+ const changeLineAndCheckOnlyThatChangeIsFromThisAuthor = (lineNumber, textChange, done) => {
// get original author class
const classes = getLine(lineNumber).find('span').first().attr('class').split(' ');
const originalAuthor = getAuthorFromClassList(classes);
diff --git a/tests/frontend/specs/bold.js b/tests/frontend/specs/bold.js
index 8eee1186e..ac0d09a0f 100644
--- a/tests/frontend/specs/bold.js
+++ b/tests/frontend/specs/bold.js
@@ -22,8 +22,6 @@ describe('bold button', function () {
const $boldButton = chrome$('.buttonicon-bold');
$boldButton.click();
- // ace creates a new dom element when you press a button
- // so just get the first text element again
const $newFirstTextElement = inner$('div').first();
// is there a element now?
@@ -48,13 +46,11 @@ describe('bold button', function () {
// select this text element
$firstTextElement.sendkeys('{selectall}');
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.ctrlKey = true; // Control key
e.which = 66; // b
inner$('#innerdocbody').trigger(e);
- // ace creates a new dom element when you press a button
- // so just get the first text element again
const $newFirstTextElement = inner$('div').first();
// is there a element now?
diff --git a/tests/frontend/specs/caret.js b/tests/frontend/specs/caret.js
index 1fb8d8aa7..e5ce255b8 100644
--- a/tests/frontend/specs/caret.js
+++ b/tests/frontend/specs/caret.js
@@ -1,7 +1,9 @@
+'use strict';
+
describe('As the caret is moved is the UI properly updated?', function () {
+ /*
let padName;
const numberOfRows = 50;
- /*
//create a new pad before each test run
beforeEach(function(cb){
@@ -16,7 +18,8 @@ describe('As the caret is moved is the UI properly updated?', function () {
*/
/* Tests to do
- * Keystroke up (38), down (40), left (37), right (39) with and without special keys IE control / shift
+ * Keystroke up (38), down (40), left (37), right (39)
+ * with and without special keys IE control / shift
* Page up (33) / down (34) with and without special keys
* Page up on the first line shouldn't move the viewport
* Down down on the last line shouldn't move the viewport
@@ -25,7 +28,9 @@ describe('As the caret is moved is the UI properly updated?', function () {
*/
/* Challenges
- * How do we keep the authors focus on a line if the lines above the author are modified? We should only redraw the user to a location if they are typing and make sure shift and arrow keys aren't redrawing the UI else highlight - copy/paste would get broken
+ * How do we keep the authors focus on a line if the lines above the author are modified?
+ * We should only redraw the user to a location if they are typing and make sure shift
+ * and arrow keys aren't redrawing the UI else highlight - copy/paste would get broken
* How can we simulate an edit event in the test framework?
*/
/*
@@ -200,7 +205,8 @@ console.log(inner$);
var chrome$ = helper.padChrome$;
var numberOfRows = 50;
- //ace creates a new dom element when you press a keystroke, so just get the first text element again
+ // ace creates a new dom element when you press a keystroke,
+ // so just get the first text element again
var $newFirstTextElement = inner$("div").first();
var originalDivHeight = inner$("div").first().css("height");
prepareDocument(numberOfRows, $newFirstTextElement); // N lines into the first div as a target
@@ -208,28 +214,33 @@ console.log(inner$);
helper.waitFor(function(){ // Wait for the DOM to register the new items
return inner$("div").first().text().length == 6;
}).done(function(){ // Once the DOM has registered the items
- inner$("div").each(function(index){ // Randomize the item heights (replicates images / headings etc)
+ // Randomize the item heights (replicates images / headings etc)
+ inner$("div").each(function(index){
var random = Math.floor(Math.random() * (50)) + 20;
$(this).css("height", random+"px");
});
console.log(caretPosition(inner$));
var newDivHeight = inner$("div").first().css("height");
- var heightHasChanged = originalDivHeight != newDivHeight; // has the new div height changed from the original div height
+ // has the new div height changed from the original div height
+ var heightHasChanged = originalDivHeight != newDivHeight;
expect(heightHasChanged).to.be(true); // expect the first line to be blank
});
// Is this Element now visible to the pad user?
helper.waitFor(function(){ // Wait for the DOM to register the new items
- return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$); // Wait for the DOM to scroll into place
+ // Wait for the DOM to scroll into place
+ return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$);
}).done(function(){ // Once the DOM has registered the items
- inner$("div").each(function(index){ // Randomize the item heights (replicates images / headings etc)
+ // Randomize the item heights (replicates images / headings etc)
+ inner$("div").each(function(index){
var random = Math.floor(Math.random() * (80 - 20 + 1)) + 20;
$(this).css("height", random+"px");
});
var newDivHeight = inner$("div").first().css("height");
- var heightHasChanged = originalDivHeight != newDivHeight; // has the new div height changed from the original div height
+ // has the new div height changed from the original div height
+ var heightHasChanged = originalDivHeight != newDivHeight;
expect(heightHasChanged).to.be(true); // expect the first line to be blank
});
var i = 0;
@@ -241,7 +252,8 @@ console.log(inner$);
// Does scrolling back up the pad with the up arrow show the correct contents?
helper.waitFor(function(){ // Wait for the new position to be in place
try{
- return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$); // Wait for the DOM to scroll into place
+ // Wait for the DOM to scroll into place
+ return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$);
}catch(e){
return false;
}
@@ -256,7 +268,8 @@ console.log(inner$);
// Does scrolling back up the pad with the up arrow show the correct contents?
helper.waitFor(function(){ // Wait for the new position to be in place
try{
- return isScrolledIntoView(inner$("div:nth-child(0)"), inner$); // Wait for the DOM to scroll into place
+ // Wait for the DOM to scroll into place
+ return isScrolledIntoView(inner$("div:nth-child(0)"), inner$);
}catch(e){
return false;
}
@@ -276,7 +289,8 @@ console.log(inner$);
// Does scrolling back up the pad with the up arrow show the correct contents?
helper.waitFor(function(){ // Wait for the new position to be in place
- return isScrolledIntoView(inner$("div:nth-child(1)"), inner$); // Wait for the DOM to scroll into place
+ // Wait for the DOM to scroll into place
+ return isScrolledIntoView(inner$("div:nth-child(1)"), inner$);
}).done(function(){ // Once the DOM has registered the items
expect(true).to.be(true);
done();
@@ -284,17 +298,19 @@ console.log(inner$);
*/
});
-function prepareDocument(n, target) { // generates a random document with random content on n lines
+// generates a random document with random content on n lines
+const prepareDocument = (n, target) => {
let i = 0;
while (i < n) { // for each line
target.sendkeys(makeStr()); // generate a random string and send that to the editor
target.sendkeys('{enter}'); // generator an enter keypress
i++; // rinse n times
}
-}
+};
-function keyEvent(target, charCode, ctrl, shift) { // sends a charCode to the window
- const e = target.Event(helper.evtType);
+// sends a charCode to the window
+const keyEvent = (target, charCode, ctrl, shift) => {
+ const e = new target.Event(helper.evtType);
if (ctrl) {
e.ctrlKey = true; // Control key
}
@@ -304,30 +320,33 @@ function keyEvent(target, charCode, ctrl, shift) { // sends a charCode to the wi
e.which = charCode;
e.keyCode = charCode;
target('#innerdocbody').trigger(e);
-}
+};
-function makeStr() { // from http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
+// from http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
+const makeStr = () => {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 5; i++) text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
-}
+};
-function isScrolledIntoView(elem, $) { // from http://stackoverflow.com/questions/487073/check-if-element-is-visible-after-scrolling
+// from http://stackoverflow.com/questions/487073/check-if-element-is-visible-after-scrolling
+const isScrolledIntoView = (elem, $) => {
const docViewTop = $(window).scrollTop();
const docViewBottom = docViewTop + $(window).height();
const elemTop = $(elem).offset().top; // how far the element is from the top of it's container
- let elemBottom = elemTop + $(elem).height(); // how far plus the height of the elem.. IE is it all in?
+ // how far plus the height of the elem.. IE is it all in?
+ let elemBottom = elemTop + $(elem).height();
elemBottom -= 16; // don't ask, sorry but this is needed..
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
-}
+};
-function caretPosition($) {
+const caretPosition = ($) => {
const doc = $.window.document;
const pos = doc.getSelection();
pos.y = pos.anchorNode.parentElement.offsetTop;
pos.x = pos.anchorNode.parentElement.offsetLeft;
return pos;
-}
+};
diff --git a/tests/frontend/specs/change_user_color.js b/tests/frontend/specs/change_user_color.js
index ca5935c58..1f41dcce2 100644
--- a/tests/frontend/specs/change_user_color.js
+++ b/tests/frontend/specs/change_user_color.js
@@ -7,7 +7,8 @@ describe('change user color', function () {
this.timeout(60000);
});
- it('Color picker remembers the user color after a refresh', function (done) {
+ it('Color picker matches original color and remembers the user color' +
+ ' after a refresh', function (done) {
this.timeout(10000);
const chrome$ = helper.padChrome$;
@@ -95,7 +96,6 @@ describe('change user color', function () {
// simulate a keypress of enter actually does evt.which = 10 not 13
$chatInput.sendkeys('{enter}');
- // check if chat shows up
// wait until the chat message shows up
helper.waitFor(() => chrome$('#chattext').children('p').length !== 0
).done(() => {
diff --git a/tests/frontend/specs/chat.js b/tests/frontend/specs/chat.js
index 6f5e9b5a4..0026f0eb4 100644
--- a/tests/frontend/specs/chat.js
+++ b/tests/frontend/specs/chat.js
@@ -6,8 +6,10 @@ describe('Chat messages and UI', function () {
helper.newPad(cb);
});
- it('opens chat, sends a message, makes sure it exists and hides chat', async function () {
+ it('opens chat, sends a message, makes sure it exists ' +
+ 'on the page and hides chat', async function () {
this.timeout(3000);
+
const chatValue = 'JohnMcLear';
await helper.showChat();
@@ -49,7 +51,8 @@ describe('Chat messages and UI', function () {
expect(chat.text()).to.be(`${username}${time} ${chatValue}`);
});
- it('makes chat stick to right side of the screen via settings, remove sticky via settings, close it', async function () {
+ it('makes chat stick to right side of the screen via settings, ' +
+ 'remove sticky via settings, close it', async function () {
this.timeout(5000);
await helper.showSettings();
@@ -66,8 +69,10 @@ describe('Chat messages and UI', function () {
expect(helper.isChatboxShown()).to.be(false);
});
- it('makes chat stick to right side of the screen via icon on the top right, remove sticky via icon, close it', async function () {
+ it('makes chat stick to right side of the screen via icon on the top' +
+ ' right, remove sticky via icon, close it', async function () {
this.timeout(5000);
+
await helper.showChat();
await helper.enableStickyChatviaIcon();
@@ -83,7 +88,8 @@ describe('Chat messages and UI', function () {
expect(helper.isChatboxShown()).to.be(false);
});
- xit('Checks showChat=false URL Parameter shows/hides chat', function (done) {
+ xit('Checks showChat=false URL Parameter hides chat then' +
+ ' when removed it shows chat', function (done) {
this.timeout(60000);
setTimeout(() => { // give it a second to save the username on the server side
diff --git a/tests/frontend/specs/clear_authorship_colors.js b/tests/frontend/specs/clear_authorship_colors.js
index c0e116dc3..cac3daa9b 100644
--- a/tests/frontend/specs/clear_authorship_colors.js
+++ b/tests/frontend/specs/clear_authorship_colors.js
@@ -92,7 +92,7 @@ describe('clear authorship colors button', function () {
let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
expect(hasAuthorClass).to.be(false);
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.ctrlKey = true; // Control key
e.which = 90; // z
inner$('#innerdocbody').trigger(e); // shouldn't od anything
diff --git a/tests/frontend/specs/delete.js b/tests/frontend/specs/delete.js
index d2b9611c0..d3fc90de5 100644
--- a/tests/frontend/specs/delete.js
+++ b/tests/frontend/specs/delete.js
@@ -22,8 +22,6 @@ describe('delete keystroke', function () {
$firstTextElement.sendkeys('{leftarrow}'); // simulate a keypress of the left arrow key
$firstTextElement.sendkeys('{del}'); // simulate a keypress of delete
- // ace creates a new dom element when you press a keystroke
- // so just get the first text element again
const $newFirstTextElement = inner$('div').first();
// get the new length of this element
diff --git a/tests/frontend/specs/drag_and_drop.js b/tests/frontend/specs/drag_and_drop.js
index 9fdbc5486..dff8e3193 100644
--- a/tests/frontend/specs/drag_and_drop.js
+++ b/tests/frontend/specs/drag_and_drop.js
@@ -86,16 +86,16 @@ describe('drag and drop', function () {
const TARGET_LINE = 2;
const FIRST_SOURCE_LINE = 5;
- const getLine = function (lineNumber) {
+ const getLine = (lineNumber) => {
const $lines = helper.padInner$('div');
return $lines.slice(lineNumber, lineNumber + 1);
};
- const createScriptWithSeveralLines = function (done) {
+ const createScriptWithSeveralLines = (done) => {
// create some lines to be used on the tests
const $firstLine = helper.padInner$('div').first();
- $firstLine.html(
- '...
...
Target line []
...
...
Source line 1.
Source line 2.
');
+ $firstLine.html('...
...
Target line []
...
...
' +
+ 'Source line 1.
Source line 2.
');
// wait for lines to be split
helper.waitFor(() => {
@@ -104,7 +104,7 @@ describe('drag and drop', function () {
}).done(done);
};
- const selectPartOfSourceLine = function () {
+ const selectPartOfSourceLine = () => {
const $sourceLine = getLine(FIRST_SOURCE_LINE);
// select 'line 1' from 'Source line 1.'
@@ -112,14 +112,14 @@ describe('drag and drop', function () {
const end = start + 'line 1'.length;
helper.selectLines($sourceLine, $sourceLine, start, end);
};
- const selectMultipleSourceLines = function () {
+ const selectMultipleSourceLines = () => {
const $firstSourceLine = getLine(FIRST_SOURCE_LINE);
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
helper.selectLines($firstSourceLine, $lastSourceLine);
};
- const dragSelectedTextAndDropItIntoMiddleOfLine = function (targetLineNumber) {
+ const dragSelectedTextAndDropItIntoMiddleOfLine = (targetLineNumber) => {
// dragstart: start dragging content
triggerEvent('dragstart');
@@ -132,7 +132,7 @@ describe('drag and drop', function () {
triggerEvent('dragend');
};
- const getHtmlFromSelectedText = function () {
+ const getHtmlFromSelectedText = () => {
const innerDocument = helper.padInner$.document;
const range = innerDocument.getSelection().getRangeAt(0);
@@ -145,12 +145,12 @@ describe('drag and drop', function () {
return draggedHtml;
};
- const triggerEvent = function (eventName) {
- const event = helper.padInner$.Event(eventName);
+ const triggerEvent = (eventName) => {
+ const event = new helper.padInner$.Event(eventName);
helper.padInner$('#innerdocbody').trigger(event);
};
- const moveSelectionIntoTarget = function (draggedHtml, targetLineNumber) {
+ const moveSelectionIntoTarget = (draggedHtml, targetLineNumber) => {
const innerDocument = helper.padInner$.document;
// delete original content
diff --git a/tests/frontend/specs/helper.js b/tests/frontend/specs/helper.js
index 60f8dd331..cb72fcf7a 100644
--- a/tests/frontend/specs/helper.js
+++ b/tests/frontend/specs/helper.js
@@ -7,7 +7,7 @@ describe('the test helper', function () {
let times = 10;
- const loadPad = function () {
+ const loadPad = () => {
helper.newPad(() => {
times--;
if (times > 0) {
@@ -77,13 +77,14 @@ describe('the test helper', function () {
// Before refreshing, make sure the name is there
expect($usernameInput.val()).to.be('John McLear');
- // Now that we have a chrome, we can set a pad cookie, so we can confirm it gets wiped as well
+ // Now that we have a chrome, we can set a pad cookie
+ // so we can confirm it gets wiped as well
chrome$.document.cookie = 'prefsHtml=baz;expires=Thu, 01 Jan 3030 00:00:00 GMT';
expect(chrome$.document.cookie).to.contain('prefsHtml=baz');
- // Cookies are weird. Because it's attached to chrome$ (as helper.setPadCookies does), AND we
- // didn't put path=/, we shouldn't expect it to be visible on window.document.cookie. Let's just
- // be sure.
+ // Cookies are weird. Because it's attached to chrome$ (as helper.setPadCookies does)
+ // AND we didn't put path=/, we shouldn't expect it to be visible on
+ // window.document.cookie. Let's just be sure.
expect(window.document.cookie).to.not.contain('prefsHtml=baz');
setTimeout(() => { // give it a second to save the username on the server side
@@ -268,7 +269,8 @@ describe('the test helper', function () {
this.timeout(60000);
});
- it('changes editor selection to be between startOffset of $startLine and endOffset of $endLine', function (done) {
+ it('changes editor selection to be between startOffset of $startLine ' +
+ 'and endOffset of $endLine', function (done) {
const inner$ = helper.padInner$;
const startOffset = 2;
@@ -315,7 +317,8 @@ describe('the test helper', function () {
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
- expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
+ expect(cleanText(
+ selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
done();
});
@@ -367,12 +370,14 @@ describe('the test helper', function () {
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
- expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
+ expect(cleanText(
+ selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
done();
});
- it('selects all text between beginning of $startLine and end of $endLine when no offset is provided', function (done) {
+ it('selects all text between beginning of $startLine and end of $endLine ' +
+ 'when no offset is provided', function (done) {
const inner$ = helper.padInner$;
const $lines = inner$('div');
@@ -390,7 +395,8 @@ describe('the test helper', function () {
* is not consistent between browsers but that's the situation so that's
* how I'm covering it in this test.
*/
- expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('short lines to test');
+ expect(cleanText(
+ selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('short lines to test');
done();
});
diff --git a/tests/frontend/specs/importexport.js b/tests/frontend/specs/importexport.js
index 0be2a0744..4eb95eeb0 100644
--- a/tests/frontend/specs/importexport.js
+++ b/tests/frontend/specs/importexport.js
@@ -1,3 +1,5 @@
+'use strict';
+
describe('import functionality', function () {
beforeEach(function (cb) {
helper.newPad(cb); // creates a new pad
@@ -16,7 +18,6 @@ describe('import functionality', function () {
return newtext;
}
function importrequest(data, importurl, type) {
- let success;
let error;
const result = $.ajax({
url: importurl,
@@ -27,7 +28,17 @@ describe('import functionality', function () {
accepts: {
text: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
},
- data: `Content-Type: multipart/form-data; boundary=--boundary\r\n\r\n--boundary\r\nContent-Disposition: form-data; name="file"; filename="import.${type}"\r\nContent-Type: text/plain\r\n\r\n${data}\r\n\r\n--boundary`,
+ data: [
+ 'Content-Type: multipart/form-data; boundary=--boundary',
+ '',
+ '--boundary',
+ `Content-Disposition: form-data; name="file"; filename="import.${type}"`,
+ 'Content-Type: text/plain',
+ '',
+ data,
+ '',
+ '--boundary',
+ ].join('\r\n'),
error(res) {
error = res;
},
@@ -56,7 +67,8 @@ describe('import functionality', function () {
const importurl = `${helper.padChrome$.window.location.href}/import`;
const textWithNewLines = 'imported text\nnewline';
importrequest(textWithNewLines, importurl, 'txt');
- helper.waitFor(() => expect(getinnertext()).to.be('imported text\nnewline\n
\n'));
+ helper.waitFor(() => expect(getinnertext())
+ .to.be('imported text\nnewline\n
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
expect(results[0][1]).to.be('imported text
newline
');
expect(results[1][1]).to.be('imported text\nnewline\n\n');
@@ -66,7 +78,8 @@ describe('import functionality', function () {
const importurl = `${helper.padChrome$.window.location.href}/import`;
const htmlWithNewLines = 'htmltext
newline';
importrequest(htmlWithNewLines, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('htmltext\nnewline\n
\n'));
+ helper.waitFor(() => expect(getinnertext())
+ .to.be('htmltext\nnewline\n
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
expect(results[0][1]).to.be('htmltext
newline
');
expect(results[1][1]).to.be('htmltext\nnewline\n\n');
@@ -74,69 +87,109 @@ describe('import functionality', function () {
});
xit('import a pad with attributes from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithNewLines = 'htmltext
newline';
+ const htmlWithNewLines = 'htmltext
' +
+ 'newline';
importrequest(htmlWithNewLines, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('htmltext\nnewline\n
\n'));
+ helper.waitFor(() => expect(getinnertext())
+ .to.be('htmltext\n' +
+ 'newline\n
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
- expect(results[0][1]).to.be('htmltext
newline
');
+ expect(results[0][1])
+ .to.be('htmltext
newline
');
expect(results[1][1]).to.be('htmltext\nnewline\n\n');
done();
});
xit('import a pad with bullets from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = '- bullet line 1
- bullet line 2
- bullet2 line 1
- bullet2 line 2
';
+ const htmlWithBullets = '- bullet line 1
' +
+ '- bullet line 2
- bullet2 line 1
' +
+ '- bullet2 line 2
';
importrequest(htmlWithBullets, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('\
-- bullet line 1
\n\
-- bullet line 2
\n\
-- bullet2 line 1
\n\
-- bullet2 line 2
\n\
-
\n'));
+ helper.waitFor(() => expect(getinnertext()).to.be(
+ '- bullet line 1
\n' +
+ '- bullet line 2
\n' +
+ '- bullet2 line 1
\n' +
+ '- bullet2 line 2
\n' +
+ '
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
- expect(results[0][1]).to.be('- bullet line 1
- bullet line 2
- bullet2 line 1
- bullet2 line 2
');
- expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t* bullet2 line 2\n\n');
+ expect(results[0][1]).to.be(
+ '- bullet line 1
- bullet line 2
' +
+ '- bullet2 line 1
- bullet2 line 2
');
+ expect(results[1][1])
+ .to.be('\t* bullet line 1\n\t* bullet line 2\n' +
+ '\t\t* bullet2 line 1\n\t\t* bullet2 line 2\n\n');
done();
});
xit('import a pad with bullets and newlines from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = '- bullet line 1
- bullet line 2
- bullet2 line 1
- bullet2 line 2
';
+ const htmlWithBullets = '- bullet line 1
' +
+ '
- bullet line 2
' +
+ '- bullet2 line 1
' +
+ '- bullet2 line 2
';
importrequest(htmlWithBullets, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('\
-- bullet line 1
\n\
-
\n\
-- bullet line 2
\n\
-- bullet2 line 1
\n\
-
\n\
-- bullet2 line 2
\n\
-
\n'));
+ helper.waitFor(() => expect(getinnertext()).to.be(
+ '- bullet line 1
\n' +
+ '
\n' +
+ '- bullet line 2
\n' +
+ '- bullet2 line 1
\n' +
+ '
\n' +
+ '- bullet2 line 2
\n' +
+ '
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
- expect(results[0][1]).to.be('- bullet line 1
- bullet line 2
- bullet2 line 1
- bullet2 line 2
');
- expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t* bullet2 line 2\n\n');
+ expect(results[0][1]).to.be(
+ '- bullet line 1
' +
+ '- bullet line 2
- bullet2 line 1
' +
+ '
- bullet2 line 2
');
+ expect(results[1][1]).to.be(
+ '\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t* bullet2 line 2\n\n');
done();
});
xit('import a pad with bullets and newlines and attributes from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = '- bullet line 1
- bullet line 2
- bullet2 line 1
bullet4 line 2 bisubullet4 line 2 bs- bullet4 line 2 u
uis
';
+ const htmlWithBullets = '- bullet line 1
' +
+ '
- bullet line 2
' +
+ '- bullet2 line 1
' +
+ '
' +
+ '- ' +
+ '
bullet4 line 2 bisu - ' +
+ '
bullet4 line 2 bs ' +
+ '- bullet4 line 2 u' +
+ '
uis
';
importrequest(htmlWithBullets, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('\
-- bullet line 1
\n\
\n\
-- bullet line 2
\n\
-- bullet2 line 1
\n
\n\
-bullet4 line 2 bisu
\n\
-bullet4 line 2 bs
\n\
-- bullet4 line 2 u
uis
\n\
-
\n'));
+ helper.waitFor(() => expect(getinnertext()).to.be(
+ '- bullet line 1
\n
\n' +
+ '- bullet line 2
\n' +
+ '- bullet2 line 1
\n
\n' +
+ '- ' +
+ '
bullet4 line 2 bisu
\n' +
+ '- ' +
+ '
bullet4 line 2 bs
\n' +
+ '- bullet4 line 2 u' +
+ '
uis
\n' +
+ '
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
- expect(results[0][1]).to.be('- bullet line 1
- bullet line 2
- bullet2 line 1
bullet4 line 2 bisubullet4 line 2 bs- bullet4 line 2 u
uis
');
- expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\n');
+ expect(results[0][1]).to.be(
+ '- bullet line 1
' +
+ '
- bullet line 2
- bullet2 line 1
' +
+ '
bullet4 line 2 bisu' +
+ 'bullet4 line 2 bs' +
+ '- bullet4 line 2 u
uis
');
+ expect(results[1][1]).to.be(
+ '\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2' +
+ ' bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\n');
done();
});
xit('import a pad with nested bullets from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = '- bullet line 1
- bullet line 2
- bullet2 line 1
- bullet4 line 2
- bullet4 line 2
- bullet4 line 2
- bullet3 line 1
- bullet2 line 1
';
+ const htmlWithBullets = '- bullet line 1
' +
+ '
- bullet line 2
' +
+ '- bullet2 line 1
' +
+ '- bullet4 line 2
' +
+ '- bullet4 line 2
- bullet4 line 2
- bullet3 line 1
' +
+ '
- bullet2 line 1
';
importrequest(htmlWithBullets, importurl, 'html');
const oldtext = getinnertext();
- helper.waitFor(() => oldtext != getinnertext()
+ helper.waitFor(() => oldtext !== getinnertext()
// return expect(getinnertext()).to.be('\
// - bullet line 1
\n\
// - bullet line 2
\n\
@@ -148,73 +201,127 @@ describe('import functionality', function () {
);
const results = exportfunc(helper.padChrome$.window.location.href);
- expect(results[0][1]).to.be('- bullet line 1
- bullet line 2
- bullet2 line 1
- bullet4 line 2
- bullet4 line 2
- bullet4 line 2
- bullet3 line 1
- bullet2 line 1
');
- expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t* bullet3 line 1\n\t* bullet2 line 1\n\n');
+ expect(results[0][1]).to.be(
+ '- bullet line 1
- bullet line 2
' +
+ '- bullet2 line 1
- bullet4 line 2
' +
+ '- bullet4 line 2
- bullet4 line 2
- bullet3 line 1
' +
+ '- bullet2 line 1
');
+ expect(results[1][1]).to.be(
+ '\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t\t\t* bullet4 line 2' +
+ '\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t* bullet3 line 1' +
+ '\n\t* bullet2 line 1\n\n');
done();
});
- xit('import a pad with 8 levels of bullets and newlines and attributes from html', function (done) {
+ xit('import with 8 levels of bullets and newlines and attributes from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = '- bullet line 1
- bullet line 2
- bullet2 line 1
bullet4 line 2 bisubullet4 line 2 bs- bullet4 line 2 u
uis - foo
foobar bs
- foobar
';
+ const htmlWithBullets =
+ '- bullet line 1
' +
+ '
- bullet line 2
- ' +
+ 'bullet2 line 1
' +
+ '- ' +
+ '
bullet4 line 2 bisu ' +
+ 'bullet4 line 2 bs- bullet4 line 2 u' +
+ '
uis ' +
+ '' +
+ '- foo
- ' +
+ '
foobar bs
' +
+ '- foobar
';
importrequest(htmlWithBullets, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('\
-- bullet line 1
\n\
\n\
-- bullet line 2
\n\
-- bullet2 line 1
\n
\n\
-bullet4 line 2 bisu
\n\
-bullet4 line 2 bs
\n\
-- bullet4 line 2 u
uis
\n\
-- foo
\n\
-foobar bs
\n\
-- foobar
\n\
-
\n'));
+ helper.waitFor(() => expect(getinnertext()).to.be(
+ '- bullet line 1
\n
\n' +
+ '- bullet line 2
\n' +
+ '- bullet2 line 1
\n
\n' +
+ 'bullet4 line 2 bisu' +
+ '
\n' +
+ 'bullet4 line 2 bs' +
+ '
\n' +
+ '- bullet4 line 2 u' +
+ '
uis' +
+ '
\n' +
+ '- foo
\n' +
+ 'foobar bs' +
+ '
\n' +
+ '- foobar
\n' +
+ '
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
- expect(results[0][1]).to.be('- bullet line 1
- bullet line 2
- bullet2 line 1
bullet4 line 2 bisubullet4 line 2 bs- bullet4 line 2 u
uis - foo
foobar bs
- foobar
');
- expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\t\t\t\t\t\t\t\t* foo\n\t\t\t\t\t\t\t\t* foobar bs\n\t\t\t\t\t* foobar\n\n');
+ expect(results[0][1]).to.be(
+ '- bullet line 1
' +
+ '- bullet line 2
- bullet2 line 1
' +
+ '
' +
+ 'bullet4 line 2 bisu' +
+ 'bullet4 line 2 bs- bullet4 line 2 u' +
+ '
uis - foo
' +
+ 'foobar bs
- foobar
' +
+ '
');
+ expect(results[1][1]).to.be(
+ '\t* bullet line 1\n\n\t* bullet line 2\n\t\t* ' +
+ 'bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 ' +
+ 'bs\n\t\t\t\t* bullet4 line 2 uuis\n\t\t\t\t\t\t\t\t* foo\n\t\t\t\t\t\t\t\t* ' +
+ 'foobar bs\n\t\t\t\t\t* foobar\n\n');
done();
});
xit('import a pad with ordered lists from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = '- number 1 line 1
- number 2 line 2
';
+ const htmlWithBullets = '' +
+ '- number 1 line 1
' +
+ '- number 2 line 2
';
importrequest(htmlWithBullets, importurl, 'html');
console.error(getinnertext());
- expect(getinnertext()).to.be('\
-- number 1 line 1
\n\
-- number 2 line 2
\n\
-
\n');
+ expect(getinnertext()).to.be(
+ '- number 1 line 1
\n' +
+ '- number 2 line 2
\n' +
+ '
\n');
const results = exportfunc(helper.padChrome$.window.location.href);
- expect(results[0][1]).to.be('- number 1 line 1
- number 2 line 2
');
+ expect(results[0][1]).to.be(
+ '- number 1 line 1
' +
+ '
- number 2 line 2
');
expect(results[1][1]).to.be('');
done();
});
xit('import a pad with ordered lists and newlines from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = '- number 9 line 1
- number 10 line 2
- number 2 times line 1
- number 2 times line 2
';
+ const htmlWithBullets = '' +
+ '- number 9 line 1
' +
+ '- number 10 line 2
' +
+ '- number 2 times line 1
' +
+ '- number 2 times line 2
';
importrequest(htmlWithBullets, importurl, 'html');
- expect(getinnertext()).to.be('\
-- number 9 line 1
\n\
-
\n\
-- number 10 line 2
\n\
-- number 2 times line 1
\n\
-
\n\
-- number 2 times line 2
\n\
-
\n');
+ expect(getinnertext()).to.be(
+ '- number 9 line 1
\n' +
+ '
\n' +
+ '- number 10 line 2
' +
+ '
\n' +
+ '- number 2 times line 1
\n' +
+ '
\n' +
+ '- number 2 times line 2
\n' +
+ '
\n');
const results = exportfunc(helper.padChrome$.window.location.href);
console.error(results);
done();
});
- xit('import a pad with nested ordered lists and attributes and newlines from html', function (done) {
+ xit('import with nested ordered lists and attributes and newlines from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
- const htmlWithBullets = 'bold strikethrough italics underline line 1bold
- number 10 line 2
- number 2 times line 1
- number 2 times line 2
';
+ const htmlWithBullets = '- ' +
+ '
bold strikethrough italics underline' +
+ ' line 1bold ' +
+ '
' +
+ '- number 10 line 2
' +
+ '- number 2 times line 1
' +
+ '' +
+ '- number 2 times line 2
';
importrequest(htmlWithBullets, importurl, 'html');
- expect(getinnertext()).to.be('\
-bold strikethrough italics underline line 1bold
\n\
-
\n\
-- number 10 line 2
\n\
-- number 2 times line 1
\n\
-
\n\
-- number 2 times line 2
\n\
-
\n');
+ expect(getinnertext()).to.be(
+ '' +
+ 'bold strikethrough italics underline' +
+ ' line 1bold
\n' +
+ '
\n' +
+ '- number 10 line 2
\n' +
+ '- ' +
+ 'number 2 times line 1
\n' +
+ '
\n' +
+ '- number 2 times line 2
\n' +
+ '
\n');
const results = exportfunc(helper.padChrome$.window.location.href);
console.error(results);
done();
diff --git a/tests/frontend/specs/importindents.js b/tests/frontend/specs/importindents.js
index 6209236df..eecbbce59 100644
--- a/tests/frontend/specs/importindents.js
+++ b/tests/frontend/specs/importindents.js
@@ -1,3 +1,5 @@
+'use strict';
+
describe('import indents functionality', function () {
beforeEach(function (cb) {
helper.newPad(cb); // creates a new pad
@@ -13,7 +15,6 @@ describe('import indents functionality', function () {
return newtext;
}
function importrequest(data, importurl, type) {
- let success;
let error;
const result = $.ajax({
url: importurl,
@@ -24,7 +25,17 @@ describe('import indents functionality', function () {
accepts: {
text: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
},
- data: `Content-Type: multipart/form-data; boundary=--boundary\r\n\r\n--boundary\r\nContent-Disposition: form-data; name="file"; filename="import.${type}"\r\nContent-Type: text/plain\r\n\r\n${data}\r\n\r\n--boundary`,
+ data: [
+ 'Content-Type: multipart/form-data; boundary=--boundary',
+ '',
+ '--boundary',
+ `Content-Disposition: form-data; name="file"; filename="import.${type}"`,
+ 'Content-Type: text/plain',
+ '',
+ data,
+ '',
+ '--boundary',
+ ].join('\r\n'),
error(res) {
error = res;
},
@@ -51,54 +62,67 @@ describe('import indents functionality', function () {
xit('import a pad with indents from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
+ /* eslint-disable-next-line max-len */
const htmlWithIndents = '- indent line 1
- indent line 2
- indent2 line 1
- indent2 line 2
';
importrequest(htmlWithIndents, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('\
-- indent line 1
\n\
-- indent line 2
\n\
-- indent2 line 1
\n\
-- indent2 line 2
\n\
-
\n'));
+ helper.waitFor(() => expect(getinnertext()).to.be(
+ '- indent line 1
\n' +
+ '- indent line 2
\n' +
+ '- indent2 line 1
\n' +
+ '- indent2 line 2
\n' +
+ '
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
+ /* eslint-disable-next-line max-len */
expect(results[0][1]).to.be('- indent line 1
- indent line 2
- indent2 line 1
- indent2 line 2
');
- expect(results[1][1]).to.be('\tindent line 1\n\tindent line 2\n\t\tindent2 line 1\n\t\tindent2 line 2\n\n');
+ expect(results[1][1])
+ .to.be('\tindent line 1\n\tindent line 2\n\t\tindent2 line 1\n\t\tindent2 line 2\n\n');
done();
});
xit('import a pad with indented lists and newlines from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
+ /* eslint-disable-next-line max-len */
const htmlWithIndents = '- indent line 1
- indent 1 line 2
- indent 2 times line 1
- indent 2 times line 2
';
importrequest(htmlWithIndents, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('\
-- indent line 1
\n\
-
\n\
-- indent 1 line 2
\n\
-- indent 2 times line 1
\n\
-
\n\
-- indent 2 times line 2
\n\
-
\n'));
+ helper.waitFor(() => expect(getinnertext()).to.be(
+ '- indent line 1
\n' +
+ '
\n' +
+ '- indent 1 line 2
\n' +
+ '- indent 2 times line 1
\n' +
+ '
\n' +
+ '- indent 2 times line 2
\n' +
+ '
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
+ /* eslint-disable-next-line max-len */
expect(results[0][1]).to.be('- indent line 1
- indent 1 line 2
- indent 2 times line 1
- indent 2 times line 2
');
+ /* eslint-disable-next-line max-len */
expect(results[1][1]).to.be('\tindent line 1\n\n\tindent 1 line 2\n\t\tindent 2 times line 1\n\n\t\tindent 2 times line 2\n\n');
done();
});
- xit('import a pad with 8 levels of indents and newlines and attributes from html', function (done) {
+ xit('import with 8 levels of indents and newlines and attributes from html', function (done) {
const importurl = `${helper.padChrome$.window.location.href}/import`;
+ /* eslint-disable-next-line max-len */
const htmlWithIndents = '- indent line 1
- indent line 2
- indent2 line 1
indent4 line 2 bisuindent4 line 2 bs- indent4 line 2 u
uis - foo
foobar bs
- foobar
';
importrequest(htmlWithIndents, importurl, 'html');
- helper.waitFor(() => expect(getinnertext()).to.be('\
-- indent line 1
\n\
\n\
-- indent line 2
\n\
-- indent2 line 1
\n
\n\
-indent4 line 2 bisu
\n\
-indent4 line 2 bs
\n\
-- indent4 line 2 u
uis
\n\
-- foo
\n\
-foobar bs
\n\
-- foobar
\n\
-
\n'));
+ helper.waitFor(() => expect(getinnertext()).to.be(
+ '- indent line 1
\n
\n' +
+ '- indent line 2
\n' +
+ '- indent2 line 1
\n
\n' +
+ 'indent4 ' +
+ 'line 2 bisu
\n' +
+ '' +
+ 'indent4 line 2 bs
\n' +
+ '- indent4 line 2 u' +
+ '
uis
\n' +
+ '- foo
\n' +
+ 'foobar bs' +
+ '
\n' +
+ '- foobar
\n' +
+ '
\n'));
const results = exportfunc(helper.padChrome$.window.location.href);
+ /* eslint-disable-next-line max-len */
expect(results[0][1]).to.be('- indent line 1
- indent line 2
- indent2 line 1
indent4 line 2 bisuindent4 line 2 bs- indent4 line 2 u
uis - foo
foobar bs
- foobar
');
+ /* eslint-disable-next-line max-len */
expect(results[1][1]).to.be('\tindent line 1\n\n\tindent line 2\n\t\tindent2 line 1\n\n\t\t\t\tindent4 line 2 bisu\n\t\t\t\tindent4 line 2 bs\n\t\t\t\tindent4 line 2 uuis\n\t\t\t\t\t\t\t\tfoo\n\t\t\t\t\t\t\t\tfoobar bs\n\t\t\t\t\tfoobar\n\n');
done();
});
diff --git a/tests/frontend/specs/indentation.js b/tests/frontend/specs/indentation.js
index b7c173660..377b1af74 100644
--- a/tests/frontend/specs/indentation.js
+++ b/tests/frontend/specs/indentation.js
@@ -17,7 +17,7 @@ describe('indentation button', function () {
// select this text element
$firstTextElement.sendkeys('{selectall}');
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.keyCode = 9; // tab :|
inner$('#innerdocbody').trigger(e);
@@ -60,7 +60,8 @@ describe('indentation button', function () {
});
});
- it("indents text with spaces on enter if previous line ends with ':', '[', '(', or '{'", function (done) {
+ it('indents text with spaces on enter if previous line ends ' +
+ "with ':', '[', '(', or '{'", function (done) {
this.timeout(1200);
const inner$ = helper.padInner$;
@@ -111,7 +112,8 @@ describe('indentation button', function () {
});
});
- it("appends indentation to the indent of previous line if previous line ends with ':', '[', '(', or '{'", function (done) {
+ it('appends indentation to the indent of previous line if previous line ends ' +
+ "with ':', '[', '(', or '{'", function (done) {
this.timeout(1200);
const inner$ = helper.padInner$;
@@ -136,7 +138,8 @@ describe('indentation button', function () {
});
});
- it("issue #2772 shows '*' when multiple indented lines receive a style and are outdented", async function () {
+ it("issue #2772 shows '*' when multiple indented lines " +
+ ' receive a style and are outdented', async function () {
this.timeout(1200);
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
@@ -189,7 +192,6 @@ describe('indentation button', function () {
var $indentButton = testHelper.$getPadChrome().find(".buttonicon-indent");
$indentButton.click();
- //ace creates a new dom element when you press a button, so just get the first text element again
var newFirstTextElement = $inner.find("div").first();
// is there a list-indent class element now?
@@ -227,7 +229,6 @@ describe('indentation button', function () {
$outdentButton.click();
$outdentButton.click();
- //ace creates a new dom element when you press a button, so just get the first text element again
var newFirstTextElement = $inner.find("div").first();
// is there a list-indent class element now?
@@ -274,7 +275,9 @@ describe('indentation button', function () {
//get the second text element out of the inner iframe
setTimeout(function(){ // THIS IS REALLY BAD
- var secondTextElement = $('iframe').contents().find('iframe').contents().find('iframe').contents().find('body > div').get(1); // THIS IS UGLY
+ var secondTextElement = $('iframe').contents()
+ .find('iframe').contents()
+ .find('iframe').contents().find('body > div').get(1); // THIS IS UGLY
// is there a list-indent class element now?
var firstChild = secondTextElement.children(":first");
@@ -289,7 +292,10 @@ describe('indentation button', function () {
expect(isLI).to.be(true);
//get the first text element out of the inner iframe
- var thirdTextElement = $('iframe').contents().find('iframe').contents().find('iframe').contents().find('body > div').get(2); // THIS IS UGLY TOO
+ var thirdTextElement = $('iframe').contents()
+ .find('iframe').contents()
+ .find('iframe').contents()
+ .find('body > div').get(2); // THIS IS UGLY TOO
// is there a list-indent class element now?
var firstChild = thirdTextElement.children(":first");
@@ -309,7 +315,7 @@ describe('indentation button', function () {
const pressEnter = () => {
const inner$ = helper.padInner$;
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.keyCode = 13; // enter :|
inner$('#innerdocbody').trigger(e);
};
diff --git a/tests/frontend/specs/italic.js b/tests/frontend/specs/italic.js
index b9edbda98..5ab6d652c 100644
--- a/tests/frontend/specs/italic.js
+++ b/tests/frontend/specs/italic.js
@@ -21,7 +21,7 @@ describe('italic some text', function () {
// get the bold button and click it
const $boldButton = chrome$('.buttonicon-italic');
$boldButton.click();
-
+
const $newFirstTextElement = inner$('div').first();
// is there a element now?
@@ -46,7 +46,7 @@ describe('italic some text', function () {
// select this text element
$firstTextElement.sendkeys('{selectall}');
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.ctrlKey = true; // Control key
e.which = 105; // i
inner$('#innerdocbody').trigger(e);
diff --git a/tests/frontend/specs/multiple_authors_clear_authorship_colors.js b/tests/frontend/specs/multiple_authors_clear_authorship_colors.js
index e658ff19f..a0e6b1aef 100755
--- a/tests/frontend/specs/multiple_authors_clear_authorship_colors.js
+++ b/tests/frontend/specs/multiple_authors_clear_authorship_colors.js
@@ -15,8 +15,8 @@ describe('author of pad edition', function () {
setTimeout(() => {
// Expire cookie, so author is changed after reloading the pad.
// See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie
- const cookieVal = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
- helper.padChrome$.document.cookie = cookieVal;
+ helper.padChrome$.document.cookie =
+ 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
helper.newPad(done, padId);
}, 1000);
@@ -25,7 +25,12 @@ describe('author of pad edition', function () {
this.timeout(60000);
});
- const clearAuthorship = function (done) {
+ // author 2 makes some changes on the pad
+ it('Clears Authorship by second user', function (done) {
+ clearAuthorship(done);
+ });
+
+ const clearAuthorship = (done) => {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
diff --git a/tests/frontend/specs/ordered_list.js b/tests/frontend/specs/ordered_list.js
index 7604e0287..7847f75ee 100644
--- a/tests/frontend/specs/ordered_list.js
+++ b/tests/frontend/specs/ordered_list.js
@@ -39,7 +39,8 @@ describe('assign ordered list', function () {
it('does not insert unordered list', function (done) {
this.timeout(3000);
- helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
+ helper.waitFor(
+ () => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
}).fail(() => {
done();
@@ -69,7 +70,8 @@ describe('assign ordered list', function () {
it('does not insert unordered list', function (done) {
this.timeout(3000);
- helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
+ helper.waitFor(
+ () => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
}).fail(() => {
done();
@@ -78,7 +80,8 @@ describe('assign ordered list', function () {
});
});
- xit('issue #1125 keeps the numbered list on enter for the new line - EMULATES PASTING INTO A PAD', function (done) {
+ xit('issue #1125 keeps the numbered list on enter for the new line', function (done) {
+ // EMULATES PASTING INTO A PAD
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
@@ -104,19 +107,19 @@ describe('assign ordered list', function () {
});
});
- const triggerCtrlShiftShortcut = function (shortcutChar) {
+ const triggerCtrlShiftShortcut = (shortcutChar) => {
const inner$ = helper.padInner$;
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.ctrlKey = true;
e.shiftKey = true;
e.which = shortcutChar.toString().charCodeAt(0);
inner$('#innerdocbody').trigger(e);
};
- const makeSureShortcutIsDisabled = function (shortcut) {
+ const makeSureShortcutIsDisabled = (shortcut) => {
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
};
- const makeSureShortcutIsEnabled = function (shortcut) {
+ const makeSureShortcutIsEnabled = (shortcut) => {
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
};
});
@@ -142,7 +145,7 @@ describe('Pressing Tab in an OL increases and decreases indentation', function (
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
$insertorderedlistButton.click();
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.keyCode = 9; // tab
inner$('#innerdocbody').trigger(e);
@@ -156,7 +159,8 @@ describe('Pressing Tab in an OL increases and decreases indentation', function (
});
-describe('Pressing indent/outdent button in an OL increases and decreases indentation and bullet / ol formatting', function () {
+describe('Pressing indent/outdent button in an OL increases and ' +
+ 'decreases indentation and bullet / ol formatting', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
diff --git a/tests/frontend/specs/pad_modal.js b/tests/frontend/specs/pad_modal.js
index 39c41a447..4e9c844b7 100644
--- a/tests/frontend/specs/pad_modal.js
+++ b/tests/frontend/specs/pad_modal.js
@@ -100,17 +100,17 @@ describe('Pad modal', function () {
});
});
- const clickOnPadInner = function () {
+ const clickOnPadInner = () => {
const $editor = helper.padInner$('#innerdocbody');
$editor.click();
};
- const clickOnPadOuter = function () {
+ const clickOnPadOuter = () => {
const $lineNumbersColumn = helper.padOuter$('#sidedivinner');
$lineNumbersColumn.click();
};
- const openSettingsAndWaitForModalToBeVisible = function (done) {
+ const openSettingsAndWaitForModalToBeVisible = (done) => {
helper.padChrome$('.buttonicon-settings').click();
// wait for modal to be displayed
@@ -118,7 +118,7 @@ describe('Pad modal', function () {
helper.waitFor(() => isModalOpened(modalSelector), 10000).done(done);
};
- const isEditorDisabled = function () {
+ const isEditorDisabled = () => {
const editorDocument = helper.padOuter$("iframe[name='ace_inner']").get(0).contentDocument;
const editorBody = editorDocument.getElementById('innerdocbody');
@@ -128,7 +128,7 @@ describe('Pad modal', function () {
return editorIsDisabled;
};
- const isModalOpened = function (modalSelector) {
+ const isModalOpened = (modalSelector) => {
const $modal = helper.padChrome$(modalSelector);
return $modal.hasClass('popup-show');
diff --git a/tests/frontend/specs/responsiveness.js b/tests/frontend/specs/responsiveness.js
index 090826979..ec63faa10 100644
--- a/tests/frontend/specs/responsiveness.js
+++ b/tests/frontend/specs/responsiveness.js
@@ -3,14 +3,17 @@
// Test for https://github.com/ether/etherpad-lite/issues/1763
// This test fails in Opera, IE and Safari
-// Opera fails due to a weird way of handling the order of execution, yet actual performance seems fine
+// Opera fails due to a weird way of handling the order of execution,
+// yet actual performance seems fine
// Safari fails due the delay being too great yet the actual performance seems fine
// Firefox might panic that the script is taking too long so will fail
// IE will fail due to running out of memory as it can't fit 2M chars in memory.
-// Just FYI Google Docs crashes on large docs whilst trying to Save, it's likely the limitations we are
+// Just FYI Google Docs crashes on large docs whilst trying to Save,
+// it's likely the limitations we are
// experiencing are more to do with browser limitations than improper implementation.
-// A ueber fix for this would be to have a separate lower cpu priority thread that handles operations that aren't
+// A ueber fix for this would be to have a separate lower cpu priority
+// thread that handles operations that aren't
// visible to the user.
// Adapted from John McLear's original test case.
@@ -22,16 +25,18 @@ xdescribe('Responsiveness of Editor', function () {
this.timeout(6000);
});
// JM commented out on 8th Sep 2020 for a release, after release this needs uncommenting
- // And the test needs to be fixed to work in Firefox 52 on Windows 7. I am not sure why it fails on this specific platform
- // The errors show this.timeout... then crash the browser but I am sure something is actually causing the stack trace and
+ // And the test needs to be fixed to work in Firefox 52 on Windows 7.
+ // I am not sure why it fails on this specific platform
+ // The errors show this.timeout... then crash the browser but
+ // I am sure something is actually causing the stack trace and
// I just need to narrow down what, offers to help accepted.
it('Fast response to keypress in pad with large amount of contents', function (done) {
// skip on Windows Firefox 52.0
- if (window.bowser && window.bowser.windows && window.bowser.firefox && window.bowser.version == '52.0') {
+ if (window.bowser &&
+ window.bowser.windows && window.bowser.firefox && window.bowser.version === '52.0') {
this.skip();
}
const inner$ = helper.padInner$;
- const chrome$ = helper.padChrome$;
const chars = '0000000000'; // row of placeholder chars
const amount = 200000; // number of blocks of chars we will insert
const length = (amount * (chars.length) + 1); // include a counter for each space
@@ -41,7 +46,7 @@ xdescribe('Responsiveness of Editor', function () {
// get keys to send
const keyMultiplier = 10; // multiplier * 10 == total number of key events
let keysToSend = '';
- for (var i = 0; i <= keyMultiplier; i++) {
+ for (let i = 0; i <= keyMultiplier; i++) {
keysToSend += chars;
}
@@ -49,23 +54,23 @@ xdescribe('Responsiveness of Editor', function () {
textElement.sendkeys('{selectall}'); // select all
textElement.sendkeys('{del}'); // clear the pad text
- for (var i = 0; i <= amount; i++) {
+ for (let i = 0; i <= amount; i++) {
text = `${text + chars} `; // add the chars and space to the text contents
}
inner$('div').first().text(text); // Put the text contents into the pad
- helper.waitFor(() => // Wait for the new contents to be on the pad
- inner$('div').text().length > length
- ).done(() => {
- expect(inner$('div').text().length).to.be.greaterThan(length); // has the text changed?
+ // Wait for the new contents to be on the pad
+ helper.waitFor(() => inner$('div').text().length > length).done(() => {
+ // has the text changed?
+ expect(inner$('div').text().length).to.be.greaterThan(length);
const start = Date.now(); // get the start time
// send some new text to the screen (ensure all 3 key events are sent)
const el = inner$('div').first();
for (let i = 0; i < keysToSend.length; ++i) {
- var x = keysToSend.charCodeAt(i);
+ const x = keysToSend.charCodeAt(i);
['keyup', 'keypress', 'keydown'].forEach((type) => {
- const e = $.Event(type);
+ const e = new $.Event(type);
e.keyCode = x;
el.trigger(e);
});
diff --git a/tests/frontend/specs/select_formatting_buttons.js b/tests/frontend/specs/select_formatting_buttons.js
index 666e81449..27b750e7f 100644
--- a/tests/frontend/specs/select_formatting_buttons.js
+++ b/tests/frontend/specs/select_formatting_buttons.js
@@ -91,7 +91,7 @@ describe('select formatting buttons when selection has style applied', function
// select this text element
$firstTextElement.sendkeys('{selectall}');
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.ctrlKey = true; // Control key
e.which = key.charCodeAt(0); // I, U, B, 5
inner$('#innerdocbody').trigger(e);
diff --git a/tests/frontend/specs/strikethrough.js b/tests/frontend/specs/strikethrough.js
index bb477e01a..301aef64b 100644
--- a/tests/frontend/specs/strikethrough.js
+++ b/tests/frontend/specs/strikethrough.js
@@ -22,8 +22,6 @@ describe('strikethrough button', function () {
const $strikethroughButton = chrome$('.buttonicon-strikethrough');
$strikethroughButton.click();
- // ace creates a new dom element when you press a button
- // so just get the first text element again
const $newFirstTextElement = inner$('div').first();
// is there a element now?
diff --git a/tests/frontend/specs/timeslider.js b/tests/frontend/specs/timeslider.js
index 401a71758..10f94b3cb 100644
--- a/tests/frontend/specs/timeslider.js
+++ b/tests/frontend/specs/timeslider.js
@@ -14,7 +14,6 @@ xdescribe('timeslider button takes you to the timeslider of a pad', function ()
// get the first text element inside the editable space
const $firstTextElement = inner$('div span').first();
const originalValue = $firstTextElement.text(); // get the original value
- const newValue = `Testing${originalValue}`;
$firstTextElement.sendkeys('Testing'); // send line 1 to the pad
const modifiedValue = $firstTextElement.text(); // get the modified value
diff --git a/tests/frontend/specs/timeslider_labels.js b/tests/frontend/specs/timeslider_labels.js
index 72a24256b..54e5da258 100644
--- a/tests/frontend/specs/timeslider_labels.js
+++ b/tests/frontend/specs/timeslider_labels.js
@@ -9,8 +9,10 @@ describe('timeslider', function () {
/**
* @todo test authorsList
*/
+
it('Shows a correctly formatted date and time', async function () {
this.timeout(12000);
+
// make some changes to produce 3 revisions
const revs = 3;
diff --git a/tests/frontend/specs/timeslider_revisions.js b/tests/frontend/specs/timeslider_revisions.js
index de3c52a6f..4c2984686 100644
--- a/tests/frontend/specs/timeslider_revisions.js
+++ b/tests/frontend/specs/timeslider_revisions.js
@@ -26,8 +26,8 @@ describe('timeslider', function () {
setTimeout(() => {
// go to timeslider
- $('#iframe-container iframe')
- .attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
+ $('#iframe-container iframe').attr('src',
+ `${$('#iframe-container iframe').attr('src')}/timeslider`);
setTimeout(() => {
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
@@ -84,8 +84,8 @@ describe('timeslider', function () {
setTimeout(() => {
// go to timeslider
- $('#iframe-container iframe')
- .attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
+ $('#iframe-container iframe').attr('src',
+ `${$('#iframe-container iframe').attr('src')}/timeslider`);
setTimeout(() => {
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
@@ -102,15 +102,16 @@ describe('timeslider', function () {
helper.waitFor(
() => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000)
.always(() => {
- expect($('#iframe-container iframe')[0].contentWindow.location.hash)
- .not.to.eql(oldUrl);
+ expect(
+ $('#iframe-container iframe')[0].contentWindow.location.hash
+ ).not.to.eql(oldUrl);
done();
});
}, 6000);
}, revs * timePerRev);
});
it('jumps to a revision given in the url', function (done) {
- this.timeout(6000);
+ this.timeout(40000);
const inner$ = helper.padInner$;
// wait for the text to be loaded
@@ -132,15 +133,16 @@ describe('timeslider', function () {
return lenOkay && colorOkay;
}, 10000).always(() => {
// go to timeslider with a specific revision set
- $('#iframe-container iframe')
- .attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
+
+ $('#iframe-container iframe').attr('src',
+ `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
// wait for the timeslider to be loaded
helper.waitFor(() => {
try {
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
} catch (e) {
- // silently fart. Deadly.
+ // Empty catch block <3
}
if (timeslider$) {
return timeslider$('#innerdocbody').text().length === oldLength;
@@ -161,8 +163,8 @@ describe('timeslider', function () {
setTimeout(() => {
// go to timeslider
- $('#iframe-container iframe')
- .attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
+ $('#iframe-container iframe').attr('src',
+ `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
let timeslider$;
let exportLink;
@@ -170,7 +172,7 @@ describe('timeslider', function () {
try {
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
} catch (e) {
- // silently give up on life.
+ // Empty catch block <3
}
if (!timeslider$) return false;
exportLink = timeslider$('#exportplaina').attr('href');
diff --git a/tests/frontend/specs/undo.js b/tests/frontend/specs/undo.js
index eabc4005d..95936669d 100644
--- a/tests/frontend/specs/undo.js
+++ b/tests/frontend/specs/undo.js
@@ -43,7 +43,7 @@ describe('undo button', function () {
const modifiedValue = $firstTextElement.text(); // get the modified value
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
- const e = inner$.Event(helper.evtType);
+ const e = new inner$.Event(helper.evtType);
e.ctrlKey = true; // Control key
e.which = 90; // z
inner$('#innerdocbody').trigger(e);
diff --git a/tests/frontend/specs/unordered_list.js b/tests/frontend/specs/unordered_list.js
index af13af2b2..45ed4ad41 100644
--- a/tests/frontend/specs/unordered_list.js
+++ b/tests/frontend/specs/unordered_list.js
@@ -138,7 +138,8 @@ describe('Pressing Tab in an UL increases and decreases indentation', function (
});
});
-describe('Pressing indent/outdent button in an UL increases and decreases indentation and bullet / ol formatting', function () {
+describe('Pressing indent/outdent button in an UL increases and decreases indentation ' +
+ 'and bullet / ol formatting', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
diff --git a/tests/frontend/travis/remote_runner.js b/tests/frontend/travis/remote_runner.js
index 70c850ca8..ba0e7be0c 100644
--- a/tests/frontend/travis/remote_runner.js
+++ b/tests/frontend/travis/remote_runner.js
@@ -1,17 +1,19 @@
-var srcFolder = '../../../src/node_modules/';
-var wd = require(`${srcFolder}wd`);
-var async = require(`${srcFolder}async`);
+'use strict';
-var config = {
+const wd = require('ep_etherpad-lite/node_modules/wd');
+const async = require('ep_etherpad-lite/node_modules/async');
+
+const config = {
host: 'ondemand.saucelabs.com',
port: 80,
username: process.env.SAUCE_USER,
accessKey: process.env.SAUCE_ACCESS_KEY,
};
-var allTestsPassed = true;
+let allTestsPassed = true;
// overwrite the default exit code
-// in case not all worker can be run (due to saucelabs limits), `queue.drain` below will not be called
+// in case not all worker can be run (due to saucelabs limits),
+// `queue.drain` below will not be called
// and the script would silently exit with error code 0
process.exitCode = 2;
process.on('exit', (code) => {
@@ -20,13 +22,18 @@ process.on('exit', (code) => {
}
});
-var sauceTestWorker = async.queue((testSettings, callback) => {
- const browser = wd.promiseChainRemote(config.host, config.port, config.username, config.accessKey);
- const name = `${process.env.GIT_HASH} - ${testSettings.browserName} ${testSettings.version}, ${testSettings.platform}`;
+const sauceTestWorker = async.queue((testSettings, callback) => {
+ const browser = wd.promiseChainRemote(
+ config.host, config.port, config.username, config.accessKey);
+ const name =
+ `${process.env.GIT_HASH} - ${testSettings.browserName} ` +
+ `${testSettings.version}, ${testSettings.platform}`;
testSettings.name = name;
testSettings.public = true;
testSettings.build = process.env.GIT_HASH;
- testSettings.extendedDebugging = true; // console.json can be downloaded via saucelabs, don't know how to print them into output of the tests
+ // console.json can be downloaded via saucelabs,
+ // don't know how to print them into output of the tests
+ testSettings.extendedDebugging = true;
testSettings.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
browser.init(testSettings).get('http://localhost:9001/tests/frontend/', () => {
@@ -34,7 +41,7 @@ var sauceTestWorker = async.queue((testSettings, callback) => {
console.log(`Remote sauce test '${name}' started! ${url}`);
// tear down the test excecution
- const stopSauce = function (success, timesup) {
+ const stopSauce = (success, timesup) => {
clearInterval(getStatusInterval);
clearTimeout(timeout);
@@ -43,12 +50,15 @@ var sauceTestWorker = async.queue((testSettings, callback) => {
allTestsPassed = false;
}
- // if stopSauce is called via timeout (in contrast to via getStatusInterval) than the log of up to the last
+ // if stopSauce is called via timeout
+ // (in contrast to via getStatusInterval) than the log of up to the last
// five seconds may not be available here. It's an error anyway, so don't care about it.
printLog(logIndex);
if (timesup) {
- console.log(`[${testSettings.browserName} ${testSettings.platform}${testSettings.version === '' ? '' : (` ${testSettings.version}`)}] \x1B[31mFAILED\x1B[39m allowed test duration exceeded`);
+ console.log(`[${testSettings.browserName} ${testSettings.platform}` +
+ `${testSettings.version === '' ? '' : (` ${testSettings.version}`)}]` +
+ ' \x1B[31mFAILED\x1B[39m allowed test duration exceeded');
}
console.log(`Remote sauce test '${name}' finished! ${url}`);
@@ -58,17 +68,19 @@ var sauceTestWorker = async.queue((testSettings, callback) => {
/**
* timeout if a test hangs or the job exceeds 14.5 minutes
- * It's necessary because if travis kills the saucelabs session due to inactivity, we don't get any output
- * @todo this should be configured in testSettings, see https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options#TestConfigurationOptions-Timeouts
+ * It's necessary because if travis kills the saucelabs session due to inactivity,
+ * we don't get any output
+ * @todo this should be configured in testSettings, see
+ * https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options#TestConfigurationOptions-Timeouts
*/
- var timeout = setTimeout(() => {
+ const timeout = setTimeout(() => {
stopSauce(false, true);
}, 870000); // travis timeout is 15 minutes, set this to a slightly lower value
let knownConsoleText = '';
// how many characters of the log have been sent to travis
let logIndex = 0;
- var getStatusInterval = setInterval(() => {
+ const getStatusInterval = setInterval(() => {
browser.eval("$('#console').text()", (err, consoleText) => {
if (!consoleText || err) {
return;
@@ -76,9 +88,10 @@ var sauceTestWorker = async.queue((testSettings, callback) => {
knownConsoleText = consoleText;
if (knownConsoleText.indexOf('FINISHED') > 0) {
- const match = knownConsoleText.match(/FINISHED.*([0-9]+) tests passed, ([0-9]+) tests failed/);
+ const match = knownConsoleText.match(
+ /FINISHED.*([0-9]+) tests passed, ([0-9]+) tests failed/);
// finished without failures
- if (match[2] && match[2] == '0') {
+ if (match[2] && match[2] === '0') {
stopSauce(true);
// finished but some tests did not return or some tests failed
@@ -99,13 +112,17 @@ var sauceTestWorker = async.queue((testSettings, callback) => {
*
* @param {number} index offset from where to start
*/
- function printLog(index) {
- let testResult = knownConsoleText.substring(index).replace(/\[red\]/g, '\x1B[31m').replace(/\[yellow\]/g, '\x1B[33m')
+ const printLog = (index) => {
+ let testResult = knownConsoleText.substring(index)
+ .replace(/\[red\]/g, '\x1B[31m').replace(/\[yellow\]/g, '\x1B[33m')
.replace(/\[green\]/g, '\x1B[32m').replace(/\[clear\]/g, '\x1B[39m');
- testResult = testResult.split('\\n').map((line) => `[${testSettings.browserName} ${testSettings.platform}${testSettings.version === '' ? '' : (` ${testSettings.version}`)}] ${line}`).join('\n');
+ testResult = testResult.split('\\n').map((line) => `[${testSettings.browserName} ` +
+ `${testSettings.platform}` +
+ `${testSettings.version === '' ? '' : (` ${testSettings.version}`)}]` +
+ `${line}`).join('\n');
console.log(testResult);
- }
+ };
});
}, 6); // run 6 tests in parrallel
diff --git a/tests/ratelimit/send_changesets.js b/tests/ratelimit/send_changesets.js
index b0d994c8c..92af23e18 100644
--- a/tests/ratelimit/send_changesets.js
+++ b/tests/ratelimit/send_changesets.js
@@ -1,8 +1,12 @@
+'use strict';
+
+let etherpad;
try {
- var etherpad = require('../../src/node_modules/etherpad-cli-client');
+ etherpad = require('ep_etherpad-lite/node_modules/etherpad-cli-client');
// ugly
} catch {
- var etherpad = require('etherpad-cli-client');
+ /* eslint-disable-next-line node/no-missing-require */
+ etherpad = require('etherpad-cli-client'); // uses global
}
const pad = etherpad.connect(process.argv[2]);
pad.on('connected', () => {
@@ -18,7 +22,7 @@ pad.on('connected', () => {
});
// in case of disconnect exit code 1
pad.on('message', (message) => {
- if (message.disconnect == 'rateLimited') {
+ if (message.disconnect === 'rateLimited') {
process.exit(1);
}
});