diff --git a/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js b/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js index 818dd161..b7cea554 100755 --- a/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js +++ b/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js @@ -2,36 +2,32 @@ describe('author of pad edition', function () { // author 1 creates a new pad with some content (regular lines and lists) - before(function (done) { - const padId = helper.newPad(() => { - // make sure pad has at least 3 lines - const $firstLine = helper.padInner$('div').first(); - $firstLine.html('Hello World'); - - // wait for lines to be processed by Etherpad - helper.waitFor(() => $firstLine.text() === 'Hello World').done(() => { - // Reload pad, to make changes as a second user. Need a timeout here to make sure - // all changes were saved before reloading - 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.newPad(done, padId); - }, 1000); - }); - }); + before(async function () { this.timeout(60000); + const padId = await helper.aNewPad(); + + // make sure pad has at least 3 lines + const $firstLine = helper.padInner$('div').first(); + $firstLine.html('Hello World'); + + // wait for lines to be processed by Etherpad + await helper.waitForPromise(() => $firstLine.text() === 'Hello World'); + + // Need a timeout here to make sure all changes were saved. + await new Promise((resolve) => setTimeout(resolve, 1000)); + + // 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=/'; + + // Reload pad, to make changes as a second user. + await helper.aNewPad({id: padId}); }); // author 2 makes some changes on the pad - it('Clears Authorship by second user', function (done) { + it('Clears Authorship by second user', async function () { this.timeout(100); - clearAuthorship(done); - }); - const clearAuthorship = (done) => { const inner$ = helper.padInner$; const chrome$ = helper.padChrome$; @@ -48,6 +44,5 @@ describe('author of pad edition', function () { const hasAuthorClass = inner$('div span').first().attr('class').indexOf('author') !== -1; expect(hasAuthorClass).to.be(false); - done(); - }; + }); });