From b9d769364d9ca3bdad68c1caea8610329370fd8a Mon Sep 17 00:00:00 2001 From: Timo K Date: Mon, 15 Jun 2026 14:50:50 +0200 Subject: [PATCH] update tests --- src/AppBar.tsx | 1 - src/room/LobbyView.test.tsx | 43 ++- .../__snapshots__/LobbyView.test.tsx.snap | 259 +++++++++++++++++- 3 files changed, 292 insertions(+), 11 deletions(-) diff --git a/src/AppBar.tsx b/src/AppBar.tsx index 071ad397a..55a1355e1 100644 --- a/src/AppBar.tsx +++ b/src/AppBar.tsx @@ -12,7 +12,6 @@ import { useMemo, useState, createContext, - type ComponentType, type FC, type MouseEvent, type ReactNode, diff --git a/src/room/LobbyView.test.tsx b/src/room/LobbyView.test.tsx index d461ffc22..4131529cd 100644 --- a/src/room/LobbyView.test.tsx +++ b/src/room/LobbyView.test.tsx @@ -11,7 +11,10 @@ import { BrowserRouter } from "react-router-dom"; import { TooltipProvider } from "@vector-im/compound-web"; import { type MatrixClient } from "matrix-js-sdk"; import { axe } from "vitest-axe"; -import { ArrowLeftIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; +import { + ArrowLeftIcon, + ChevronLeftIcon, +} from "@vector-im/compound-design-tokens/assets/web/icons"; import { LobbyView } from "./LobbyView"; import { E2eeType } from "../e2ee/e2eeType"; @@ -49,6 +52,13 @@ const mockClient = { getDeviceId: () => "DEVICE", } as Partial as MatrixClient; +const platformMock = vi.hoisted(() => vi.fn(() => "desktop")); +vi.mock("../Platform", () => ({ + get platform(): string { + return platformMock(); + }, +})); + const matrixInfo = { userId: "@user:example.org", displayName: "Test User", @@ -63,7 +73,9 @@ const matrixInfo = { function renderLobbyView( props: Partial[0]> = {}, withAppBar = false, + platform = "android", ): ReturnType { + platformMock.mockReturnValue(platform); const mediaDevices = mockMediaDevices({}); const muteStates = mockMuteStates(); const hideHeader = withAppBar ? true : false; @@ -117,12 +129,13 @@ describe("LobbyView", () => { expect(getByTestId("lobby_joinCall")).toHaveClass(lobbyStyles.wait); }); - it("renders with AppBar", async () => { + it("renders with AppBar android", async () => { const { container } = renderLobbyView( { waitingForInvite: true, }, true, + "android", ); expect( container.getElementsByClassName(headerStyles.header).length, @@ -141,4 +154,30 @@ describe("LobbyView", () => { expect(container).toMatchSnapshot(); expect(await axe(container)).toHaveNoViolations(); }); + + it("renders with AppBar ios", async () => { + const { container } = renderLobbyView( + { + waitingForInvite: true, + }, + true, + "ios", + ); + expect( + container.getElementsByClassName(headerStyles.header).length, + ).toBeTruthy(); + // Check that the primary button uses ArrowLeftIcon (the back/return icon), + // not the default CollapseIcon + const { container: iconContainer } = render(); + const expectedSvgPath = iconContainer + .querySelector("path")! + .getAttribute("d"); + const primaryButtonSvgPath = container + .querySelector(".leftNav button") + ?.querySelector("path") + ?.getAttribute("d"); + expect(primaryButtonSvgPath).toBe(expectedSvgPath); + expect(container).toMatchSnapshot(); + expect(await axe(container)).toHaveNoViolations(); + }); }); diff --git a/src/room/__snapshots__/LobbyView.test.tsx.snap b/src/room/__snapshots__/LobbyView.test.tsx.snap index 09c86f02e..17df4aabf 100644 --- a/src/room/__snapshots__/LobbyView.test.tsx.snap +++ b/src/room/__snapshots__/LobbyView.test.tsx.snap @@ -1,10 +1,10 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`LobbyView > renders with AppBar 1`] = ` +exports[`LobbyView > renders with AppBar android 1`] = `
@@ -161,7 +161,7 @@ exports[`LobbyView > renders with AppBar 1`] = ` xmlns="http://www.w3.org/2000/svg" > @@ -243,6 +243,249 @@ exports[`LobbyView > renders with AppBar 1`] = `
`; +exports[`LobbyView > renders with AppBar ios 1`] = ` +
+
+
+ +

+ Test Room +

+
+
+
+
+
+
+ + Back to recents + +
+ +
+
+`; + exports[`LobbyView > renders with header and participant count 1`] = `
renders with header and participant count 1`] = ` xmlns="http://www.w3.org/2000/svg" >
@@ -542,7 +785,7 @@ exports[`LobbyView > renders with header and participant count 1`] = ` xmlns="http://www.w3.org/2000/svg" >