mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
9bcb0b7a59
Replace acceptInvitesFromGroup with acceptInvitesFromSpace. https://github.com/matrix-org/mjolnir/issues/125 https://github.com/matrix-org/mjolnir/issues/99 acceptInvitesFromGroup was implemented with an experimental api that was a precursor to spaces which was refereed to as either communities or groups. Support for communities/groups ended in Synapse 1.61.0 https://github.com/matrix-org/synapse/releases/tag/v1.61.0. To test we just edit the config dynamically which changes how the join room listener functions though idk, shouldn't we have just made a new mjolnir instance for this test, or changed the config before the test started somehow? Co-authored-by: jesopo <github@lolnerd.net>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { MatrixClient } from "matrix-bot-sdk";
|
|
import { Mjolnir } from "../../src/Mjolnir"
|
|
import { newTestUser } from "./clientHelper";
|
|
|
|
describe("Test: Accept Invites From Space", function() {
|
|
let client: MatrixClient|undefined;
|
|
this.beforeEach(async function () {
|
|
client = await newTestUser(this.config.homeserverUrl, { name: { contains: "spacee" }});
|
|
await client.start();
|
|
})
|
|
this.afterEach(async function () {
|
|
await client.stop();
|
|
})
|
|
it("Mjolnir should accept an invite from a user in a nominated Space", async function() {
|
|
this.timeout(20000);
|
|
|
|
const mjolnir: Mjolnir = this.mjolnir!;
|
|
const mjolnirUserId = await mjolnir.client.getUserId();
|
|
|
|
const space = await client.createSpace({
|
|
name: "mjolnir space invite test",
|
|
invites: [mjolnirUserId],
|
|
isPublic: false
|
|
});
|
|
|
|
await this.mjolnir.client.joinRoom(space.roomId);
|
|
|
|
// we're mutating a static object, which may affect other tests :(
|
|
mjolnir.config.autojoinOnlyIfManager = false;
|
|
mjolnir.config.acceptInvitesFromSpace = space.roomId;
|
|
|
|
const promise = new Promise(async resolve => {
|
|
const newRoomId = await client.createRoom({ invite: [mjolnirUserId] });
|
|
client.on("room.event", (roomId, event) => {
|
|
if (
|
|
roomId === newRoomId
|
|
&& event.type === "m.room.member"
|
|
&& event.sender === mjolnirUserId
|
|
&& event.content?.membership === "join"
|
|
) {
|
|
resolve(null);
|
|
}
|
|
});
|
|
});
|
|
await promise;
|
|
});
|
|
});
|
|
|