Add message preview toggle to room list header option (#31821)

* feat: add message preview action to room list header option

https://github.com/element-hq/element-web/issues/31214

* test: add e2e test
This commit is contained in:
Florian Duros
2026-01-21 11:43:35 +01:00
committed by GitHub
parent 819d361a91
commit bc6375d7ab
9 changed files with 101 additions and 10 deletions

View File

@@ -148,6 +148,16 @@ describe("RoomListHeaderViewModel", () => {
vm = new RoomListHeaderViewModel({ matrixClient, spaceStore: SpaceStore.instance });
expect(vm.getSnapshot().canAccessSpaceSettings).toBe(false);
});
it("should show message preview when RoomList.showMessagePreview is enabled", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName: string) => {
if (settingName === "RoomList.showMessagePreview") return true;
return false;
});
vm = new RoomListHeaderViewModel({ matrixClient, spaceStore: SpaceStore.instance });
expect(vm.getSnapshot().isMessagePreviewEnabled).toBe(true);
});
});
describe("event listeners", () => {
@@ -268,5 +278,20 @@ describe("RoomListHeaderViewModel", () => {
expect(resortSpy).toHaveBeenCalledWith(expectedAlgorithm);
});
it("should toggle message preview from enabled to disabled", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName: string) => {
if (settingName === "RoomList.showMessagePreview") return true;
return false;
});
const setValueSpy = jest.spyOn(SettingsStore, "setValue").mockImplementation(jest.fn());
vm = new RoomListHeaderViewModel({ matrixClient, spaceStore: SpaceStore.instance });
expect(vm.getSnapshot().isMessagePreviewEnabled).toBe(true);
vm.toggleMessagePreview();
expect(setValueSpy).toHaveBeenCalledWith("RoomList.showMessagePreview", null, expect.anything(), false);
});
});
});