Update for MPS 2.5.2 (#683)

* Test UnbanCommand and UnbanPrompt have unbanned as a side effect.

You'd think it would be obvious, but clearly it hasn't been.  Part of
the reason for it is just how un-ergonomic it used to be to verify
room state.  Fortunately it's quite straight forward to do since MPS
has picked up. So now we can do it easily.

* Update for MPS 2.5.2.

- Fix SchemedMatrixData putting the wrong version number into data.
  Sadly a complication of
  https://github.com/the-draupnir-project/Draupnir/issues/560.

- Fix an issue where the implementation of the RoomUnbanner capability
  was actually calling `/ban`.
This commit is contained in:
Gnuxie authored and GitHub committed 2025-01-18 00:54:25 +00:00
1 parent a16fb7b2c0
commit 8a17cfed5d
4 files changed
+67 -23

No files matched your search

+30 -3
View File
@@ -5,6 +5,7 @@
import { CommandExecutorHelper } from "@the-draupnir-project/interface-manager";
import {
MatrixRoomID,
MatrixRoomReference,
MatrixUserID,
StringUserID,
} from "@the-draupnir-project/matrix-basic-types";
@@ -75,14 +76,29 @@ describe("Test the DraupnirUnbanCommand", function () {
},
});
it("Will add a user to the policy list when they are banned", async function () {
const { protectedRoomsSet, policyRoomManager, roomStateManager } =
await createProtectedRooms();
const roomUnbanner = createMock<RoomUnbanner>({
async unbanUser(_room, userID, _reason) {
async unbanUser(roomOrRoomID, userID, reason) {
const room =
roomOrRoomID instanceof MatrixRoomID
? roomOrRoomID
: MatrixRoomReference.fromRoomID(roomOrRoomID);
expect(userID).toBe(ExistingBanUserID);
roomStateManager.appendState({
room,
membershipDescriptions: [
{
sender: DraupnirUserID,
target: userID,
membership: Membership.Leave,
...(reason === undefined ? {} : { reason }),
},
],
});
return Ok(undefined);
},
});
const { protectedRoomsSet, policyRoomManager } =
await createProtectedRooms();
const policyRoom = protectedRoomsSet.allProtectedRooms[0];
if (policyRoom === undefined) {
throw new TypeError(
@@ -128,5 +144,16 @@ describe("Test the DraupnirUnbanCommand", function () {
policyRoom
);
expect(banResult.isOkay).toBe(true);
const membership = protectedRoomsSet.setRoomMembership.getRevision(
policyRoom.toRoomIDOrAlias()
);
if (membership === undefined) {
throw new TypeError(
`We should be able to get the membership for the protected policy room`
);
}
expect(membership.membershipForUser(ExistingBanUserID)?.membership).toBe(
Membership.Leave
);
});
});