mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-05-17 12:55:21 +00:00
e4c02b96cd
* 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>
40 lines
2.3 KiB
TypeScript
40 lines
2.3 KiB
TypeScript
import { strict as assert } from "assert";
|
|
import { newTestUser } from "../clientHelper";
|
|
import { getFirstReaction, getFirstReply } from "./commandUtils";
|
|
|
|
describe("Test: The rooms commands", function () {
|
|
// If a test has a timeout while awaitng on a promise then we never get given control back.
|
|
afterEach(function() { this.moderator?.stop(); });
|
|
|
|
it('Mjolnir can protect a room, show that it is protected and then stop protecting the room.', async function() {
|
|
// Create a few users and a room.
|
|
const mjolnir = this.mjolnir.client;
|
|
let mjolnirUserId = await mjolnir.getUserId();
|
|
let moderator = await newTestUser(this.config.homeserverUrl, { name: { contains: "moderator" } });
|
|
this.moderator = moderator;
|
|
await moderator.joinRoom(this.config.managementRoom);
|
|
let targetRoom = await moderator.createRoom({ invite: [mjolnirUserId]});
|
|
await moderator.setUserPowerLevel(mjolnirUserId, targetRoom, 100);
|
|
|
|
try {
|
|
await moderator.start();
|
|
await getFirstReaction(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
|
return await moderator.sendMessage(this.mjolnir.managementRoomId, {msgtype: 'm.text', body: `!mjolnir rooms add ${targetRoom}`});
|
|
});
|
|
let protectedRoomsMessage = await getFirstReply(moderator, this.mjolnir.managementRoomId, async () => {
|
|
return await moderator.sendMessage(this.mjolnir.managementRoomId, {msgtype: 'm.text', body: `!mjolnir rooms`});
|
|
})
|
|
assert.equal(protectedRoomsMessage['content']?.['body']?.includes('1'), true, "There should be one protected room");
|
|
await getFirstReaction(moderator, this.mjolnir.managementRoomId, '✅', async () => {
|
|
return await moderator.sendMessage(this.mjolnir.managementRoomId, {msgtype: 'm.text', body: `!mjolnir rooms remove ${targetRoom}`});
|
|
});
|
|
protectedRoomsMessage = await getFirstReply(moderator, this.mjolnir.managementRoomId, async () => {
|
|
return await moderator.sendMessage(this.mjolnir.managementRoomId, {msgtype: 'm.text', body: `!mjolnir rooms`});
|
|
})
|
|
assert.equal(protectedRoomsMessage['content']?.['body']?.includes('0'), true, "There room should no longer be protected");
|
|
} finally {
|
|
moderator.stop();
|
|
}
|
|
})
|
|
})
|