mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
make reportPollingTest report in a room that's protected
This commit is contained in:
parent
cad92074e5
commit
ad8a5e0dda
@ -19,13 +19,14 @@ describe("Test: Report polling", function() {
|
|||||||
await client.stop();
|
await client.stop();
|
||||||
})
|
})
|
||||||
it("Mjolnir correctly retrieves a report from synapse", async function() {
|
it("Mjolnir correctly retrieves a report from synapse", async function() {
|
||||||
this.timeout(20000);
|
this.timeout(40000);
|
||||||
|
|
||||||
const reportPromise = new Promise(async (resolve, reject) => {
|
const reportPromise = new Promise(async (resolve, reject) => {
|
||||||
await this.mjolnir.registerProtection(new class implements IProtection {
|
await this.mjolnir.registerProtection(new class implements IProtection {
|
||||||
name = "jYvufI";
|
name = "jYvufI";
|
||||||
description = "A test protection";
|
description = "A test protection";
|
||||||
settings = { };
|
settings = { };
|
||||||
|
handleEvent = async (mjolnir: Mjolnir, roomId: string, event: any) => { };
|
||||||
handleReport = (mjolnir: Mjolnir, roomId: string, reporterId: string, event: any, reason?: string) => {
|
handleReport = (mjolnir: Mjolnir, roomId: string, reporterId: string, event: any, reason?: string) => {
|
||||||
if (reason === "x5h1Je") {
|
if (reason === "x5h1Je") {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
@ -35,14 +36,14 @@ describe("Test: Report polling", function() {
|
|||||||
});
|
});
|
||||||
await this.mjolnir.enableProtection("jYvufI");
|
await this.mjolnir.enableProtection("jYvufI");
|
||||||
|
|
||||||
const roomId = this.mjolnir.managementRoomId;
|
let protectedRoomId = await this.mjolnir.client.createRoom({ invite: [await client.getUserId()] });
|
||||||
await this.mjolnir.client.inviteUser(await client.getUserId(), roomId);
|
await client.joinRoom(protectedRoomId);
|
||||||
await client.joinRoom(roomId);
|
await this.mjolnir.addProtectedRoom(protectedRoomId);
|
||||||
|
|
||||||
const eventId = await client.sendMessage(roomId, {msgtype: "m.text", body: "uwNd3q"});
|
const eventId = await client.sendMessage(protectedRoomId, {msgtype: "m.text", body: "uwNd3q"});
|
||||||
await client.doRequest(
|
await client.doRequest(
|
||||||
"POST",
|
"POST",
|
||||||
`/_matrix/client/r0/rooms/${encodeURIComponent(roomId)}/report/${encodeURIComponent(eventId)}`, "", {
|
`/_matrix/client/r0/rooms/${encodeURIComponent(protectedRoomId)}/report/${encodeURIComponent(eventId)}`, "", {
|
||||||
reason: "x5h1Je"
|
reason: "x5h1Je"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user