mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-06-15 10:44:41 -04:00
fix: express5
This commit is contained in:
parent
6208a04556
commit
6db14baee7
26 changed files with 200 additions and 207 deletions
|
@ -12,7 +12,7 @@ describe(__filename, function () {
|
|||
|
||||
beforeEach(async function () {
|
||||
padId = common.randomString();
|
||||
assert(!await padManager.doesPadExist(padId));
|
||||
assert(!(await padManager.doesPadExist(padId)));
|
||||
});
|
||||
|
||||
describe('exportEtherpadAdditionalContent', function () {
|
||||
|
|
|
@ -53,7 +53,7 @@ describe(__filename, function () {
|
|||
|
||||
beforeEach(async function () {
|
||||
padId = randomString(10);
|
||||
assert(!await padManager.doesPadExist(padId));
|
||||
assert(!(await padManager.doesPadExist(padId)));
|
||||
});
|
||||
|
||||
it('unknown db records are ignored', async function () {
|
||||
|
@ -62,7 +62,7 @@ describe(__filename, function () {
|
|||
[badKey]: 'value',
|
||||
...makeExport(makeAuthorId()),
|
||||
}));
|
||||
assert(await db.get(badKey) == null);
|
||||
assert((await db.get(badKey)) == null);
|
||||
});
|
||||
|
||||
it('changes are all or nothing', async function () {
|
||||
|
@ -71,8 +71,8 @@ describe(__filename, function () {
|
|||
data['pad:differentPadId:revs:0'] = data['pad:testing:revs:0'];
|
||||
delete data['pad:testing:revs:0'];
|
||||
assert.rejects(importEtherpad.setPadRaw(padId, JSON.stringify(data)), /unexpected pad ID/);
|
||||
assert(!await authorManager.doesAuthorExist(authorId));
|
||||
assert(!await padManager.doesPadExist(padId));
|
||||
assert(!(await authorManager.doesAuthorExist(authorId)));
|
||||
assert(!(await padManager.doesPadExist(padId)));
|
||||
});
|
||||
|
||||
describe('author pad IDs', function () {
|
||||
|
@ -85,7 +85,7 @@ describe(__filename, function () {
|
|||
assert.deepEqual((await authorManager.listPadsOfAuthor(existingAuthorId)).padIDs, []);
|
||||
newAuthorId = makeAuthorId();
|
||||
assert.notEqual(newAuthorId, existingAuthorId);
|
||||
assert(!await authorManager.doesAuthorExist(newAuthorId));
|
||||
assert(!(await authorManager.doesAuthorExist(newAuthorId)));
|
||||
});
|
||||
|
||||
it('author does not yet exist', async function () {
|
||||
|
@ -199,12 +199,12 @@ describe(__filename, function () {
|
|||
...makeExport(makeAuthorId()),
|
||||
'custom:testingx': 'x',
|
||||
})), /unexpected pad ID/);
|
||||
assert(await db.get(`custom:${padId}x`) == null);
|
||||
assert((await db.get(`custom:${padId}x`)) == null);
|
||||
await assert.rejects(importEtherpad.setPadRaw(padId, JSON.stringify({
|
||||
...makeExport(makeAuthorId()),
|
||||
'custom:testingx:foo': 'x',
|
||||
})), /unexpected pad ID/);
|
||||
assert(await db.get(`custom:${padId}x:foo`) == null);
|
||||
assert((await db.get(`custom:${padId}x:foo`)) == null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -44,7 +44,7 @@ describe(__filename, function () {
|
|||
describe('set', function () {
|
||||
it('set of null is a no-op', async function () {
|
||||
await set(null);
|
||||
assert(await db.get(`sessionstorage:${sid}`) == null);
|
||||
assert((await db.get(`sessionstorage:${sid}`)) == null);
|
||||
});
|
||||
|
||||
it('set of non-expiring session', async function () {
|
||||
|
@ -59,14 +59,14 @@ describe(__filename, function () {
|
|||
assert.equal(JSON.stringify(await db.get(`sessionstorage:${sid}`)), JSON.stringify(sess));
|
||||
await new Promise((resolve) => setTimeout(resolve, 110));
|
||||
// Writing should start a timeout.
|
||||
assert(await db.get(`sessionstorage:${sid}`) == null);
|
||||
assert((await db.get(`sessionstorage:${sid}`)) == null);
|
||||
});
|
||||
|
||||
it('set of already expired session', async function () {
|
||||
const sess:any = {foo: 'bar', cookie: {expires: new Date(1)}};
|
||||
await set(sess);
|
||||
// No record should have been created.
|
||||
assert(await db.get(`sessionstorage:${sid}`) == null);
|
||||
assert((await db.get(`sessionstorage:${sid}`)) == null);
|
||||
});
|
||||
|
||||
it('switch from non-expiring to expiring', async function () {
|
||||
|
@ -75,7 +75,7 @@ describe(__filename, function () {
|
|||
const sess2:any = {foo: 'bar', cookie: {expires: new Date(Date.now() + 100)}};
|
||||
await set(sess2);
|
||||
await new Promise((resolve) => setTimeout(resolve, 110));
|
||||
assert(await db.get(`sessionstorage:${sid}`) == null);
|
||||
assert((await db.get(`sessionstorage:${sid}`)) == null);
|
||||
});
|
||||
|
||||
it('switch from expiring to non-expiring', async function () {
|
||||
|
@ -90,7 +90,7 @@ describe(__filename, function () {
|
|||
|
||||
describe('get', function () {
|
||||
it('get of non-existent entry', async function () {
|
||||
assert(await get() == null);
|
||||
assert((await get()) == null);
|
||||
});
|
||||
|
||||
it('set+get round trip', async function () {
|
||||
|
@ -111,14 +111,14 @@ describe(__filename, function () {
|
|||
assert.equal(JSON.stringify(await get()), JSON.stringify(sess));
|
||||
await new Promise((resolve) => setTimeout(resolve, 110));
|
||||
// Reading should start a timeout.
|
||||
assert(await db.get(`sessionstorage:${sid}`) == null);
|
||||
assert((await db.get(`sessionstorage:${sid}`)) == null);
|
||||
});
|
||||
|
||||
it('get of record from previous run (already expired)', async function () {
|
||||
const sess = {foo: 'bar', cookie: {expires: new Date(1)}};
|
||||
await db.set(`sessionstorage:${sid}`, sess);
|
||||
assert(await get() == null);
|
||||
assert(await db.get(`sessionstorage:${sid}`) == null);
|
||||
assert((await get()) == null);
|
||||
assert((await db.get(`sessionstorage:${sid}`)) == null);
|
||||
});
|
||||
|
||||
it('external expiration update is picked up', async function () {
|
||||
|
@ -151,7 +151,7 @@ describe(__filename, function () {
|
|||
const sess:any = {cookie: {expires: new Date(Date.now() + 100)}};
|
||||
await set(sess);
|
||||
await destroy();
|
||||
assert(await db.get(`sessionstorage:${sid}`) == null);
|
||||
assert((await db.get(`sessionstorage:${sid}`)) == null);
|
||||
});
|
||||
|
||||
it('destroy cancels the timeout', async function () {
|
||||
|
|
|
@ -131,7 +131,7 @@ describe(__filename, function () {
|
|||
.expect((res:any) => {
|
||||
assert.equal(res.body.code, 0);
|
||||
});
|
||||
assert(await db.get(`mapper2group:${mapper}`) == null);
|
||||
assert((await db.get(`mapper2group:${mapper}`)) == null);
|
||||
});
|
||||
|
||||
// Test coverage for https://github.com/ether/etherpad-lite/issues/4227
|
||||
|
|
|
@ -27,7 +27,7 @@ describe(__filename, function () {
|
|||
backups.hooks = {handleMessageSecurity: plugins.hooks.handleMessageSecurity};
|
||||
plugins.hooks.handleMessageSecurity = [];
|
||||
padId = common.randomString();
|
||||
assert(!await padManager.doesPadExist(padId));
|
||||
assert(!(await padManager.doesPadExist(padId)));
|
||||
pad = await padManager.getPad(padId, 'dummy text\n');
|
||||
await pad!.setText('\n'); // Make sure the pad is created.
|
||||
assert.equal(pad!.text(), '\n');
|
||||
|
@ -57,7 +57,7 @@ describe(__filename, function () {
|
|||
describe('CHANGESET_REQ', function () {
|
||||
it('users are unable to read changesets from other pads', async function () {
|
||||
const otherPadId = `${padId}other`;
|
||||
assert(!await padManager.doesPadExist(otherPadId));
|
||||
assert(!(await padManager.doesPadExist(otherPadId)));
|
||||
const otherPad = await padManager.getPad(otherPadId, 'other text\n');
|
||||
try {
|
||||
await otherPad.setText('other text\n');
|
||||
|
@ -84,7 +84,7 @@ describe(__filename, function () {
|
|||
|
||||
it('CHANGESET_REQ: verify revNum is a number (regression)', async function () {
|
||||
const otherPadId = `${padId}other`;
|
||||
assert(!await padManager.doesPadExist(otherPadId));
|
||||
assert(!(await padManager.doesPadExist(otherPadId)));
|
||||
const otherPad = await padManager.getPad(otherPadId, 'other text\n');
|
||||
let errorCatched = 0;
|
||||
try {
|
||||
|
@ -113,7 +113,7 @@ describe(__filename, function () {
|
|||
|
||||
it('CHANGESET_REQ: revNum is converted to number if possible (regression)', async function () {
|
||||
const otherPadId = `${padId}other`;
|
||||
assert(!await padManager.doesPadExist(otherPadId));
|
||||
assert(!(await padManager.doesPadExist(otherPadId)));
|
||||
const otherPad = await padManager.getPad(otherPadId, 'other text\n');
|
||||
try {
|
||||
await otherPad.setText('other text\n');
|
||||
|
@ -140,7 +140,7 @@ describe(__filename, function () {
|
|||
|
||||
it('CHANGESET_REQ: revNum 2 is converted to head rev 1 (regression)', async function () {
|
||||
const otherPadId = `${padId}other`;
|
||||
assert(!await padManager.doesPadExist(otherPadId));
|
||||
assert(!(await padManager.doesPadExist(otherPadId)));
|
||||
const otherPad = await padManager.getPad(otherPadId, 'other text\n');
|
||||
try {
|
||||
await otherPad.setText('other text\n');
|
||||
|
|
|
@ -358,7 +358,7 @@ describe(__filename, function () {
|
|||
const connected = new Promise((resolve) => resolveConnected = resolve);
|
||||
let resolveDisconnected: (value: void | PromiseLike<void>) => void ;
|
||||
const disconnected = new Promise<void>((resolve) => resolveDisconnected = resolve);
|
||||
socketIoRouter.addComponent(this.test!.fullTitle(), new class extends Module {
|
||||
socketIoRouter.addComponent(this.test!.fullTitle(), new (class extends Module {
|
||||
private _socket: any;
|
||||
handleConnect(socket:any) {
|
||||
this._socket = socket;
|
||||
|
@ -371,7 +371,7 @@ describe(__filename, function () {
|
|||
assert.equal(socket, this._socket);
|
||||
resolveDisconnected();
|
||||
}
|
||||
}());
|
||||
})());
|
||||
socket = await common.connect();
|
||||
await connected;
|
||||
socket.close();
|
||||
|
@ -387,13 +387,13 @@ describe(__filename, function () {
|
|||
};
|
||||
let rx:Function;
|
||||
const got = new Promise((resolve) => { rx = resolve; });
|
||||
socketIoRouter.addComponent(this.test!.fullTitle(), new class extends Module {
|
||||
socketIoRouter.addComponent(this.test!.fullTitle(), new (class extends Module {
|
||||
handleConnect(socket:any) { serverSocket = socket; }
|
||||
handleMessage(socket:any, message:string) { assert.equal(socket, serverSocket); rx(message); }
|
||||
}());
|
||||
socketIoRouter.addComponent(`${this.test!.fullTitle()} #2`, new class extends Module {
|
||||
})());
|
||||
socketIoRouter.addComponent(`${this.test!.fullTitle()} #2`, new (class extends Module {
|
||||
handleMessage(socket:any, message:any) { assert.fail('wrong handler called'); }
|
||||
}());
|
||||
})());
|
||||
socket = await common.connect();
|
||||
socket.emit('message', want);
|
||||
assert.deepEqual(await got, want);
|
||||
|
|
|
@ -85,7 +85,7 @@ export const isChatBoxSticky = async (page: Page):Promise<boolean> => {
|
|||
}
|
||||
|
||||
export const hideChat = async (page: Page) => {
|
||||
if(!await isChatBoxShown(page)|| await isChatBoxSticky(page)) return
|
||||
if(!(await isChatBoxShown(page))|| (await isChatBoxSticky(page))) return
|
||||
await page.locator('#titlecross').click()
|
||||
await page.waitForFunction(`!document.querySelector('#chatbox').classList.contains('stickyChat')`)
|
||||
|
||||
|
@ -98,7 +98,7 @@ export const enableStickyChatviaIcon = async (page: Page) => {
|
|||
}
|
||||
|
||||
export const disableStickyChatviaIcon = async (page: Page) => {
|
||||
if(!await isChatBoxSticky(page)) return
|
||||
if(!(await isChatBoxSticky(page))) return
|
||||
await page.locator('#titlecross').click()
|
||||
await page.waitForFunction(`!document.querySelector('#chatbox').classList.contains('stickyChat')`)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export const showSettings = async (page: Page) => {
|
|||
}
|
||||
|
||||
export const hideSettings = async (page: Page) => {
|
||||
if(!await isSettingsShown(page)) return
|
||||
if(!(await isSettingsShown(page))) return
|
||||
await page.locator("button[data-l10n-id='pad.toolbar.settings.title']").click()
|
||||
await page.waitForFunction(`!document.querySelector('#settings').classList.contains('popup-show')`)
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ const helper = {};
|
|||
|
||||
const check = async () => {
|
||||
try {
|
||||
if (!await conditionFunc()) return;
|
||||
if (!(await conditionFunc())) return;
|
||||
deferred.resolve();
|
||||
} catch (err) {
|
||||
deferred.reject(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue