|
1 | | -import { readTestConfig, setupHarness } from "../utils/harness"; |
| 1 | +import { isPolicyRoom, readTestConfig, setupHarness } from "../utils/harness"; |
2 | 2 | import { newTestUser } from "../../integration/clientHelper"; |
3 | 3 | import { getFirstReply } from "../../integration/commands/commandUtils"; |
4 | 4 | import { MatrixClient } from "matrix-bot-sdk"; |
5 | 5 | import { MjolnirAppService } from "../../../src/appservice/AppService"; |
6 | | -import PolicyList from "../../../src/models/PolicyList"; |
7 | | -import { CreateEvent } from "matrix-bot-sdk"; |
| 6 | +import { doesNotMatch } from "assert"; |
8 | 7 |
|
9 | 8 | interface Context extends Mocha.Context { |
10 | 9 | user?: MatrixClient, |
11 | 10 | appservice?: MjolnirAppService |
12 | 11 | } |
13 | 12 |
|
14 | | -afterEach(function(this: Context) { |
15 | | - this.user?.stop(); |
16 | | - // something still runs, and i'm not sure what? -- ignoring with --exit. |
17 | | - this.appservice?.close(); |
18 | | -}); |
19 | | - |
20 | | -async function isPolicyRoom(user: MatrixClient, roomId: string): Promise<boolean> { |
21 | | - const createEvent = new CreateEvent(await user.getRoomStateEvent(roomId, "m.room.create", "")); |
22 | | - return PolicyList.ROOM_TYPE_VARIANTS.includes(createEvent.type); |
23 | | -} |
24 | | - |
25 | 13 | describe("Test that the app service can provision a mjolnir on invite of the appservice bot", function () { |
| 14 | + afterEach(function(this: Context) { |
| 15 | + this.user?.stop(); |
| 16 | + if (this.appservice) { |
| 17 | + return this.appservice.close(); |
| 18 | + } else { |
| 19 | + console.warn("Missing Appservice in this context, so cannot stop it.") |
| 20 | + } |
| 21 | + }); |
26 | 22 | it("", async function (this: Context) { |
27 | 23 | const config = readTestConfig(); |
28 | 24 | this.appservice = await setupHarness(); |
|
0 commit comments