tests: Promisify multiple_authors_clear_authorship_colors.js

This commit is contained in:
Richard Hansen 2021-03-31 03:35:31 -04:00 committed by webzwo0i
parent 8b43f9eb5f
commit 701a40ac13

View file

@ -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(() => {
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
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(() => {
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=/';
helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
helper.newPad(done, padId);
}, 1000);
});
});
this.timeout(60000);
// 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();
};
});
});