2021-09-22 12:59:11 -04:00
|
|
|
import config from "../../src/config";
|
|
|
|
import { newTestUser, noticeListener } from "./clientHelper"
|
|
|
|
|
2021-10-20 07:11:00 -04:00
|
|
|
describe("Test: !help command", function() {
|
2021-09-22 12:59:11 -04:00
|
|
|
let client;
|
2021-10-20 07:11:00 -04:00
|
|
|
this.beforeEach(async function () {
|
2022-08-16 10:51:18 -04:00
|
|
|
client = await newTestUser(this.config.homeserverUrl, { name: { contains: "-" }});;
|
2021-09-22 12:59:11 -04:00
|
|
|
await client.start();
|
|
|
|
})
|
2021-10-20 07:11:00 -04:00
|
|
|
this.afterEach(async function () {
|
|
|
|
await client.stop();
|
|
|
|
})
|
2021-09-22 12:59:11 -04:00
|
|
|
it('Mjolnir responded to !mjolnir help', async function() {
|
|
|
|
this.timeout(30000);
|
|
|
|
// send a messgage
|
2022-08-16 10:51:18 -04:00
|
|
|
await client.joinRoom(this.config.managementRoom);
|
2021-09-22 12:59:11 -04:00
|
|
|
// listener for getting the event reply
|
|
|
|
let reply = new Promise((resolve, reject) => {
|
2022-01-17 11:24:12 -05:00
|
|
|
client.on('room.message', noticeListener(this.mjolnir.managementRoomId, (event) => {
|
2021-09-22 12:59:11 -04:00
|
|
|
if (event.content.body.includes("Print status information")) {
|
|
|
|
resolve(event);
|
|
|
|
}
|
|
|
|
}))});
|
|
|
|
// check we get one back
|
2021-09-23 11:12:08 -04:00
|
|
|
console.log(config);
|
2022-01-17 11:24:12 -05:00
|
|
|
await client.sendMessage(this.mjolnir.managementRoomId, {msgtype: "m.text", body: "!mjolnir help"})
|
2021-09-22 12:59:11 -04:00
|
|
|
await reply
|
|
|
|
})
|
|
|
|
})
|