Provide a labs flag for encrypted state events (MSC3414) (#31513)
Signed-off-by: Skye Elliot <actuallyori@gmail.com> Co-authored-by: Skye Elliot <actuallyori@gmail.com>
This commit is contained in:
co-authored by
Skye Elliot
parent
6f0369e623
commit
ff3f069122
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { fireEvent, render, screen, within } from "jest-matrix-react";
|
||||
import { act, fireEvent, render, screen, within } from "jest-matrix-react";
|
||||
import { type Room, JoinRule, MatrixError, Preset, Visibility } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import CreateRoomDialog from "../../../../../src/components/views/dialogs/CreateRoomDialog";
|
||||
@@ -247,6 +247,7 @@ describe("<CreateRoomDialog />", () => {
|
||||
createOpts: {},
|
||||
name: roomName,
|
||||
encryption: true,
|
||||
stateEncryption: false,
|
||||
parentSpace: undefined,
|
||||
roomType: undefined,
|
||||
});
|
||||
@@ -260,6 +261,29 @@ describe("<CreateRoomDialog />", () => {
|
||||
await flushPromises();
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe("when the state encryption labs flag is on", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation(
|
||||
(settingName) => settingName === "feature_msc4362_encrypted_state_events",
|
||||
);
|
||||
});
|
||||
|
||||
it("should turn on state encryption when toggled", async () => {
|
||||
// Given we have the create room dialog open
|
||||
const { asFragment } = getComponent();
|
||||
await flushPromises();
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
|
||||
// When I click the Encrypt state events toggle
|
||||
const toggle = screen.getByRole("switch", { name: "Encrypt state events" });
|
||||
expect(toggle).not.toBeChecked();
|
||||
act(() => toggle.click());
|
||||
|
||||
// Then it changes state
|
||||
expect(toggle).toBeChecked();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("for a knock room", () => {
|
||||
@@ -308,6 +332,7 @@ describe("<CreateRoomDialog />", () => {
|
||||
},
|
||||
name: roomName,
|
||||
encryption: true,
|
||||
stateEncryption: false,
|
||||
joinRule: JoinRule.Knock,
|
||||
parentSpace: undefined,
|
||||
roomType: undefined,
|
||||
@@ -326,6 +351,7 @@ describe("<CreateRoomDialog />", () => {
|
||||
},
|
||||
name: roomName,
|
||||
encryption: true,
|
||||
stateEncryption: false,
|
||||
joinRule: JoinRule.Knock,
|
||||
parentSpace: undefined,
|
||||
roomType: undefined,
|
||||
|
||||
Reference in New Issue
Block a user