mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
tests: Promisify multiple_authors_clear_authorship_colors.js
This commit is contained in:
parent
8b43f9eb5f
commit
701a40ac13
1 changed files with 21 additions and 26 deletions
|
@ -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();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue