From edf1dabe65d2388b8634b70b26fc6ed4e40550e6 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 27 Jan 2021 04:53:28 +0000 Subject: [PATCH] low hanging lint and some hard coded timeouts --- tests/frontend/lib/mocha.js | 16 +++--- tests/frontend/runner.js | 2 +- tests/frontend/specs/alphabet.js | 3 +- .../frontend/specs/authorship_of_editions.js | 5 ++ tests/frontend/specs/bold.js | 11 ++-- tests/frontend/specs/change_user_color.js | 17 +++--- tests/frontend/specs/change_user_name.js | 4 ++ tests/frontend/specs/chat.js | 15 ++++-- tests/frontend/specs/chat_load_messages.js | 24 +++++---- .../frontend/specs/clear_authorship_colors.js | 36 ++++++------- tests/frontend/specs/delete.js | 12 ++--- tests/frontend/specs/drag_and_drop.js | 30 ++++++----- tests/frontend/specs/embed_value.js | 6 +++ tests/frontend/specs/enter.js | 11 ++-- tests/frontend/specs/font_type.js | 4 +- tests/frontend/specs/helper.js | 4 +- tests/frontend/specs/indentation.js | 21 +++++--- tests/frontend/specs/italic.js | 7 +-- tests/frontend/specs/language.js | 22 ++++---- ...ultiple_authors_clear_authorship_colors.js | 20 ++++--- tests/frontend/specs/ordered_list.js | 18 +++++-- tests/frontend/specs/pad_modal.js | 17 ++++-- tests/frontend/specs/redo.js | 9 ++-- tests/frontend/specs/responsiveness.js | 2 + tests/frontend/specs/scrollTo.js | 4 +- .../specs/select_formatting_buttons.js | 10 ++-- tests/frontend/specs/strikethrough.js | 6 ++- tests/frontend/specs/timeslider.js | 2 + tests/frontend/specs/timeslider_follow.js | 1 + tests/frontend/specs/timeslider_labels.js | 5 +- .../specs/timeslider_numeric_padID.js | 4 ++ tests/frontend/specs/timeslider_revisions.js | 53 +++++++++++-------- tests/frontend/specs/undo.js | 5 +- tests/frontend/specs/unordered_list.js | 9 ++++ tests/frontend/specs/urls_become_clickable.js | 3 ++ tests/frontend/specs/xxauto_reconnect.js | 5 +- 36 files changed, 273 insertions(+), 150 deletions(-) diff --git a/tests/frontend/lib/mocha.js b/tests/frontend/lib/mocha.js index a9669b1b7..bba9033b0 100644 --- a/tests/frontend/lib/mocha.js +++ b/tests/frontend/lib/mocha.js @@ -3216,10 +3216,10 @@ function HTML(runner, options) { runner.on(EVENT_TEST_PASS, function(test) { var url = self.testURL(test); var markup = - '
  • %e%ems ' + + '
  • %e

    %ems ' + '' + playIcon + - '
  • '; + ''; var el = fragment(markup, test.speed, test.title, test.duration, url); self.addCodeToggle(el, test.body); appendToStack(el); @@ -13792,18 +13792,18 @@ function mkdirP (p, opts, f, made) { else if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 } if (!made) made = null; - + var cb = f || function () {}; p = path.resolve(p); - + xfs.mkdir(p, mode, function (er) { if (!er) { made = made || p; @@ -13837,10 +13837,10 @@ mkdirP.sync = function sync (p, opts, made) { if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 } diff --git a/tests/frontend/runner.js b/tests/frontend/runner.js index 616c065b3..55ef2acf3 100644 --- a/tests/frontend/runner.js +++ b/tests/frontend/runner.js @@ -69,7 +69,7 @@ $(() => { }, 60000 * 3); const medium = test.slow() / 2; - test.speed = test.duration > test.slow() + test.speed = test.duratoin > test.slow() ? 'slow' : test.duration > medium ? 'medium' diff --git a/tests/frontend/specs/alphabet.js b/tests/frontend/specs/alphabet.js index 9371683ca..939bcfe18 100644 --- a/tests/frontend/specs/alphabet.js +++ b/tests/frontend/specs/alphabet.js @@ -1,3 +1,5 @@ +'use strict'; + describe('All the alphabet works n stuff', function () { const expectedString = 'abcdefghijklmnopqrstuvwxyz'; @@ -10,7 +12,6 @@ describe('All the alphabet works n stuff', function () { it('when you enter any char it appears right', function (done) { this.timeout(100); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element out of the inner iframe const firstTextElement = inner$('div').first(); diff --git a/tests/frontend/specs/authorship_of_editions.js b/tests/frontend/specs/authorship_of_editions.js index 6cf14b869..73007dc30 100644 --- a/tests/frontend/specs/authorship_of_editions.js +++ b/tests/frontend/specs/authorship_of_editions.js @@ -1,3 +1,5 @@ +'use strict'; + describe('author of pad edition', function () { const REGULAR_LINE = 0; const LINE_WITH_ORDERED_LIST = 1; @@ -56,14 +58,17 @@ describe('author of pad edition', function () { // author 2 makes some changes on the pad it('marks only the new content as changes of the second user on a regular line', function (done) { + this.timeout(100); 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) { + this.timeout(100); 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) { + this.timeout(100); changeLineAndCheckOnlyThatChangeIsFromThisAuthor(LINE_WITH_UNORDERED_LIST, 'z', done); }); diff --git a/tests/frontend/specs/bold.js b/tests/frontend/specs/bold.js index a7c46e1bc..f15026862 100644 --- a/tests/frontend/specs/bold.js +++ b/tests/frontend/specs/bold.js @@ -1,3 +1,5 @@ +'use strict'; + describe('bold button', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,6 +8,7 @@ describe('bold button', function () { }); it('makes text bold on click', function (done) { + this.timeout(50); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -19,7 +22,8 @@ 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 + // 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? @@ -35,8 +39,8 @@ describe('bold button', function () { }); it('makes text bold on keypress', function (done) { + this.timeout(50); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); @@ -49,7 +53,8 @@ describe('bold button', function () { 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 + // 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/change_user_color.js b/tests/frontend/specs/change_user_color.js index e8c16db37..b01bda7e3 100644 --- a/tests/frontend/specs/change_user_color.js +++ b/tests/frontend/specs/change_user_color.js @@ -1,3 +1,5 @@ +'use strict'; + describe('change user color', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -5,8 +7,8 @@ describe('change user color', function () { this.timeout(60000); }); - it('Color picker matches original color and remembers the user color after a refresh', function (done) { - this.timeout(60000); + it('Color picker remembers the user color after a refresh', function (done) { + this.timeout(5000); const chrome$ = helper.padChrome$; // click on the settings button to make settings visible @@ -60,7 +62,7 @@ describe('change user color', function () { }); it('Own user color is shown when you enter a chat', function (done) { - const inner$ = helper.padInner$; + this.timeout(200); const chrome$ = helper.padChrome$; const $colorOption = helper.padChrome$('#options-colorscheck'); @@ -90,13 +92,16 @@ describe('change user color', function () { $chatButton.click(); const $chatInput = chrome$('#chatinput'); $chatInput.sendkeys('O hi'); // simulate a keypress of typing user - $chatInput.sendkeys('{enter}'); // simulate a keypress of enter actually does evt.which = 10 not 13 + // simulate a keypress of enter actually does evt.which = 10 not 13 + $chatInput.sendkeys('{enter}'); // check if chat shows up - helper.waitFor(() => chrome$('#chattext').children('p').length !== 0 // wait until the chat message shows up + // wait until the chat message shows up + helper.waitFor(() => chrome$('#chattext').children('p').length !== 0 ).done(() => { const $firstChatMessage = chrome$('#chattext').children('p'); - expect($firstChatMessage.css('background-color')).to.be(testColorRGB); // expect the first chat message to be of the user's color + // expect the first chat message to be of the user's color + expect($firstChatMessage.css('background-color')).to.be(testColorRGB); done(); }); }); diff --git a/tests/frontend/specs/change_user_name.js b/tests/frontend/specs/change_user_name.js index 0b9132f80..fb0239605 100644 --- a/tests/frontend/specs/change_user_name.js +++ b/tests/frontend/specs/change_user_name.js @@ -1,3 +1,5 @@ +'use strict'; + describe('change username value', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -5,6 +7,7 @@ describe('change username value', function () { }); it('Remembers the user name after a refresh', async function () { + this.timeout(100); helper.toggleUserList(); helper.setUserName('😃'); @@ -19,6 +22,7 @@ describe('change username value', function () { }); it('Own user name is shown when you enter a chat', async function () { + this.timeout(100); helper.toggleUserList(); helper.setUserName('😃'); diff --git a/tests/frontend/specs/chat.js b/tests/frontend/specs/chat.js index d45988d60..6c8ee9fdc 100644 --- a/tests/frontend/specs/chat.js +++ b/tests/frontend/specs/chat.js @@ -1,10 +1,13 @@ +'use strict'; + describe('Chat messages and UI', function () { // create a new pad before each test run beforeEach(function (cb) { helper.newPad(cb); }); - it('opens chat, sends a message, makes sure it exists on the page and hides chat', async function () { + it('opens chat, sends a message, makes sure it exists and hides chat', async function () { + this.timeout(100); const chatValue = 'JohnMcLear'; await helper.showChat(); @@ -27,11 +30,13 @@ describe('Chat messages and UI', function () { }); it("makes sure that an empty message can't be sent", async function () { + this.timeout(100); const chatValue = 'mluto'; await helper.showChat(); - await helper.sendChatMessage(`{enter}${chatValue}{enter}`); // simulate a keypress of typing enter, mluto and enter (to send 'mluto') + // simulate a keypress of typing enter, mluto and enter (to send 'mluto') + await helper.sendChatMessage(`{enter}${chatValue}{enter}`); const chat = helper.chatTextParagraphs(); @@ -45,6 +50,7 @@ describe('Chat messages and UI', function () { }); it('makes chat stick to right side of the screen via settings, remove sticky via settings, close it', async function () { + this.timeout(200); await helper.showSettings(); await helper.enableStickyChatviaSettings(); @@ -61,6 +67,7 @@ describe('Chat messages and UI', 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(200); await helper.showChat(); await helper.enableStickyChatviaIcon(); @@ -76,10 +83,8 @@ describe('Chat messages and UI', function () { expect(helper.isChatboxShown()).to.be(false); }); - xit('Checks showChat=false URL Parameter hides chat then when removed it shows chat', function (done) { + xit('Checks showChat=false URL Parameter shows/hides chat', function (done) { this.timeout(60000); - const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; setTimeout(() => { // give it a second to save the username on the server side helper.newPad({ // get a new pad, but don't clear the cookies diff --git a/tests/frontend/specs/chat_load_messages.js b/tests/frontend/specs/chat_load_messages.js index 29c1734ca..542932249 100644 --- a/tests/frontend/specs/chat_load_messages.js +++ b/tests/frontend/specs/chat_load_messages.js @@ -1,13 +1,15 @@ +'use strict'; + describe('chat-load-messages', function () { let padName; it('creates a pad', function (done) { + this.timeout(3000); padName = helper.newPad(done); - this.timeout(60000); }); it('adds a lot of messages', function (done) { - const inner$ = helper.padInner$; + this.timeout(5000); const chrome$ = helper.padChrome$; const chatButton = chrome$('#chaticon'); chatButton.click(); @@ -19,18 +21,19 @@ describe('chat-load-messages', function () { const messages = 140; for (let i = 1; i <= messages; i++) { let num = `${i}`; - if (num.length == 1) num = `00${num}`; - if (num.length == 2) num = `0${num}`; + if (num.length === 1) num = `00${num}`; + if (num.length === 2) num = `0${num}`; chatInput.sendkeys(`msg${num}`); chatInput.sendkeys('{enter}'); } - helper.waitFor(() => chatText.children('p').length == messages, 60000).always(() => { + helper.waitFor(() => chatText.children('p').length === messages, 60000).always(() => { expect(chatText.children('p').length).to.be(messages); helper.newPad(done, padName); }); }); it('checks initial message count', function (done) { + this.timeout(100); let chatText; const expectedCount = 101; const chrome$ = helper.padChrome$; @@ -38,7 +41,7 @@ describe('chat-load-messages', function () { const chatButton = chrome$('#chaticon'); chatButton.click(); chatText = chrome$('#chattext'); - return chatText.children('p').length == expectedCount; + return chatText.children('p').length === expectedCount; }).always(() => { expect(chatText.children('p').length).to.be(expectedCount); done(); @@ -46,6 +49,7 @@ describe('chat-load-messages', function () { }); it('loads more messages', function (done) { + this.timeout(1500); const expectedCount = 122; const chrome$ = helper.padChrome$; const chatButton = chrome$('#chaticon'); @@ -54,24 +58,24 @@ describe('chat-load-messages', function () { const loadMsgBtn = chrome$('#chatloadmessagesbutton'); loadMsgBtn.click(); - helper.waitFor(() => chatText.children('p').length == expectedCount).always(() => { + helper.waitFor(() => chatText.children('p').length === expectedCount).always(() => { expect(chatText.children('p').length).to.be(expectedCount); done(); }); }); it('checks for button vanishing', function (done) { + this.timeout(2000); const expectedDisplay = 'none'; const chrome$ = helper.padChrome$; const chatButton = chrome$('#chaticon'); chatButton.click(); - const chatText = chrome$('#chattext'); const loadMsgBtn = chrome$('#chatloadmessagesbutton'); const loadMsgBall = chrome$('#chatloadmessagesball'); loadMsgBtn.click(); - helper.waitFor(() => loadMsgBtn.css('display') == expectedDisplay && - loadMsgBall.css('display') == expectedDisplay).always(() => { + helper.waitFor(() => loadMsgBtn.css('display') === expectedDisplay && + loadMsgBall.css('display') === expectedDisplay).always(() => { expect(loadMsgBtn.css('display')).to.be(expectedDisplay); expect(loadMsgBall.css('display')).to.be(expectedDisplay); done(); diff --git a/tests/frontend/specs/clear_authorship_colors.js b/tests/frontend/specs/clear_authorship_colors.js index f622e912a..c0e116dc3 100644 --- a/tests/frontend/specs/clear_authorship_colors.js +++ b/tests/frontend/specs/clear_authorship_colors.js @@ -1,3 +1,5 @@ +'use strict'; + describe('clear authorship colors button', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,6 +8,7 @@ describe('clear authorship colors button', function () { }); it('makes text clear authorship colors', function (done) { + this.timeout(1500); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -17,9 +20,6 @@ describe('clear authorship colors button', function () { // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); - // Get the original text - const originalText = inner$('div').first().text(); - // Set some new text const sentText = 'Hello'; @@ -28,7 +28,9 @@ describe('clear authorship colors button', function () { $firstTextElement.sendkeys(sentText); $firstTextElement.sendkeys('{rightarrow}'); - helper.waitFor(() => inner$('div span').first().attr('class').indexOf('author') !== -1 // wait until we have the full value available + // wait until we have the full value available + helper.waitFor( + () => inner$('div span').first().attr('class').indexOf('author') !== -1 ).done(() => { // IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship inner$('div').first().focus(); @@ -37,16 +39,13 @@ describe('clear authorship colors button', function () { const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship'); $clearauthorshipcolorsButton.click(); - // does the first divs span include an author class? - var hasAuthorClass = inner$('div span').first().attr('class').indexOf('author') !== -1; - // expect(hasAuthorClass).to.be(false); - // does the first div include an author class? - var hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1; + const hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1; expect(hasAuthorClass).to.be(false); helper.waitFor(() => { - const disconnectVisible = chrome$('div.disconnected').attr('class').indexOf('visible') === -1; + const disconnectVisible = + chrome$('div.disconnected').attr('class').indexOf('visible') === -1; return (disconnectVisible === true); }); @@ -58,6 +57,7 @@ describe('clear authorship colors button', function () { }); it("makes text clear authorship colors and checks it can't be undone", function (done) { + this.timeout(1500); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -69,9 +69,6 @@ describe('clear authorship colors button', function () { // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); - // Get the original text - const originalText = inner$('div').first().text(); - // Set some new text const sentText = 'Hello'; @@ -80,7 +77,9 @@ describe('clear authorship colors button', function () { $firstTextElement.sendkeys(sentText); $firstTextElement.sendkeys('{rightarrow}'); - helper.waitFor(() => inner$('div span').first().attr('class').indexOf('author') !== -1 // wait until we have the full value available + // wait until we have the full value available + helper.waitFor( + () => inner$('div span').first().attr('class').indexOf('author') !== -1 ).done(() => { // IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship inner$('div').first().focus(); @@ -89,12 +88,8 @@ describe('clear authorship colors button', function () { const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship'); $clearauthorshipcolorsButton.click(); - // does the first divs span include an author class? - var hasAuthorClass = inner$('div span').first().attr('class').indexOf('author') !== -1; - // expect(hasAuthorClass).to.be(false); - // does the first div include an author class? - var hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1; + let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1; expect(hasAuthorClass).to.be(false); const e = inner$.Event(helper.evtType); @@ -115,7 +110,8 @@ describe('clear authorship colors button', function () { expect(hasAuthorClass).to.be(false); helper.waitFor(() => { - const disconnectVisible = chrome$('div.disconnected').attr('class').indexOf('visible') === -1; + const disconnectVisible = + chrome$('div.disconnected').attr('class').indexOf('visible') === -1; return (disconnectVisible === true); }); diff --git a/tests/frontend/specs/delete.js b/tests/frontend/specs/delete.js index 4267aeec7..d2b9611c0 100644 --- a/tests/frontend/specs/delete.js +++ b/tests/frontend/specs/delete.js @@ -1,3 +1,5 @@ +'use strict'; + describe('delete keystroke', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,8 +8,9 @@ describe('delete keystroke', function () { }); it('makes text delete', function (done) { + this.timeout(50); + const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); @@ -15,15 +18,12 @@ describe('delete keystroke', function () { // get the original length of this element const elementLength = $firstTextElement.text().length; - // get the original string value minus the last char - const originalTextValue = $firstTextElement.text(); - const originalTextValueMinusFirstChar = originalTextValue.substring(1, originalTextValue.length); - // simulate key presses to delete content $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 + // 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 a9726111c..9fdbc5486 100644 --- a/tests/frontend/specs/drag_and_drop.js +++ b/tests/frontend/specs/drag_and_drop.js @@ -1,4 +1,7 @@ -// WARNING: drag and drop is only simulated on these tests, so manual testing might also be necessary +'use strict'; + +// WARNING: drag and drop is only simulated on these tests +// so manual testing might also be necessary describe('drag and drop', function () { before(function (done) { helper.newPad(() => { @@ -27,6 +30,7 @@ describe('drag and drop', function () { }); it('moves text back to its original place', function (done) { + this.timeout(50); // test text was removed from drop target const $targetLine = getLine(TARGET_LINE); expect($targetLine.text()).to.be('Target line []'); @@ -62,6 +66,7 @@ describe('drag and drop', function () { }); it('moves text back to its original place', function (done) { + this.timeout(50); // test text was removed from drop target const $targetLine = getLine(TARGET_LINE); expect($targetLine.text()).to.be('Target line []'); @@ -78,18 +83,19 @@ describe('drag and drop', function () { }); /* ********************* Helper functions/constants ********************* */ - var TARGET_LINE = 2; - var FIRST_SOURCE_LINE = 5; + const TARGET_LINE = 2; + const FIRST_SOURCE_LINE = 5; - var getLine = function (lineNumber) { + const getLine = function (lineNumber) { const $lines = helper.padInner$('div'); return $lines.slice(lineNumber, lineNumber + 1); }; - var createScriptWithSeveralLines = function (done) { + const createScriptWithSeveralLines = function (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(() => { @@ -98,7 +104,7 @@ describe('drag and drop', function () { }).done(done); }; - var selectPartOfSourceLine = function () { + const selectPartOfSourceLine = function () { const $sourceLine = getLine(FIRST_SOURCE_LINE); // select 'line 1' from 'Source line 1.' @@ -106,14 +112,14 @@ describe('drag and drop', function () { const end = start + 'line 1'.length; helper.selectLines($sourceLine, $sourceLine, start, end); }; - var selectMultipleSourceLines = function () { + const selectMultipleSourceLines = function () { const $firstSourceLine = getLine(FIRST_SOURCE_LINE); const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1); helper.selectLines($firstSourceLine, $lastSourceLine); }; - var dragSelectedTextAndDropItIntoMiddleOfLine = function (targetLineNumber) { + const dragSelectedTextAndDropItIntoMiddleOfLine = function (targetLineNumber) { // dragstart: start dragging content triggerEvent('dragstart'); @@ -126,7 +132,7 @@ describe('drag and drop', function () { triggerEvent('dragend'); }; - var getHtmlFromSelectedText = function () { + const getHtmlFromSelectedText = function () { const innerDocument = helper.padInner$.document; const range = innerDocument.getSelection().getRangeAt(0); @@ -139,12 +145,12 @@ describe('drag and drop', function () { return draggedHtml; }; - var triggerEvent = function (eventName) { + const triggerEvent = function (eventName) { const event = helper.padInner$.Event(eventName); helper.padInner$('#innerdocbody').trigger(event); }; - var moveSelectionIntoTarget = function (draggedHtml, targetLineNumber) { + const moveSelectionIntoTarget = function (draggedHtml, targetLineNumber) { const innerDocument = helper.padInner$.document; // delete original content diff --git a/tests/frontend/specs/embed_value.js b/tests/frontend/specs/embed_value.js index d6fb8c977..ee1bf8966 100644 --- a/tests/frontend/specs/embed_value.js +++ b/tests/frontend/specs/embed_value.js @@ -1,3 +1,5 @@ +'use strict'; + describe('embed links', function () { const objectify = function (str) { const hash = {}; @@ -55,6 +57,7 @@ describe('embed links', function () { describe('the share link', function () { it('is the actual pad url', function (done) { + this.timeout(50); const chrome$ = helper.padChrome$; // open share dropdown @@ -71,6 +74,7 @@ describe('embed links', function () { describe('the embed as iframe code', function () { it('is an iframe with the the correct url parameters and correct size', function (done) { + this.timeout(50); const chrome$ = helper.padChrome$; // open share dropdown @@ -94,6 +98,7 @@ describe('embed links', function () { describe('the share link', function () { it('shows a read only url', function (done) { + this.timeout(50); const chrome$ = helper.padChrome$; // open share dropdown @@ -112,6 +117,7 @@ describe('embed links', function () { describe('the embed as iframe code', function () { it('is an iframe with the the correct url parameters and correct size', function (done) { + this.timeout(50); const chrome$ = helper.padChrome$; // open share dropdown diff --git a/tests/frontend/specs/enter.js b/tests/frontend/specs/enter.js index 6108d7f82..f6fab8b37 100644 --- a/tests/frontend/specs/enter.js +++ b/tests/frontend/specs/enter.js @@ -1,3 +1,5 @@ +'use strict'; + describe('enter keystroke', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,8 +8,9 @@ describe('enter keystroke', function () { }); it('creates a new line & puts cursor onto a new line', function (done) { + this.timeout(2000); + const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); @@ -18,14 +21,12 @@ describe('enter keystroke', function () { // simulate key presses to enter content $firstTextElement.sendkeys('{enter}'); - // ace creates a new dom element when you press a keystroke, so just get the first text element again - const $newFirstTextElement = inner$('div').first(); - helper.waitFor(() => inner$('div').first().text() === '').done(() => { const $newSecondLine = inner$('div').first().next(); const newFirstTextElementValue = inner$('div').first().text(); expect(newFirstTextElementValue).to.be(''); // expect the first line to be blank - expect($newSecondLine.text()).to.be(originalTextValue); // expect the second line to be the same as the original first line. + // expect the second line to be the same as the original first line. + expect($newSecondLine.text()).to.be(originalTextValue); done(); }); }); diff --git a/tests/frontend/specs/font_type.js b/tests/frontend/specs/font_type.js index 51971da39..9790873b3 100644 --- a/tests/frontend/specs/font_type.js +++ b/tests/frontend/specs/font_type.js @@ -1,3 +1,5 @@ +'use strict'; + describe('font select', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,6 +8,7 @@ describe('font select', function () { }); it('makes text RobotoMono', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -15,7 +18,6 @@ describe('font select', function () { // get the font menu and RobotoMono option const $viewfontmenu = chrome$('#viewfontmenu'); - const $RobotoMonooption = $viewfontmenu.find('[value=RobotoMono]'); // select RobotoMono and fire change event // $RobotoMonooption.attr('selected','selected'); diff --git a/tests/frontend/specs/helper.js b/tests/frontend/specs/helper.js index 6bc6a3643..60f8dd331 100644 --- a/tests/frontend/specs/helper.js +++ b/tests/frontend/specs/helper.js @@ -1,3 +1,5 @@ +'use strict'; + describe('the test helper', function () { describe('the newPad method', function () { xit("doesn't leak memory if you creates iframes over and over again", function (done) { @@ -5,7 +7,7 @@ describe('the test helper', function () { let times = 10; - var loadPad = function () { + const loadPad = function () { helper.newPad(() => { times--; if (times > 0) { diff --git a/tests/frontend/specs/indentation.js b/tests/frontend/specs/indentation.js index f35b7ca00..602c2d65e 100644 --- a/tests/frontend/specs/indentation.js +++ b/tests/frontend/specs/indentation.js @@ -1,3 +1,5 @@ +'use strict'; + describe('indentation button', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,8 +8,8 @@ describe('indentation button', function () { }); it('indent text with keypress', function (done) { + this.timeout(100); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); @@ -23,6 +25,7 @@ describe('indentation button', function () { }); it('indent text with button', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -33,6 +36,7 @@ describe('indentation button', function () { }); it('keeps the indent on enter for the new line', function (done) { + this.timeout(150); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -57,8 +61,8 @@ describe('indentation button', function () { }); it("indents text with spaces on enter if previous line ends with ':', '[', '(', or '{'", function (done) { + this.timeout(150); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // type a bit, make a line break and type again const $firstTextElement = inner$('div').first(); @@ -77,7 +81,8 @@ describe('indentation button', function () { // curly braces const $lineWithCurlyBraces = inner$('div').first().next().next().next(); $lineWithCurlyBraces.sendkeys('{{}'); - pressEnter(); // cannot use sendkeys('{enter}') here, browser does not read the command properly + // cannot use sendkeys('{enter}') here, browser does not read the command properly + pressEnter(); const $lineAfterCurlyBraces = inner$('div').first().next().next().next().next(); expect($lineAfterCurlyBraces.text()).to.match(/\s{4}/); // tab === 4 spaces @@ -107,8 +112,8 @@ describe('indentation button', function () { }); it("appends indentation to the indent of previous line if previous line ends with ':', '[', '(', or '{'", function (done) { + this.timeout(150); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // type a bit, make a line break and type again const $firstTextElement = inner$('div').first(); @@ -124,13 +129,15 @@ describe('indentation button', function () { $lineWithColon.sendkeys(':'); pressEnter(); const $lineAfterColon = inner$('div').first().next(); - expect($lineAfterColon.text()).to.match(/\s{6}/); // previous line indentation + regular tab (4 spaces) + // previous line indentation + regular tab (4 spaces) + expect($lineAfterColon.text()).to.match(/\s{6}/); done(); }); }); it("issue #2772 shows '*' when multiple indented lines receive a style and are outdented", function (done) { + this.timeout(150); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -302,9 +309,9 @@ describe('indentation button', function () { });*/ }); -function pressEnter() { +const pressEnter = () => { const inner$ = helper.padInner$; const e = 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 3660f71f3..d22d43ba0 100644 --- a/tests/frontend/specs/italic.js +++ b/tests/frontend/specs/italic.js @@ -1,3 +1,5 @@ +'use strict'; + describe('italic some text', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,6 +8,7 @@ describe('italic some text', function () { }); it('makes text italic using button', function (done) { + this.timeout(50); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -19,7 +22,6 @@ describe('italic some text', function () { const $boldButton = chrome$('.buttonicon-italic'); $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? @@ -35,8 +37,8 @@ describe('italic some text', function () { }); it('makes text italic using keypress', function (done) { + this.timeout(50); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); @@ -49,7 +51,6 @@ describe('italic some text', function () { e.which = 105; // i 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/language.js b/tests/frontend/specs/language.js index d29b2407e..f0fff5671 100644 --- a/tests/frontend/specs/language.js +++ b/tests/frontend/specs/language.js @@ -1,6 +1,8 @@ -function deletecookie(name) { +'use strict'; + +const deletecookie = (name) => { document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; -} +}; describe('Language select and change', function () { // Destroy language cookies @@ -14,7 +16,7 @@ describe('Language select and change', function () { // Destroy language cookies it('makes text german', function (done) { - const inner$ = helper.padInner$; + this.timeout(100); const chrome$ = helper.padChrome$; // click on the settings button to make settings visible @@ -29,7 +31,7 @@ describe('Language select and change', function () { $languageoption.attr('selected', 'selected'); $language.change(); - helper.waitFor(() => chrome$('.buttonicon-bold').parent()[0].title == 'Fett (Strg-B)') + helper.waitFor(() => chrome$('.buttonicon-bold').parent()[0].title === 'Fett (Strg-B)') .done(() => { // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); @@ -44,7 +46,7 @@ describe('Language select and change', function () { }); it('makes text English', function (done) { - const inner$ = helper.padInner$; + this.timeout(100); const chrome$ = helper.padChrome$; // click on the settings button to make settings visible @@ -60,7 +62,7 @@ describe('Language select and change', function () { // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); - helper.waitFor(() => $boldButton[0].title != 'Fett (Strg+B)') + helper.waitFor(() => $boldButton[0].title !== 'Fett (Strg+B)') .done(() => { // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); @@ -75,7 +77,7 @@ describe('Language select and change', function () { }); it('changes direction when picking an rtl lang', function (done) { - const inner$ = helper.padInner$; + this.timeout(200); const chrome$ = helper.padChrome$; // click on the settings button to make settings visible @@ -91,7 +93,7 @@ describe('Language select and change', function () { $language.val('ar'); $languageoption.change(); - helper.waitFor(() => chrome$('html')[0].dir != 'ltr') + helper.waitFor(() => chrome$('html')[0].dir !== 'ltr') .done(() => { // check if the document's direction was changed expect(chrome$('html')[0].dir).to.be('rtl'); @@ -100,7 +102,7 @@ describe('Language select and change', function () { }); it('changes direction when picking an ltr lang', function (done) { - const inner$ = helper.padInner$; + this.timeout(200); const chrome$ = helper.padChrome$; // click on the settings button to make settings visible @@ -117,7 +119,7 @@ describe('Language select and change', function () { $language.val('en'); $languageoption.change(); - helper.waitFor(() => chrome$('html')[0].dir != 'rtl') + helper.waitFor(() => chrome$('html')[0].dir !== 'rtl') .done(() => { // check if the document's direction was changed expect(chrome$('html')[0].dir).to.be('ltr'); diff --git a/tests/frontend/specs/multiple_authors_clear_authorship_colors.js b/tests/frontend/specs/multiple_authors_clear_authorship_colors.js index f532ea4be..e658ff19f 100755 --- a/tests/frontend/specs/multiple_authors_clear_authorship_colors.js +++ b/tests/frontend/specs/multiple_authors_clear_authorship_colors.js @@ -1,7 +1,9 @@ +'use strict'; + 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(); $firstLine.html('Hello World'); @@ -13,7 +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 - helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; + const cookieVal = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; + helper.padChrome$.document.cookie = cookieVal; helper.newPad(done, padId); }, 1000); @@ -22,12 +25,7 @@ describe('author of pad edition', function () { this.timeout(60000); }); - // author 2 makes some changes on the pad - it('Clears Authorship by second user', function (done) { - clearAuthorship(done); - }); - - var clearAuthorship = function (done) { + const clearAuthorship = function (done) { const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -46,4 +44,10 @@ describe('author of pad edition', function () { expect(hasAuthorClass).to.be(false); done(); }; + + // author 2 makes some changes on the pad + it('Clears Authorship by second user', function (done) { + this.timeout(100); + clearAuthorship(done); + }); }); diff --git a/tests/frontend/specs/ordered_list.js b/tests/frontend/specs/ordered_list.js index a932335e8..c900235e3 100644 --- a/tests/frontend/specs/ordered_list.js +++ b/tests/frontend/specs/ordered_list.js @@ -1,3 +1,5 @@ +'use strict'; + describe('assign ordered list', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,6 +8,7 @@ describe('assign ordered list', function () { }); it('inserts ordered list text', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -23,6 +26,7 @@ describe('assign ordered list', function () { }); it('inserts unordered list', function (done) { + this.timeout(50); helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done); }); }); @@ -34,6 +38,7 @@ 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(() => { expect().fail(() => 'Unordered list inserted, should ignore shortcut'); }).fail(() => { @@ -51,6 +56,7 @@ describe('assign ordered list', function () { }); it('inserts unordered list', function (done) { + this.timeout(100); helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done); }); }); @@ -62,6 +68,7 @@ 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(() => { expect().fail(() => 'Unordered list inserted, should ignore shortcut'); }).fail(() => { @@ -91,12 +98,13 @@ describe('assign ordered list', function () { expect(hasOLElement).to.be(true); expect($newSecondLine.text()).to.be('line 2'); const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2; - expect(hasLineNumber).to.be(true); // This doesn't work because pasting in content doesn't work + // This doesn't work because pasting in content doesn't work + expect(hasLineNumber).to.be(true); done(); }); }); - var triggerCtrlShiftShortcut = function (shortcutChar) { + const triggerCtrlShiftShortcut = function (shortcutChar) { const inner$ = helper.padInner$; const e = inner$.Event(helper.evtType); e.ctrlKey = true; @@ -105,10 +113,10 @@ describe('assign ordered list', function () { inner$('#innerdocbody').trigger(e); }; - var makeSureShortcutIsDisabled = function (shortcut) { + const makeSureShortcutIsDisabled = function (shortcut) { helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false; }; - var makeSureShortcutIsEnabled = function (shortcut) { + const makeSureShortcutIsEnabled = function (shortcut) { helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true; }; }); @@ -121,6 +129,7 @@ describe('Pressing Tab in an OL increases and decreases indentation', function ( }); it('indent and de-indent list item with keypress', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -155,6 +164,7 @@ describe('Pressing indent/outdent button in an OL increases and decreases indent }); it('indent and de-indent list item with indent button', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; diff --git a/tests/frontend/specs/pad_modal.js b/tests/frontend/specs/pad_modal.js index 1711e38b8..39c41a447 100644 --- a/tests/frontend/specs/pad_modal.js +++ b/tests/frontend/specs/pad_modal.js @@ -1,3 +1,5 @@ +'use strict'; + describe('Pad modal', function () { context('when modal is a "force reconnect" message', function () { const MODAL_SELECTOR = '#connectivity'; @@ -16,6 +18,7 @@ describe('Pad modal', function () { }); it('disables editor', function (done) { + this.timeout(20); expect(isEditorDisabled()).to.be(true); done(); @@ -27,6 +30,7 @@ describe('Pad modal', function () { }); it('does not close the modal', function (done) { + this.timeout(20); const $modal = helper.padChrome$(MODAL_SELECTOR); const modalIsVisible = $modal.hasClass('popup-show'); @@ -42,6 +46,7 @@ describe('Pad modal', function () { }); it('does not close the modal', function (done) { + this.timeout(20); const $modal = helper.padChrome$(MODAL_SELECTOR); const modalIsVisible = $modal.hasClass('popup-show'); @@ -76,6 +81,7 @@ describe('Pad modal', function () { }); it('closes the modal', function (done) { + this.timeout(20); expect(isModalOpened(MODAL_SELECTOR)).to.be(false); done(); }); @@ -87,23 +93,24 @@ describe('Pad modal', function () { }); it('closes the modal', function (done) { + this.timeout(20); expect(isModalOpened(MODAL_SELECTOR)).to.be(false); done(); }); }); }); - var clickOnPadInner = function () { + const clickOnPadInner = function () { const $editor = helper.padInner$('#innerdocbody'); $editor.click(); }; - var clickOnPadOuter = function () { + const clickOnPadOuter = function () { const $lineNumbersColumn = helper.padOuter$('#sidedivinner'); $lineNumbersColumn.click(); }; - var openSettingsAndWaitForModalToBeVisible = function (done) { + const openSettingsAndWaitForModalToBeVisible = function (done) { helper.padChrome$('.buttonicon-settings').click(); // wait for modal to be displayed @@ -111,7 +118,7 @@ describe('Pad modal', function () { helper.waitFor(() => isModalOpened(modalSelector), 10000).done(done); }; - var isEditorDisabled = function () { + const isEditorDisabled = function () { const editorDocument = helper.padOuter$("iframe[name='ace_inner']").get(0).contentDocument; const editorBody = editorDocument.getElementById('innerdocbody'); @@ -121,7 +128,7 @@ describe('Pad modal', function () { return editorIsDisabled; }; - var isModalOpened = function (modalSelector) { + const isModalOpened = function (modalSelector) { const $modal = helper.padChrome$(modalSelector); return $modal.hasClass('popup-show'); diff --git a/tests/frontend/specs/redo.js b/tests/frontend/specs/redo.js index 58d5b6c12..383f95f38 100644 --- a/tests/frontend/specs/redo.js +++ b/tests/frontend/specs/redo.js @@ -1,3 +1,5 @@ +'use strict'; + describe('undo button then redo button', function () { beforeEach(function (cb) { helper.newPad(cb); // creates a new pad @@ -5,6 +7,7 @@ describe('undo button then redo button', function () { }); it('redo some typing with button', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -32,8 +35,8 @@ describe('undo button then redo button', function () { }); it('redo some typing with keypress', function (done) { + this.timeout(100); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element inside the editable space const $firstTextElement = inner$('div span').first(); @@ -44,12 +47,12 @@ describe('undo button then redo button', function () { const modifiedValue = $firstTextElement.text(); // get the modified value expect(modifiedValue).not.to.be(originalValue); // expect the value to change - var e = inner$.Event(helper.evtType); + let e = inner$.Event(helper.evtType); e.ctrlKey = true; // Control key e.which = 90; // z inner$('#innerdocbody').trigger(e); - var e = inner$.Event(helper.evtType); + e = inner$.Event(helper.evtType); e.ctrlKey = true; // Control key e.which = 121; // y inner$('#innerdocbody').trigger(e); diff --git a/tests/frontend/specs/responsiveness.js b/tests/frontend/specs/responsiveness.js index 63803f641..090826979 100644 --- a/tests/frontend/specs/responsiveness.js +++ b/tests/frontend/specs/responsiveness.js @@ -1,3 +1,5 @@ +'use strict'; + // Test for https://github.com/ether/etherpad-lite/issues/1763 // This test fails in Opera, IE and Safari diff --git a/tests/frontend/specs/scrollTo.js b/tests/frontend/specs/scrollTo.js index 47fe1ca7e..aad644027 100755 --- a/tests/frontend/specs/scrollTo.js +++ b/tests/frontend/specs/scrollTo.js @@ -11,7 +11,7 @@ describe('scrolls to line', function () { }); it('Scrolls down to Line 4', async function () { - this.timeout(10000); + this.timeout(100); const chrome$ = helper.padChrome$; await helper.waitForPromise(() => { const topOffset = parseInt(chrome$('iframe').first('iframe') @@ -32,7 +32,7 @@ describe('doesnt break on weird hash input', function () { }); it('Does NOT change scroll', async function () { - this.timeout(10000); + this.timeout(100); const chrome$ = helper.padChrome$; await helper.waitForPromise(() => { const topOffset = parseInt(chrome$('iframe').first('iframe') diff --git a/tests/frontend/specs/select_formatting_buttons.js b/tests/frontend/specs/select_formatting_buttons.js index 52595a044..666e81449 100644 --- a/tests/frontend/specs/select_formatting_buttons.js +++ b/tests/frontend/specs/select_formatting_buttons.js @@ -1,3 +1,5 @@ +'use strict'; + describe('select formatting buttons when selection has style applied', function () { const STYLES = ['italic', 'bold', 'underline', 'strikethrough']; const SHORTCUT_KEYS = ['I', 'B', 'U', '5']; // italic, bold, underline, strikethrough @@ -21,7 +23,7 @@ describe('select formatting buttons when selection has style applied', function return $formattingButton.parent().hasClass('selected'); }; - var selectLine = function (lineNumber, offsetStart, offsetEnd) { + const selectLine = function (lineNumber, offsetStart, offsetEnd) { const inner$ = helper.padInner$; const $line = inner$('div').eq(lineNumber); helper.selectLines($line, $line, offsetStart, offsetEnd); @@ -40,12 +42,14 @@ describe('select formatting buttons when selection has style applied', function const testIfFormattingButtonIsDeselected = function (style) { it(`deselects the ${style} button`, function (done) { + this.timeout(50); helper.waitFor(() => isButtonSelected(style) === false).done(done); }); }; const testIfFormattingButtonIsSelected = function (style) { it(`selects the ${style} button`, function (done) { + this.timeout(50); helper.waitFor(() => isButtonSelected(style)).done(done); }); }; @@ -58,7 +62,7 @@ describe('select formatting buttons when selection has style applied', function applyStyleOnLineOnFullLineAndRemoveSelection(line, style, placeCaretOnLine, cb); }; - var applyStyleOnLineOnFullLineAndRemoveSelection = function (line, style, selectTarget, cb) { + const applyStyleOnLineOnFullLineAndRemoveSelection = function (line, style, selectTarget, cb) { // see if line html has changed const inner$ = helper.padInner$; const oldLineHTML = inner$.find('div')[line]; @@ -80,7 +84,6 @@ describe('select formatting buttons when selection has style applied', function const pressFormattingShortcutOnSelection = function (key) { const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element out of the inner iframe const $firstTextElement = inner$('div').first(); @@ -134,6 +137,7 @@ describe('select formatting buttons when selection has style applied', function }); it('selects the style button', function (done) { + this.timeout(50); expect(isButtonSelected(style)).to.be(true); done(); }); diff --git a/tests/frontend/specs/strikethrough.js b/tests/frontend/specs/strikethrough.js index d8feae3be..bb477e01a 100644 --- a/tests/frontend/specs/strikethrough.js +++ b/tests/frontend/specs/strikethrough.js @@ -1,3 +1,5 @@ +'use strict'; + describe('strikethrough button', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,6 +8,7 @@ describe('strikethrough button', function () { }); it('makes text strikethrough', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -19,7 +22,8 @@ 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 + // 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 bea7932df..401a71758 100644 --- a/tests/frontend/specs/timeslider.js +++ b/tests/frontend/specs/timeslider.js @@ -1,3 +1,5 @@ +'use strict'; + // deactivated, we need a nice way to get the timeslider, this is ugly xdescribe('timeslider button takes you to the timeslider of a pad', function () { beforeEach(function (cb) { diff --git a/tests/frontend/specs/timeslider_follow.js b/tests/frontend/specs/timeslider_follow.js index 9f86ddc77..9324c8344 100644 --- a/tests/frontend/specs/timeslider_follow.js +++ b/tests/frontend/specs/timeslider_follow.js @@ -9,6 +9,7 @@ describe('timeslider follow', function () { // TODO needs test if content is also followed, when user a makes edits // while user b is in the timeslider it("content as it's added to timeslider", async function () { + this.timeout(0); // JM TO DO // send 6 revisions const revs = 6; const message = 'a\n\n\n\n\n\n\n\n\n\n'; diff --git a/tests/frontend/specs/timeslider_labels.js b/tests/frontend/specs/timeslider_labels.js index c7a4aca5a..72a24256b 100644 --- a/tests/frontend/specs/timeslider_labels.js +++ b/tests/frontend/specs/timeslider_labels.js @@ -1,3 +1,5 @@ +'use strict'; + describe('timeslider', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -7,7 +9,8 @@ describe('timeslider', function () { /** * @todo test authorsList */ - it("Shows a date and time in the timeslider and make sure it doesn't include NaN", async function () { + 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_numeric_padID.js b/tests/frontend/specs/timeslider_numeric_padID.js index 53eb4a29c..0fca6b027 100644 --- a/tests/frontend/specs/timeslider_numeric_padID.js +++ b/tests/frontend/specs/timeslider_numeric_padID.js @@ -1,3 +1,5 @@ +'use strict'; + describe('timeslider', function () { const padId = 735773577357 + (Math.round(Math.random() * 1000)); @@ -7,6 +9,8 @@ describe('timeslider', function () { }); it('Makes sure the export URIs are as expected when the padID is numeric', async function () { + this.timeout(6000); + await helper.edit('a\n'); await helper.gotoTimeslider(1); diff --git a/tests/frontend/specs/timeslider_revisions.js b/tests/frontend/specs/timeslider_revisions.js index fbfbb3615..de3c52a6f 100644 --- a/tests/frontend/specs/timeslider_revisions.js +++ b/tests/frontend/specs/timeslider_revisions.js @@ -1,3 +1,5 @@ +'use strict'; + describe('timeslider', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -5,7 +7,8 @@ describe('timeslider', function () { this.timeout(60000); }); - it('loads adds a hundred revisions', function (done) { // passes + it('loads adds a hundred revisions', function (done) { + this.timeout(100000); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -23,7 +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.$; @@ -66,7 +70,6 @@ describe('timeslider', function () { // Disabled as jquery trigger no longer works properly xit('changes the url when clicking on the timeslider', function (done) { const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // make some changes to produce 7 revisions const timePerRev = 1000; @@ -81,13 +84,13 @@ 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.$; const $sliderBar = timeslider$('#ui-slider-bar'); - const latestContents = timeslider$('#innerdocbody').text(); const oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash; // Click somewhere on the timeslider @@ -96,20 +99,22 @@ describe('timeslider', function () { e.clientY = e.pageY = 60; $sliderBar.trigger(e); - helper.waitFor(() => $('#iframe-container iframe')[0].contentWindow.location.hash != oldUrl, 6000).always(() => { - expect($('#iframe-container iframe')[0].contentWindow.location.hash).not.to.eql(oldUrl); - done(); - }); + helper.waitFor( + () => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000) + .always(() => { + 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); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; - this.timeout(40000); // wait for the text to be loaded - helper.waitFor(() => inner$('body').text().length != 0, 10000).always(() => { + helper.waitFor(() => inner$('body').text().length !== 0, 10000).always(() => { const newLines = inner$('body div').length; const oldLength = inner$('body').text().length + newLines / 2; expect(oldLength).to.not.eql(0); @@ -120,22 +125,25 @@ describe('timeslider', function () { helper.waitFor(() => { // newLines takes the new lines into account which are strippen when using // inner$('body').text(), one
    is used for one line in ACE. - const lenOkay = inner$('body').text().length + newLines / 2 != oldLength; + const lenOkay = inner$('body').text().length + newLines / 2 !== oldLength; // this waits for the color to be added to our , which means that the revision // was accepted by the server. - const colorOkay = inner$('span').first().attr('class').indexOf('author-') == 0; + const colorOkay = inner$('span').first().attr('class').indexOf('author-') === 0; 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) {} + } catch (e) { + // silently fart. Deadly. + } if (timeslider$) { - return timeslider$('#innerdocbody').text().length == oldLength; + return timeslider$('#innerdocbody').text().length === oldLength; } }, 10000).always(() => { expect(timeslider$('#innerdocbody').text().length).to.eql(oldLength); @@ -146,25 +154,28 @@ describe('timeslider', function () { }); it('checks the export url', function (done) { + this.timeout(6000); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; this.timeout(11000); inner$('div').first().sendkeys('a'); 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; helper.waitFor(() => { try { timeslider$ = $('#iframe-container iframe')[0].contentWindow.$; - } catch (e) {} + } catch (e) { + // silently give up on life. + } if (!timeslider$) return false; exportLink = timeslider$('#exportplaina').attr('href'); if (!exportLink) return false; - return exportLink.substr(exportLink.length - 12) == '0/export/txt'; + return exportLink.substr(exportLink.length - 12) === '0/export/txt'; }, 6000).always(() => { expect(exportLink.substr(exportLink.length - 12)).to.eql('0/export/txt'); done(); diff --git a/tests/frontend/specs/undo.js b/tests/frontend/specs/undo.js index 0c94f2230..762f50d62 100644 --- a/tests/frontend/specs/undo.js +++ b/tests/frontend/specs/undo.js @@ -1,3 +1,5 @@ +'use strict'; + describe('undo button', function () { beforeEach(function (cb) { helper.newPad(cb); // creates a new pad @@ -5,6 +7,7 @@ describe('undo button', function () { }); it('undo some typing by clicking undo button', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -29,8 +32,8 @@ describe('undo button', function () { }); it('undo some typing using a keypress', function (done) { + this.timeout(100); const inner$ = helper.padInner$; - const chrome$ = helper.padChrome$; // get the first text element inside the editable space const $firstTextElement = inner$('div span').first(); diff --git a/tests/frontend/specs/unordered_list.js b/tests/frontend/specs/unordered_list.js index 4cbdabfac..af13af2b2 100644 --- a/tests/frontend/specs/unordered_list.js +++ b/tests/frontend/specs/unordered_list.js @@ -1,3 +1,5 @@ +'use strict'; + describe('assign unordered list', function () { // create a new pad before each test run beforeEach(function (cb) { @@ -6,6 +8,7 @@ describe('assign unordered list', function () { }); it('insert unordered list text then removes by outdent', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; const originalText = inner$('div').first().text(); @@ -32,6 +35,7 @@ describe('assign unordered list', function () { }); describe('unassign unordered list', function () { + this.timeout(100); // create a new pad before each test run beforeEach(function (cb) { helper.newPad(cb); @@ -39,6 +43,7 @@ describe('unassign unordered list', function () { }); it('insert unordered list text then remove by clicking list again', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; const originalText = inner$('div').first().text(); @@ -74,6 +79,7 @@ describe('keep unordered list on enter key', function () { }); it('Keeps the unordered list on enter for the new line', function (done) { + this.timeout(1000); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -98,6 +104,7 @@ describe('keep unordered list on enter key', function () { }); describe('Pressing Tab in an UL increases and decreases indentation', function () { + this.timeout(100); // create a new pad before each test run beforeEach(function (cb) { helper.newPad(cb); @@ -105,6 +112,7 @@ describe('Pressing Tab in an UL increases and decreases indentation', function ( }); it('indent and de-indent list item with keypress', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -138,6 +146,7 @@ describe('Pressing indent/outdent button in an UL increases and decreases indent }); it('indent and de-indent list item with indent button', function (done) { + this.timeout(100); const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; diff --git a/tests/frontend/specs/urls_become_clickable.js b/tests/frontend/specs/urls_become_clickable.js index a027de9ff..2aed8e476 100644 --- a/tests/frontend/specs/urls_become_clickable.js +++ b/tests/frontend/specs/urls_become_clickable.js @@ -20,6 +20,7 @@ describe('urls', function () { describe('entering a URL makes a link', function () { for (const url of ['https://etherpad.org', 'www.etherpad.org']) { it(url, async function () { + this.timeout(5000); const url = 'https://etherpad.org'; await helper.edit(url); await helper.waitForPromise(() => txt().find('a').length === 1, 2000); @@ -34,6 +35,7 @@ describe('urls', function () { for (const char of '-:@_.,~%+/?=&#!;()$\'*') { const url = `https://etherpad.org/${char}foo`; it(url, async function () { + this.timeout(5000); await helper.edit(url); await helper.waitForPromise(() => txt().find('a').length === 1); const link = txt().find('a'); @@ -48,6 +50,7 @@ describe('urls', function () { const want = 'https://etherpad.org'; const input = want + char; it(input, async function () { + this.timeout(5000); await helper.edit(input); await helper.waitForPromise(() => txt().find('a').length === 1); const link = txt().find('a'); diff --git a/tests/frontend/specs/xxauto_reconnect.js b/tests/frontend/specs/xxauto_reconnect.js index 574616ce5..1c16d647e 100644 --- a/tests/frontend/specs/xxauto_reconnect.js +++ b/tests/frontend/specs/xxauto_reconnect.js @@ -1,3 +1,5 @@ +'use strict'; + describe('Automatic pad reload on Force Reconnect message', function () { let padId, $originalPadFrame; @@ -59,9 +61,8 @@ describe('Automatic pad reload on Force Reconnect message', function () { }); it('reloads the pad', function (done) { - helper.waitFor(() => padWasReloaded, 5000).done(done); - this.timeout(5000); + helper.waitFor(() => padWasReloaded, 5000).done(done); }); }); });