Fix uses of old interface for registration helper in tests.

This commit is contained in:
gnuxie 2022-01-25 17:55:02 +00:00
parent 9e96d399c0
commit 17a1d02af8
3 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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 () {