From 17a1d02af83836d8964100ea6bbd8562ae649a04 Mon Sep 17 00:00:00 2001 From: gnuxie Date: Tue, 25 Jan 2022 17:55:02 +0000 Subject: [PATCH] Fix uses of old interface for registration helper in tests. --- test/integration/fixtures.ts | 2 ++ test/integration/policyConsumptionTest.ts | 10 +++++----- test/integration/protectionSettingsTest.ts | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/integration/fixtures.ts b/test/integration/fixtures.ts index 4eaf155..416926d 100644 --- a/test/integration/fixtures.ts +++ b/test/integration/fixtures.ts @@ -10,6 +10,8 @@ export const mochaHooks = { beforeEach: [ async function() { console.log("mochaHooks.beforeEach"); + // Sometimes it takes a little longer to register users. + this.timeout(3000) this.managementRoomAlias = config.managementRoom; this.mjolnir = await makeMjolnir(); config.RUNTIME.client = this.mjolnir.client; diff --git a/test/integration/policyConsumptionTest.ts b/test/integration/policyConsumptionTest.ts index de6d796..fd343ad 100644 --- a/test/integration/policyConsumptionTest.ts +++ b/test/integration/policyConsumptionTest.ts @@ -70,11 +70,11 @@ describe("Test: that policy lists are consumed by the associated synapse module" it('blocks users in antispam when they are banned from sending messages and invites serverwide.', async function() { this.timeout(20000); // Create a few users and a room. - let badUser = await newTestUser(false, "spammer"); + let badUser = await newTestUser({ name: { contains: "spammer" }}); let badUserId = await badUser.getUserId(); const mjolnir = config.RUNTIME.client! let mjolnirUserId = await mjolnir.getUserId(); - let moderator = await newTestUser(false, "moderator"); + let moderator = await newTestUser({ name: { contains: "moderator" }}); this.moderator = moderator; await moderator.joinRoom(this.mjolnir.managementRoomId); let unprotectedRoom = await badUser.createRoom({ invite: [await moderator.getUserId()]}); @@ -105,9 +105,9 @@ describe("Test: that policy lists are consumed by the associated synapse module" }) it('Test: Cannot send message to a room that is listed in a policy list and cannot invite a user to the room either', async function () { this.timeout(20000); - let badUser = await newTestUser(false, "spammer"); + let badUser = await newTestUser({ name: { contains: "spammer" }}); const mjolnir = config.RUNTIME.client! - let moderator = await newTestUser(false, "moderator"); + let moderator = await newTestUser({ name: { contains: "moderator" }}); await moderator.joinRoom(this.mjolnir.managementRoomId); const banList = await createBanList(this.mjolnir.managementRoomId, mjolnir, moderator); let badRoom = await badUser.createRoom(); @@ -135,7 +135,7 @@ describe("Test: that policy lists are consumed by the associated synapse module" it('Test: When a list becomes unwatched, the associated policies are stopped.', async function () { this.timeout(20000); const mjolnir = config.RUNTIME.client! - let moderator = await newTestUser(false, "moderator"); + let moderator = await newTestUser({ name: { contains: "moderator" }}); await moderator.joinRoom(this.mjolnir.managementRoomId); const banList = await createBanList(this.mjolnir.managementRoomId, mjolnir, moderator); let targetRoom = await moderator.createRoom(); diff --git a/test/integration/protectionSettingsTest.ts b/test/integration/protectionSettingsTest.ts index 3b84511..f1cff54 100644 --- a/test/integration/protectionSettingsTest.ts +++ b/test/integration/protectionSettingsTest.ts @@ -1,6 +1,8 @@ import { strict as assert } from "assert"; import config from "../../src/config"; +import { Mjolnir } from "../../src/Mjolnir"; +import { IProtection } from "../../src/protections/IProtection"; import { PROTECTIONS } from "../../src/protections/protections"; import { ProtectionSettingValidationError } from "../../src/protections/ProtectionSettings"; import { NumberProtectionSetting, StringProtectionSetting, StringListProtectionSetting } from "../../src/protections/ProtectionSettings"; @@ -10,7 +12,7 @@ import { matrixClient, mjolnir } from "./mjolnirSetupUtils"; describe("Test: Protection settings", function() { let client; this.beforeEach(async function () { - client = await newTestUser(true); + client = await newTestUser({ name: { contains: "protection-settings" }}); await client.start(); }) this.afterEach(async function () {