mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-08-18 08:29:48 +00:00
Docker Hub - Develop / docker-latest (push) Canceled after 0s
GHCR - Development Branches / ghcr-publish (push) Canceled after 0s
Tests / Build & Lint (push) Canceled after 0s
Tests / Unit tests (push) Canceled after 0s
Tests / Integration tests (push) Canceled after 0s
Tests / Application Service Integration tests (push) Canceled after 0s
Validate Docker Build / validate-docker-build (push) Canceled after 0s
* Remove old matrix-protection-suite package aliases. This was leading to issues with monorepo package management. https://github.com/the-draupnir-project/Draupnir/issues/1124 * Fix badly imported symbols from packages that already export them. * Cleanup build command arguments. There was a deprecation warning for short workspaces flag.
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
// Copyright 2022 - 2024 Gnuxie <Gnuxie@protonmail.com>
|
|
// Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
// SPDX-FileAttributionText: <text>
|
|
// This modified file incorporates work from mjolnir
|
|
// https://github.com/matrix-org/mjolnir
|
|
// </text>
|
|
|
|
import { MatrixClient } from "@vector-im/matrix-bot-sdk";
|
|
import { newTestUser, noticeListener } from "./clientHelper";
|
|
import { DraupnirTestContext } from "./mjolnirSetupUtils";
|
|
import { SafeMatrixEmitterWrapper } from "@the-draupnir-project/matrix-protection-suite-for-matrix-bot-sdk";
|
|
import { DefaultEventDecoder } from "@the-draupnir-project/matrix-protection-suite";
|
|
|
|
describe("Test: !help command", function (this: Mocha.Suite) {
|
|
let client: MatrixClient;
|
|
this.beforeEach(async function (this: DraupnirTestContext) {
|
|
client = await newTestUser(this.config.homeserverUrl, {
|
|
name: { contains: "-" },
|
|
});
|
|
await client.start();
|
|
} as unknown as Mocha.AsyncFunc);
|
|
this.afterEach(async function (this: DraupnirTestContext) {
|
|
client.stop();
|
|
} as unknown as Mocha.AsyncFunc);
|
|
it("Draupnir responded to !mjolnir help", async function (
|
|
this: DraupnirTestContext
|
|
) {
|
|
this.timeout(30000);
|
|
// send a messgage
|
|
const draupnir = this.draupnir;
|
|
const clientEmitter = new SafeMatrixEmitterWrapper(
|
|
client,
|
|
DefaultEventDecoder
|
|
);
|
|
if (draupnir === undefined) {
|
|
throw new TypeError(`setup code is wrong`);
|
|
}
|
|
await client.joinRoom(draupnir.managementRoomID);
|
|
// listener for getting the event reply
|
|
const reply = new Promise((resolve) => {
|
|
clientEmitter.on(
|
|
"room.message",
|
|
noticeListener(draupnir.managementRoomID, (event) => {
|
|
if (event.content.body.includes("which can be used")) {
|
|
resolve(event);
|
|
}
|
|
})
|
|
);
|
|
});
|
|
await client.sendMessage(draupnir.managementRoomID, {
|
|
msgtype: "m.text",
|
|
body: "!draupnir help",
|
|
});
|
|
await reply;
|
|
} as unknown as Mocha.AsyncFunc);
|
|
});
|