Files
Draupnir/test/appservice/utils/harness.ts
T
Aminda Suomalainen e4c02b96cd Add pre-commit configuration (#34)
* add .pre-commit-config.yaml

Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>

* .editorconfig: decrease indent size for text

* .pre-commit-config.yaml: remove prettier

Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>

* .editorconfig consistency.

* .pre-commit-config.yaml: restore sample hooks

* .editorconfig: disable indent_size for LICENSE & NOTICE

* pre-commit run --all-files

* tsconfig.json: tabs to spaces

* .pre-commit-config.yaml: update editorconfig-checker to 2.7.2

* .editorconfig: disable indent_size for markdown

* mjolnir-entrypoint.sh: retab

* .editorconfig: also exclude json from indent checking

* test/nginx.conf: retab

* test/integration/commands/redactCommandTest.ts: remove leading space

* retab or remove leading whitespaces for the rest of the files

* src/appservice/datastore.ts remove newlines

* test/integration/commands/roomTest.ts: remove leading space.

---------

Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>
Co-authored-by: gnuxie <Gnuxie@protonmail.com>
2023-08-29 13:38:00 +01:00

24 lines
1.2 KiB
TypeScript

import path from "path";
import { MjolnirAppService } from "../../../src/appservice/AppService";
import { ensureAliasedRoomExists } from "../../integration/mjolnirSetupUtils";
import { read as configRead, IConfig } from "../../../src/appservice/config/config";
import { newTestUser } from "../../integration/clientHelper";
import PolicyList from "../../../src/models/PolicyList";
import { CreateEvent, MatrixClient } from "matrix-bot-sdk";
export function readTestConfig(): IConfig {
return configRead(path.join(__dirname, "../../../src/appservice/config/config.harness.yaml"));
}
export async function setupHarness(): Promise<MjolnirAppService> {
const config = readTestConfig();
const utilityUser = await newTestUser(config.homeserver.url, { name: { contains: "utility" }});
await ensureAliasedRoomExists(utilityUser, config.adminRoom);
return await MjolnirAppService.run(9000, config, "mjolnir-registration.yaml");
}
export async function isPolicyRoom(user: MatrixClient, roomId: string): Promise<boolean> {
const createEvent = new CreateEvent(await user.getRoomStateEvent(roomId, "m.room.create", ""));
return PolicyList.ROOM_TYPE_VARIANTS.includes(createEvent.type);
}