From 2be4267bef1feb755fedf82c32a01647119045dd Mon Sep 17 00:00:00 2001 From: Catalan Lover Date: Mon, 27 Apr 2026 20:54:51 +0200 Subject: [PATCH] Fix Test Linting --- .../src/appservice/AppServiceDraupnirManager.ts | 6 +++++- apps/draupnir/src/protections/TrustedReporters.ts | 15 ++++++--------- .../integration/managedBootstrapStartTest.ts | 13 +++++++++---- .../integration/commands/redactCommandTest.ts | 9 +++++++++ .../test/integration/commands/roomsTest.ts | 3 +++ apps/draupnir/test/integration/fixtures.ts | 4 +++- apps/draupnir/test/integration/helloTest.ts | 3 +++ .../test/integration/mjolnirSetupUtils.ts | 5 ++++- apps/draupnir/test/integration/utilsTest.ts | 3 +++ 9 files changed, 45 insertions(+), 16 deletions(-) diff --git a/apps/draupnir/src/appservice/AppServiceDraupnirManager.ts b/apps/draupnir/src/appservice/AppServiceDraupnirManager.ts index 4e588142..74b9cc1e 100644 --- a/apps/draupnir/src/appservice/AppServiceDraupnirManager.ts +++ b/apps/draupnir/src/appservice/AppServiceDraupnirManager.ts @@ -49,7 +49,11 @@ import { userLocalpart, } from "@the-draupnir-project/matrix-basic-types"; import { TopLevelStores } from "../backingstore/DraupnirStores"; -import { loadOrCreateZeroTouchDeployRoom, ZERO_TOUCH_DEPLOY_ROOM_ACCOUNT_DATA_TYPE, ZeroTouchDeployRoomAccountDataSchema } from "../managedRoomAccountData"; +import { + loadOrCreateZeroTouchDeployRoom, + ZERO_TOUCH_DEPLOY_ROOM_ACCOUNT_DATA_TYPE, + ZeroTouchDeployRoomAccountDataSchema, +} from "../managedRoomAccountData"; const log = new Logger("AppServiceDraupnirManager"); diff --git a/apps/draupnir/src/protections/TrustedReporters.ts b/apps/draupnir/src/protections/TrustedReporters.ts index ef9f1f0a..dfeaf486 100644 --- a/apps/draupnir/src/protections/TrustedReporters.ts +++ b/apps/draupnir/src/protections/TrustedReporters.ts @@ -194,15 +194,12 @@ export class TrustedReporters } if (met.length > 0) { - await this.draupnir.client.sendMessage( - this.draupnir.managementRoomID, - { - msgtype: "m.notice", - body: - `message ${report.event_id} reported by ${[...reporters].join(", ")}. ` + - `actions: ${met.join(", ")}`, - } - ); + await this.draupnir.client.sendMessage(this.draupnir.managementRoomID, { + msgtype: "m.notice", + body: + `message ${report.event_id} reported by ${[...reporters].join(", ")}. ` + + `actions: ${met.join(", ")}`, + }); } return Ok(undefined); } diff --git a/apps/draupnir/test/appservice/integration/managedBootstrapStartTest.ts b/apps/draupnir/test/appservice/integration/managedBootstrapStartTest.ts index 3639236f..1ceb69f1 100644 --- a/apps/draupnir/test/appservice/integration/managedBootstrapStartTest.ts +++ b/apps/draupnir/test/appservice/integration/managedBootstrapStartTest.ts @@ -14,13 +14,18 @@ describe("Managed room bootstrap startup integration", function (this: Mocha.Sui const initialManager = await newTestUser(config.homeserver.url, { name: { contains: "managed-admin" }, }); - config.managedAdminRoom = true; - config.adminRoom = undefined; - config.initialManager = (await initialManager.getUserId()) as StringUserID; + const testConfigRecord = { + ...(config as unknown as Record), + }; + testConfigRecord.managedAdminRoom = true; + testConfigRecord.adminRoom = undefined; + testConfigRecord.initialManager = + (await initialManager.getUserId()) as StringUserID; + const testConfig = testConfigRecord as typeof config; let appservice: MjolnirAppService | undefined; try { - appservice = await setupHarnessWithConfig(config, { + appservice = await setupHarnessWithConfig(testConfig, { ensureAdminRoomAlias: false, }); if (appservice.accessControlRoomID.length === 0) { diff --git a/apps/draupnir/test/integration/commands/redactCommandTest.ts b/apps/draupnir/test/integration/commands/redactCommandTest.ts index a2c652b5..9098c09e 100644 --- a/apps/draupnir/test/integration/commands/redactCommandTest.ts +++ b/apps/draupnir/test/integration/commands/redactCommandTest.ts @@ -51,6 +51,9 @@ describe("Test: The redaction command", function () { name: { contains: "moderator" }, }); this.moderator = moderator; + if (this.config.managementRoom === undefined) { + throw new TypeError("managementRoom is required for this test"); + } await moderator.joinRoom(this.config.managementRoom); const targetRoom = await moderator.createRoom({ invite: [await badUser.getUserId(), mjolnirUserId], @@ -158,6 +161,9 @@ describe("Test: The redaction command", function () { name: { contains: "moderator" }, }); this.moderator = moderator; + if (this.config.managementRoom === undefined) { + throw new TypeError("managementRoom is required for this test"); + } await moderator.joinRoom(this.config.managementRoom); const targetRooms: string[] = []; for (let i = 0; i < 5; i++) { @@ -260,6 +266,9 @@ describe("Test: The redaction command", function () { name: { contains: "moderator" }, }); this.moderator = moderator; + if (this.config.managementRoom === undefined) { + throw new TypeError("managementRoom is required for this test"); + } await moderator.joinRoom(this.config.managementRoom); const targetRoom = await moderator.createRoom({ invite: [await badUser.getUserId(), draupnir.clientUserID], diff --git a/apps/draupnir/test/integration/commands/roomsTest.ts b/apps/draupnir/test/integration/commands/roomsTest.ts index 66690e17..95e8b89d 100644 --- a/apps/draupnir/test/integration/commands/roomsTest.ts +++ b/apps/draupnir/test/integration/commands/roomsTest.ts @@ -36,6 +36,9 @@ describe("Test: The rooms commands", function () { name: { contains: "moderator" }, }); this.moderator = moderator; + if (this.config.managementRoom === undefined) { + throw new TypeError("managementRoom is required for this test"); + } await moderator.joinRoom(this.config.managementRoom); const targetRoom = await moderator.createRoom({ invite: [draupnir.clientUserID], diff --git a/apps/draupnir/test/integration/fixtures.ts b/apps/draupnir/test/integration/fixtures.ts index eb97e209..f3bff3b4 100644 --- a/apps/draupnir/test/integration/fixtures.ts +++ b/apps/draupnir/test/integration/fixtures.ts @@ -81,7 +81,9 @@ export const mochaHooks = { this.timeout(30000); this.lifetime = new StandardLifetime(); const config = (this.config = configRead()); - this.managementRoomAlias = config.managementRoom; + if (config.managementRoom !== undefined) { + this.managementRoomAlias = config.managementRoom; + } const storagePath = getStoragePath(config.dataPath); await cleanUpTopLevelStores(storagePath); this.stores = makeTopLevelStores(storagePath, DefaultEventDecoder, { diff --git a/apps/draupnir/test/integration/helloTest.ts b/apps/draupnir/test/integration/helloTest.ts index 5b32fe40..f10eb0b5 100644 --- a/apps/draupnir/test/integration/helloTest.ts +++ b/apps/draupnir/test/integration/helloTest.ts @@ -38,6 +38,9 @@ describe("Test: !help command", function (this: Mocha.Suite) { if (draupnir === undefined) { throw new TypeError(`setup code is wrong`); } + if (this.config.managementRoom === undefined) { + throw new TypeError("managementRoom is required for this test"); + } await client.joinRoom(this.config.managementRoom); // listener for getting the event reply const reply = new Promise((resolve) => { diff --git a/apps/draupnir/test/integration/mjolnirSetupUtils.ts b/apps/draupnir/test/integration/mjolnirSetupUtils.ts index ebe5b01e..4a5da753 100644 --- a/apps/draupnir/test/integration/mjolnirSetupUtils.ts +++ b/apps/draupnir/test/integration/mjolnirSetupUtils.ts @@ -34,7 +34,10 @@ import { } from "matrix-protection-suite"; import { SafeModeDraupnir } from "../../src/safemode/DraupnirSafeMode"; import { TopLevelStores } from "../../src/backingstore/DraupnirStores"; -import { isStringUserID, userLocalpart } from "@the-draupnir-project/matrix-basic-types"; +import { + isStringUserID, + userLocalpart, +} from "@the-draupnir-project/matrix-basic-types"; patchMatrixClient(); diff --git a/apps/draupnir/test/integration/utilsTest.ts b/apps/draupnir/test/integration/utilsTest.ts index f2426ede..0066f25c 100644 --- a/apps/draupnir/test/integration/utilsTest.ts +++ b/apps/draupnir/test/integration/utilsTest.ts @@ -21,6 +21,9 @@ describe("Test: utils", function () { it( "replaceRoomIdsWithPills correctly turns a room ID in to a pill", async function (this: DraupnirTestContext) { + if (this.config.managementRoom === undefined) { + throw new TypeError("managementRoom is required for this test"); + } const managementRoomAlias = this.config.managementRoom; const draupnir = this.draupnir; const draupnirMatrixClient = draupnirSafeEmitter();