diff --git a/test/integration/clientHelper.ts b/test/integration/clientHelper.ts index cbe032c..bf6902f 100644 --- a/test/integration/clientHelper.ts +++ b/test/integration/clientHelper.ts @@ -90,7 +90,7 @@ async function registerNewTestUser(options: RegistrationOptions) { username = `mjolnir-test-user-${options.name.contains}${Math.floor(Math.random() * 100000)}` } try { - await registerUser(username, username, username, options.isAdmin); + await registerUser(username, username, username, Boolean(options.isAdmin)); return username; } catch (e) { if (e?.body?.errcode === 'M_USER_IN_USE') { diff --git a/test/integration/commands/commandUtils.ts b/test/integration/commands/commandUtils.ts index 4c3a89d..4b4fab6 100644 --- a/test/integration/commands/commandUtils.ts +++ b/test/integration/commands/commandUtils.ts @@ -23,7 +23,7 @@ import * as crypto from "crypto"; const targetEventId = await targetEventThunk(); for (let event of reactionEvents) { const in_reply_to = event.content['m.relates_to']?.['m.in_reply_to']; - if (in_reply_to.event_id === targetEventId) { + if (in_reply_to?.event_id === targetEventId) { return event; } } @@ -70,7 +70,7 @@ export async function getFirstReaction(client: MatrixClient, targetRoom: string, const targetEventId = await targetEventThunk(); for (let event of reactionEvents) { const relates_to = event.content['m.relates_to']; - if (relates_to.event_id === targetEventId && relates_to.key === reactionKey) { + if (relates_to?.event_id === targetEventId && relates_to?.key === reactionKey) { return event; } } @@ -79,7 +79,7 @@ export async function getFirstReaction(client: MatrixClient, targetRoom: string, if (roomId !== targetRoom) return; if (event.type !== 'm.reaction') return; const relates_to = event.content['m.relates_to']; - if (relates_to.event_id === targetEventId && relates_to.key === reactionKey) { + if (relates_to?.event_id === targetEventId && relates_to?.key === reactionKey) { resolve(event) } } diff --git a/test/integration/commands/redactCommandTest.ts b/test/integration/commands/redactCommandTest.ts index 514b18e..1c02cb9 100644 --- a/test/integration/commands/redactCommandTest.ts +++ b/test/integration/commands/redactCommandTest.ts @@ -7,6 +7,9 @@ import { LogService } from "matrix-bot-sdk"; import { getFirstReaction } from "./commandUtils"; describe("Test: The redaction command", function () { + // If a test has a timeout while awaitng on a promise then we never get given control back. + afterEach(function() { this.moderator?.stop(); }); + it('Mjölnir redacts all of the events sent by a spammer when instructed to by giving their id and a room id.', async function() { this.timeout(60000); // Create a few users and a room. @@ -51,6 +54,7 @@ import { getFirstReaction } from "./commandUtils"; }) }); }) + it('Mjölnir redacts all of the events sent by a spammer when instructed to by giving their id in multiple rooms.', async function() { this.timeout(60000); // Create a few users and a room. diff --git a/test/integration/throttleTest.ts b/test/integration/throttleTest.ts index 6d38c62..6c097e9 100644 --- a/test/integration/throttleTest.ts +++ b/test/integration/throttleTest.ts @@ -24,6 +24,9 @@ describe("Test: Mjolnir can still sync and respond to commands while throttled", await resetRatelimitForUser(await this.mjolnir.client.getUserId()) }) afterEach(async function() { + // If a test has a timeout while awaitng on a promise then we never get given control back. + this.moderator?.stop(); + await overrideRatelimitForUser(await this.mjolnir.client.getUserId()); })