Files
Draupnir/test/integration/helloTest.ts
Gnuxie 8973db487b Migrate to eslint-9 flat config, typescript 5, typescript-eslint strictTypeChecked (#476)
* Migrate to eslint-9 strictTypeChecked & typescript 5.

* Update to MPS 0.23.0.

Required for strict type checks.

* Looks like we found a test that was complete garbage, amazing really.

* FIXUP

* Well, the command handler was bugged previously...

The command handler used to always only return the command
without the prefix due to an operator precedence bug.
This meant that when we made the order of operations explicit,
we were now including the prefix of the command in the copy.
So when we parsed arguments the code wasn't expecting the prefix
to be there.

* update to MPS 0.23.1.

MPS 0.23.0 was bugged because we didn't enable
`noUncheckedIndexedAccess` while upgrading to typescript 5.

* Make sure eslint runs on all ts files.

* eslint fixes.

* enable `noUncheckedIndexedAccess` & `exactOptionalPropertyTypes`.

* eslint ignores is clearly not understood by me.

* Update SuperCoolStream for eslint and ts5.

* stricter eslint done i thinks

* Whoops, added on .only somewhere.

* Update MPS.

* fix broken test realted things.

* Well I guess that part of getMessagesByUserIn was part of the interface.

* Fix redactionCommandTest.

* Account for escapeHTML in tests.

* Fix tests.

* stuff not matching with .editorconfig fixes.

* Fix appservice webAPI test.

* Update for MPS 0.23.3.
2024-07-22 16:54:04 +01:00

37 lines
1.6 KiB
TypeScript

import { MatrixClient } from "matrix-bot-sdk";
import { newTestUser, noticeListener } from "./clientHelper"
import { DraupnirTestContext } from "./mjolnirSetupUtils";
import { SafeMatrixEmitterWrapper } from "matrix-protection-suite-for-matrix-bot-sdk";
import { DefaultEventDecoder } from "matrix-protection-suite";
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 unknown as Mocha.AsyncFunc)
this.afterEach(async function () {
client.stop();
} as unknown as Mocha.AsyncFunc)
it('Mjolnir 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(this.config.managementRoom);
// 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)
})