Files
Draupnir/test/integration/helloTest.ts
T
gnuxie d718967a7c Fix hello test (it works).
Ok so this is pretty shit, i hate the integration test suite now.

The reason why we return the test functions with `as any` in the
hello test is because we had to remove `Record<string, any>` from
mocha's test context interface, otherwise the interface would
have been completely useless. Maybe there is a ts setting though
to not infer any from `this` at all? and just ignore those properties.

The tsconfig.json situation is a bit weird, i don't understand why
it's in this situation. However, it seems like we can try to
https://github.com/jaredpalmer/tsdx/issues/84#issuecomment-489690504
use this workaround so that ts language features work in the test
directory.

I think we should focus on doing as little effort as possible getting
these tests into working condition. If something is too complicated,
it will need removing. If we need to make additional tests,
this entire integration tests directory should be moved
to a legacy-integration directory and we can start afresh.

We should also ideally not integration tests as much as possible
and try to reuse the unit helpers from MPS.
This is even going to be critical later on.
2024-04-06 20:03:36 +01:00

30 lines
1.2 KiB
TypeScript

import { MatrixClient } from "matrix-bot-sdk";
import { newTestUser, noticeListener } from "./clientHelper"
import { DraupnirTestContext } from "./mjolnirSetupUtils";
describe("Test: !help command", function() {
let client: MatrixClient;
this.beforeEach(async function (this: DraupnirTestContext) {
client = await newTestUser(this.config.homeserverUrl, { name: { contains: "-" }});;
await client.start();
} as any)
this.afterEach(async function () {
client?.stop();
} as any)
it('Mjolnir responded to !mjolnir help', async function(this: DraupnirTestContext) {
this.timeout(30000);
// send a messgage
await client.joinRoom(this.config.managementRoom);
// listener for getting the event reply
let reply = new Promise((resolve, reject) => {
client.on('room.message', noticeListener(this.draupnir!.managementRoomID, (event) => {
if (event.content.body.includes("which can be used")) {
resolve(event);
}
}))
});
await client.sendMessage(this.draupnir!.managementRoomID, {msgtype: "m.text", body: "!draupnir help"})
await reply
} as any)
})