diff --git a/src/components/views/auth/CaptchaForm.tsx b/src/components/views/auth/CaptchaForm.tsx index ca25ae180de..ed19bae08e0 100644 --- a/src/components/views/auth/CaptchaForm.tsx +++ b/src/components/views/auth/CaptchaForm.tsx @@ -68,7 +68,7 @@ export default class CaptchaForm extends React.Component { public static contextType = MatrixClientContext; declare public context: React.ContextType; @@ -199,24 +194,10 @@ export default class RolesRoomSettingsTab extends React.Component diff --git a/test/unit-tests/components/views/settings/tabs/room/RolesRoomSettingsTab-test.tsx b/test/unit-tests/components/views/settings/tabs/room/RolesRoomSettingsTab-test.tsx index 7681ec0c7b2..44ec2878629 100644 --- a/test/unit-tests/components/views/settings/tabs/room/RolesRoomSettingsTab-test.tsx +++ b/test/unit-tests/components/views/settings/tabs/room/RolesRoomSettingsTab-test.tsx @@ -247,4 +247,42 @@ describe("RolesRoomSettingsTab", () => { deferred.reject("Error"); await waitFor(() => expect(selector).toHaveValue("100")); }); + + it("should allow changing events power levels", async () => { + mocked(cli.sendStateEvent).mockResolvedValue({ event_id: "$eventId" }); + mocked(cli.getRoom).mockReturnValue(room); + mocked(room.currentState.mayClientSendStateEvent).mockReturnValue(true); + const { container } = await renderTab(); + + const selector = container.querySelector(`[placeholder="Change topic"]`)!; + fireEvent.change(selector, { target: { value: "0" } }); + + expect(cli.sendStateEvent).toHaveBeenCalledWith( + room.roomId, + "m.room.power_levels", + expect.objectContaining({ + events: expect.objectContaining({ + "m.room.topic": 0, + }), + }), + ); + }); + + it("should allow changing top level power levels", async () => { + mocked(cli.sendStateEvent).mockResolvedValue({ event_id: "$eventId" }); + mocked(cli.getRoom).mockReturnValue(room); + mocked(room.currentState.mayClientSendStateEvent).mockReturnValue(true); + const { container } = await renderTab(); + + const selector = container.querySelector(`[placeholder="Remove users"]`)!; + fireEvent.change(selector, { target: { value: "0" } }); + + expect(cli.sendStateEvent).toHaveBeenCalledWith( + room.roomId, + "m.room.power_levels", + expect.objectContaining({ + kick: 0, + }), + ); + }); });