Files
ThreadNet-Web/apps/web/test/unit-tests/utils/EventPresentationContextProvider-test.tsx
T
sorB 3da363517f
Docker / Docker Buildx (push) Has been cancelled
Build Debian package / Build package (release) Has been cancelled
Build and Deploy / prepare (release) Has been cancelled
Deploy release / Deploy to Cloudflare Pages (release) Has been cancelled
Build and Deploy / Trigger Pro pipeline (release) Has been cancelled
Build and Deploy / Windows arm64 (release) Has been cancelled
Build and Deploy / Windows x64 (release) Has been cancelled
Build and Deploy / macOS (release) Has been cancelled
Build and Deploy / Linux amd64 (sqlcipher static) (release) Has been cancelled
Build and Deploy / Linux arm64 (sqlcipher static) (release) Has been cancelled
Build and Deploy / ${{ needs.prepare.outputs.deploy == 'true' && 'Deploy' || 'Deploy (dry-run)' }} (release) Has been cancelled
Build and Deploy / Deploy builds to ESS (release) Has been cancelled
feat: show call participants in room list (Discord-style)
2026-05-10 14:25:35 +02:00

58 lines
2.2 KiB
TypeScript

/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import React from "react";
import { act, render, screen, waitFor } from "jest-matrix-react";
import { useEventPresentation } from "@element-hq/web-shared-components";
import { Layout } from "../../../src/settings/enums/Layout";
import {
EventPresentationContextProvider,
getEventPresentation,
} from "../../../src/utils/EventPresentationContextProvider";
import SettingsStore from "../../../src/settings/SettingsStore";
import { SettingLevel } from "../../../src/settings/SettingLevel";
const PresentationProbe: React.FC = () => {
const { layout, density } = useEventPresentation();
return <div data-testid="presentation">{`${layout}:${density}`}</div>;
};
describe("EventPresentationContextProvider", () => {
beforeEach(async () => {
await SettingsStore.setValue("useCompactLayout", null, SettingLevel.DEVICE, false);
});
it.each([
[Layout.Group, false, { layout: "group", density: "default" }],
[Layout.Group, true, { layout: "group", density: "compact" }],
[Layout.Bubble, false, { layout: "bubble", density: "default" }],
[Layout.Bubble, true, { layout: "bubble", density: "default" }],
[Layout.IRC, false, { layout: "irc", density: "default" }],
[Layout.IRC, true, { layout: "irc", density: "default" }],
])("maps %s with compact=%s", (layout, useCompactLayout, expected) => {
expect(getEventPresentation(layout, useCompactLayout)).toEqual(expected);
});
it("updates provider density when compact layout changes", async () => {
render(
<EventPresentationContextProvider layout={Layout.Group}>
<PresentationProbe />
</EventPresentationContextProvider>,
);
expect(screen.getByTestId("presentation")).toHaveTextContent("group:default");
await act(async () => {
await SettingsStore.setValue("useCompactLayout", null, SettingLevel.DEVICE, true);
});
await waitFor(() => expect(screen.getByTestId("presentation")).toHaveTextContent("group:compact"));
});
});