mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-03-31 11:25:39 +00:00
* add .pre-commit-config.yaml Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info> * .editorconfig: decrease indent size for text * .pre-commit-config.yaml: remove prettier Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info> * .editorconfig consistency. * .pre-commit-config.yaml: restore sample hooks * .editorconfig: disable indent_size for LICENSE & NOTICE * pre-commit run --all-files * tsconfig.json: tabs to spaces * .pre-commit-config.yaml: update editorconfig-checker to 2.7.2 * .editorconfig: disable indent_size for markdown * mjolnir-entrypoint.sh: retab * .editorconfig: also exclude json from indent checking * test/nginx.conf: retab * test/integration/commands/redactCommandTest.ts: remove leading space * retab or remove leading whitespaces for the rest of the files * src/appservice/datastore.ts remove newlines * test/integration/commands/roomTest.ts: remove leading space. --------- Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info> Co-authored-by: gnuxie <Gnuxie@protonmail.com>
48 lines
1.7 KiB
TypeScript
48 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;
|
|
});
|
|
});
|