Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
test(web): load what suspending components wait on before rendering them
shoudi zhengec093dd610f1
diff --git a/apps/web/src/features/local-computer/computers-page.test.tsx b/apps/web/src/features/local-computer/computers-page.test.tsxindex af367160..41644880 100644--- a/apps/web/src/features/local-computer/computers-page.test.tsx+++ b/apps/web/src/features/local-computer/computers-page.test.tsx@@ -28,16 +28,23 @@ import type {TeamHubTenantAgentAvailabilitySnapshot,} from "@/features/teamhub/teamhub-types";+import {+ tenantAgentAvailabilityQueryOptions,+ tenantAgentsQueryOptions,+} from "@/features/rooms/room-queries";import { tenantLocalModelsQueryKey } from "@/features/local-models/local-models-queries";import { ComputersPage } from "./computers-page";-import { localComputersQueryKey } from "./local-computer-queries";+import {+ localComputersQueryKey,+ localComputersQueryOptions,+} from "./local-computer-queries";import { publishLocalComputerEnrollment } from "./local-computer-enrollment-events";describe("ComputersPage", () => {it("links a Computer to its Local models page without reading its models", async () => {const runtime = await authenticatedFixture();- const queryClient = renderPage(+ const queryClient = await renderPage(runtime,"/t/tenant-northstar/computers?computer=computer-offline-lab",);@@ -78,7 +85,7 @@ describe("ComputersPage", () => {it("lists several Computers by readiness and opens each one's detail", async () => {const runtime = await authenticatedFixture();- renderPage(runtime);+ await renderPage(runtime);const directory = await screen.findByRole("list", {name: "Local computers directory",@@ -130,7 +137,7 @@ describe("ComputersPage", () => {it("waits for the exact server when another user's Computer connects first", async () => {const runtime = await authenticatedFixture();- const queryClient = renderPage(runtime);+ const queryClient = await renderPage(runtime);fireEvent.click(await screen.findByRole("button", { name: "Connect a Local Computer" }),);@@ -177,7 +184,7 @@ describe("ComputersPage", () => {}),);- renderPage(+ await renderPage(runtime,"/t/tenant-northstar/computers?computer=computer-jenny-mac",);@@ -219,7 +226,7 @@ describe("ComputersPage", () => {},};- renderPage(runtime);+ await renderPage(runtime);const detail = await screen.findByRole("region", {name: "New Build Mac details",@@ -239,7 +246,7 @@ describe("ComputersPage", () => {},};- renderPage(runtime);+ await renderPage(runtime);expect(await screen.findByRole("heading", {@@ -275,7 +282,7 @@ describe("ComputersPage", () => {},};- renderPage(runtime, "/t/tenant-northstar/computers?computer=missing");+ await renderPage(runtime, "/t/tenant-northstar/computers?computer=missing");expect(await screen.findByText("Computer unavailable")).toBeVisible();fireEvent.click(screen.getByRole("button", { name: "Back to computers" }));@@ -287,7 +294,7 @@ describe("ComputersPage", () => {it("completes setup when polling finds a newly connected Computer from another browser", async () => {const runtime = await authenticatedFixture();- const queryClient = renderPage(runtime);+ const queryClient = await renderPage(runtime);fireEvent.click(await screen.findByRole("button", { name: "Connect a Local Computer" }),@@ -351,7 +358,7 @@ describe("ComputersPage", () => {page: { has_more: false },}));- renderPage(runtime);+ await renderPage(runtime);const detail = await screen.findByRole("region", {name: "New Build Mac details",@@ -383,7 +390,7 @@ describe("ComputersPage", () => {},};- renderPage(runtime);+ await renderPage(runtime);const detail = await screen.findByRole("region", {name: "New Build Mac details",@@ -448,7 +455,7 @@ describe("ComputersPage", () => {removeTenantLocalComputer,);- renderPage(runtime);+ await renderPage(runtime);fireEvent.click(await screen.findByRole("button", { name: "Advanced" }));fireEvent.click(screen.getByRole("button", { name: "Remove" }));const dialog = await screen.findByRole("dialog", {@@ -488,7 +495,7 @@ describe("ComputersPage", () => {removeTenantLocalComputer,);- renderPage(+ await renderPage(fixture,"/t/tenant-northstar/computers?computer=computer-jenny-mac",);@@ -541,13 +548,26 @@ async function authenticatedFixture() {return runtime;}-function renderPage(+// Loading the suspending queries first skips React's Suspense reveal+// throttle, which otherwise costs every test a fixed delay.+async function renderPage(runtime: TeamHubRuntime,initialEntry = "/t/tenant-northstar/computers",) {const queryClient = new QueryClient({defaultOptions: { queries: { retry: false } },});+ await Promise.all([+ queryClient.ensureQueryData(+ localComputersQueryOptions(runtime.client, "tenant-northstar"),+ ),+ queryClient.ensureQueryData(+ tenantAgentsQueryOptions(runtime.client, "tenant-northstar"),+ ),+ queryClient.ensureQueryData(+ tenantAgentAvailabilityQueryOptions(runtime.client, "tenant-northstar"),+ ),+ ]);render(<QueryClientProvider client={queryClient}><TeamHubRuntimeProvider runtime={runtime}>diff --git a/apps/web/src/features/local-computer/local-computer-gate.test.tsx b/apps/web/src/features/local-computer/local-computer-gate.test.tsxindex a8c02adc..f3768049 100644--- a/apps/web/src/features/local-computer/local-computer-gate.test.tsx+++ b/apps/web/src/features/local-computer/local-computer-gate.test.tsx@@ -11,7 +11,11 @@ import { Suspense } from "react";import { createMemoryRouter, RouterProvider } from "react-router";import { describe, expect, it } from "vitest";-import { anotherMeQueryKey } from "@/features/rooms/room-queries";+import {+ anotherMeQueryKey,+ teamHubIdentityQueryOptions,+ teamHubTenantQueryOptions,+} from "@/features/rooms/room-queries";import { RoomShell } from "@/features/rooms/room-shell";import { TeamHubRuntimeProvider } from "@/features/teamhub/teamhub-runtime";import type { TeamHubLocalComputerPage } from "@/features/teamhub/teamhub-types";@@ -46,7 +50,7 @@ const newMac: LocalComputer = {describe("Local Computer gate", () => {it("covers the product until a Computer runs an AI app, then opens the Another Me Chat", async () => {- const fixture = renderShell(newMac);+ const fixture = await renderShell(newMac);const gate = await screen.findByRole("dialog", {name: "Connect your computer",@@ -81,7 +85,7 @@ describe("Local Computer gate", () => {it("lets a Computer with no ready app open Settings to load a local model", async () => {// Pi with no model yet: nothing can run Another Me until one is loaded.- const fixture = renderShell({+ const fixture = await renderShell({...newMac,runtimes: [{@@ -129,7 +133,7 @@ describe("Local Computer gate", () => {});it("keeps covering the rest of the product while Another Me is missing", async () => {- renderShell(newMac, "/t/tenant-northstar/rooms/room-1/chat");+ await renderShell(newMac, "/t/tenant-northstar/rooms/room-1/chat");expect(await screen.findByRole("dialog", { name: "Connect your computer" }),).toBeVisible();@@ -137,7 +141,7 @@ describe("Local Computer gate", () => {});it("waits for the CLI login while no Computer is connected", async () => {- renderShell();+ await renderShell();const gate = await screen.findByRole("dialog", {name: "Connect your computer",@@ -152,7 +156,7 @@ describe("Local Computer gate", () => {});});-function renderShell(+async function renderShell(computer?: LocalComputer,path = "/t/tenant-northstar/rooms",) {@@ -182,6 +186,16 @@ function renderShell(.on("GET", "/v0/tenants/{tenantId}/local-computers", () => ({items: computer ? [computer] : [],}));+ // Loading what RoomShell suspends on before rendering skips React's+ // Suspense reveal throttle, which otherwise costs every test a fixed delay.+ await Promise.all([+ fixture.queryClient.ensureQueryData(+ teamHubIdentityQueryOptions(runtime.client),+ ),+ fixture.queryClient.ensureQueryData(+ teamHubTenantQueryOptions(runtime.client, "tenant-northstar"),+ ),+ ]);render(<QueryClientProvider client={fixture.queryClient}><TeamHubRuntimeProvider runtime={runtime}>diff --git a/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsx b/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsxindex 65d829f5..f413352b 100644--- a/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsx+++ b/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsx@@ -48,7 +48,7 @@ describe("Room Chat", () => {"createMessage",);- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -77,7 +77,7 @@ describe("Room Chat", () => {it("does not project hardware Capture into a non-AnotherMe Direct Room", async () => {const runtime = createTestTeamHubRuntime();- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -89,7 +89,7 @@ describe("Room Chat", () => {).not.toBeInTheDocument();cleanup();- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-all/chat",@@ -114,7 +114,7 @@ describe("Room Chat", () => {direct_peer_active: false,}));- renderRoomChat(+ await renderRoomChat(fixture,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -185,7 +185,7 @@ describe("Room Chat", () => {),}),);- renderRoomChat(+ await renderRoomChat(fixture,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -234,7 +234,7 @@ describe("Room Chat", () => {}),);- renderRoomChat(+ await renderRoomChat(fixture,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -308,7 +308,7 @@ describe("Room Chat", () => {listAvailability,);const queryClient = testQueryClient();- renderRoomChat(+ await renderRoomChat(fixture,queryClient,"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -394,7 +394,7 @@ describe("Room Chat", () => {() => snapshot,);const queryClient = testQueryClient();- renderRoomChat(+ await renderRoomChat(runtime,queryClient,"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -444,7 +444,7 @@ describe("Room Chat", () => {it("focuses the composer once when an Agent DM entry requests it", async () => {const runtime = createTestTeamHubRuntime();- const router = renderRoomChat(+ const router = await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -467,7 +467,7 @@ describe("Room Chat", () => {}),);- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),`/t/tenant-northstar/rooms/${room.id}/chat`,@@ -506,7 +506,7 @@ describe("Room Chat", () => {"createMessage",);- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");expect(@@ -542,7 +542,7 @@ describe("Room Chat", () => {"Directory unavailable.",),);- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -572,7 +572,7 @@ describe("Room Chat", () => {"/v0/tenants/{tenantId}/agents",() => new Promise(() => {}),);- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -594,7 +594,7 @@ describe("Room Chat", () => {items: [],page: { has_more: false },}));- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -622,7 +622,7 @@ describe("Room Chat", () => {.mockReturnValue(agents);runtime.server.on("GET", "/v0/tenants/{tenantId}/agents", listTenantAgents);- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",diff --git a/apps/web/src/features/rooms/chat/room-chat-documents.test.tsx b/apps/web/src/features/rooms/chat/room-chat-documents.test.tsxindex ef7fee7b..c0da207e 100644--- a/apps/web/src/features/rooms/chat/room-chat-documents.test.tsx+++ b/apps/web/src/features/rooms/chat/room-chat-documents.test.tsx@@ -96,7 +96,7 @@ describe("Room Chat", () => {},});- const router = renderRoomChat(runtime, testQueryClient());+ const router = await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");fireEvent.change(editor, { target: { value: "@Cod" } });@@ -189,7 +189,7 @@ describe("Room Chat", () => {],};const queryClient = testQueryClient();- const router = renderRoomChat(runtime, queryClient);+ const router = await renderRoomChat(runtime, queryClient);await screen.findByText(/Reviewed the checklist/);appendCommittedMessage(queryClient, contextMessage);@@ -229,7 +229,7 @@ describe("Room Chat", () => {],};const queryClient = testQueryClient();- renderRoomChat(runtime, queryClient);+ await renderRoomChat(runtime, queryClient);await screen.findByText(/Reviewed the checklist/);appendCommittedMessage(queryClient, delivered);@@ -277,7 +277,7 @@ describe("Room Chat", () => {};});const queryClient = testQueryClient();- renderRoomChat(runtime, queryClient);+ await renderRoomChat(runtime, queryClient);await screen.findByText(/Reviewed the checklist/);appendCommittedMessage(queryClient, {...message("message-mail-canvas", "Invitation"),@@ -349,7 +349,7 @@ describe("Room Chat", () => {};});const queryClient = testQueryClient();- renderRoomChat(runtime, queryClient);+ await renderRoomChat(runtime, queryClient);await screen.findByText(/Reviewed the checklist/);appendCommittedMessage(queryClient, {...message("message-mail-readonly", "Pricing"),@@ -389,7 +389,7 @@ describe("Room Chat", () => {const runtime = createTestTeamHubRuntime();const document = seedRoomDocument(runtime, "room-chat-surface-prefetch");const queryClient = testQueryClient();- renderRoomChat(runtime, queryClient);+ await renderRoomChat(runtime, queryClient);await screen.findByText(/Reviewed the checklist/);await new Promise((resolve) => setTimeout(resolve, 50));expect(preload).not.toHaveBeenCalled();@@ -414,7 +414,7 @@ describe("Room Chat", () => {window.localStorage.clear();const runtime = createTestTeamHubRuntime();- const router = renderRoomChat(runtime, testQueryClient());+ const router = await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");fireEvent.change(editor, {@@ -539,7 +539,7 @@ describe("Room Chat", () => {],};});- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");fireEvent.change(editor, { target: { selectionStart: 1, value: "@" } });@@ -578,7 +578,7 @@ describe("Room Chat", () => {}),);const searches = () => queriesTo(runtime, "/v0/library/documents/search");- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");expect(list).not.toHaveBeenCalled();expect(searches()).toEqual([]);@@ -644,7 +644,7 @@ describe("Room Chat", () => {skillReferences: [],},);- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());await waitFor(() =>expect(@@ -675,7 +675,7 @@ describe("Room Chat", () => {bind,);const lists = () => queriesTo(runtime, "/v0/library/documents");- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");expect(lists()).toEqual([]);expect(bind).not.toHaveBeenCalled();@@ -757,7 +757,7 @@ describe("Room Chat", () => {);const listDocuments = () =>runtime.server.requestsTo("GET", "/v0/rooms/{roomId}/documents");- const router = renderRoomChat(runtime, testQueryClient());+ const router = await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");await waitFor(() => expect(listDocuments().length).toBeGreaterThan(0));const initialDocumentLoads = listDocuments().length;@@ -818,7 +818,7 @@ describe("Room Chat", () => {it("keeps a cross-Tenant Document URL out of the current Room Context", async () => {const runtime = createTestTeamHubRuntime();- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");await waitFor(() =>expect(diff --git a/apps/web/src/features/rooms/chat/room-chat-timeline.test.tsx b/apps/web/src/features/rooms/chat/room-chat-timeline.test.tsxindex f4ebf3d1..97cb6aa9 100644--- a/apps/web/src/features/rooms/chat/room-chat-timeline.test.tsx+++ b/apps/web/src/features/rooms/chat/room-chat-timeline.test.tsx@@ -60,7 +60,7 @@ describe("Room Chat", () => {getMessage,);- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-all/chat?message=message-source",@@ -149,7 +149,7 @@ describe("Room Chat", () => {}});try {- renderRoomChat(+ await renderRoomChat(runtime,queryClient,"/t/tenant-northstar/rooms/room-all/chat?message=message-source",@@ -195,7 +195,7 @@ describe("Room Chat", () => {});try {- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-all/chat?message=message-2",@@ -245,7 +245,7 @@ describe("Room Chat", () => {});try {- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-all/chat?message=message-source",@@ -270,7 +270,7 @@ describe("Room Chat", () => {it("offers Copy and the same Thread action on every committed Message", async () => {const runtime = createTestTeamHubRuntime();- const router = renderRoomChat(runtime, testQueryClient());+ const router = await renderRoomChat(runtime, testQueryClient());await screen.findByText(/Reviewed the checklist/);const activeRunMessage = screen@@ -338,7 +338,7 @@ describe("Room Chat", () => {it("keeps Human avatars static while names mention and Agent avatars open Agent info", async () => {const runtime = createTestTeamHubRuntime();- const router = renderRoomChat(runtime, testQueryClient());+ const router = await renderRoomChat(runtime, testQueryClient());await screen.findByText(/I moved the launch notes/);const mayaMessage = screen@@ -407,7 +407,7 @@ describe("Room Chat", () => {events: fixture.events,};- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());await screen.findByText(/Reviewed the checklist/);expect(@@ -444,7 +444,7 @@ describe("Room Chat", () => {fixture.server.on("GET", "/v0/rooms/{roomId}/messages", listMessages);const runtime = withoutRealtime(fixture);- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());await screen.findByText(/Keep the first release focused/);const timeline = screen.getByLabelText("Room timeline");@@ -499,7 +499,7 @@ describe("Room Chat", () => {});try {- renderRoomChat(withoutRealtime(fixture), testQueryClient());+ await renderRoomChat(withoutRealtime(fixture), testQueryClient());const timeline = await screen.findByLabelText("Room timeline");expect(timeline).toHaveAttribute("data-initial-scroll-ready", "true");@@ -538,7 +538,7 @@ describe("Room Chat", () => {fixture.server.on("GET", "/v0/rooms/{roomId}/messages", listMessages);const queryClient = testQueryClient();- renderRoomChat(withoutRealtime(fixture), queryClient);+ await renderRoomChat(withoutRealtime(fixture), queryClient);await screen.findByText(/Keep the first release focused/);const timeline = screen.getByLabelText("Room timeline");@@ -579,7 +579,7 @@ describe("Room Chat", () => {const runtime = withoutRealtime(fixture);const queryClient = testQueryClient();- renderRoomChat(runtime, queryClient);+ await renderRoomChat(runtime, queryClient);const timeline = await screen.findByLabelText("Room timeline");let scrollHeight = 500;diff --git a/apps/web/src/features/rooms/chat/room-chat.fixtures.tsx b/apps/web/src/features/rooms/chat/room-chat.fixtures.tsxindex e70682ce..6de65310 100644--- a/apps/web/src/features/rooms/chat/room-chat.fixtures.tsx+++ b/apps/web/src/features/rooms/chat/room-chat.fixtures.tsx@@ -102,12 +102,20 @@ export function TestRoomChrome({ children }: { children: ReactNode }) {);}-export function renderRoomChat(+// Loading what RoomChat suspends on before rendering skips React's Suspense+// reveal throttle, which otherwise costs every test a fixed delay.+export async function renderRoomChat(runtime: TeamHubRuntime,queryClient: QueryClient,initialEntry = "/t/tenant-northstar/rooms/room-all/chat",focusComposer = false,) {+ const [, tenantId = "", roomId = ""] =+ /^\/t\/([^/]+)\/rooms\/([^/]+)/.exec(initialEntry) ?? [];+ // A failed load stays in the cache so RoomChat surfaces it as before.+ await preloadRoomChat(runtime, queryClient, tenantId, roomId).catch(+ () => undefined,+ );const router = createMemoryRouter([{@@ -246,8 +254,16 @@ export function presentedAttachment(available: boolean) {// still start through their real mounted query and transport paths.export async function loadedRoomChatQueryClient(runtime: TeamHubRuntime) {const queryClient = testQueryClient();- const tenantId = "tenant-northstar";- const roomId = "room-all";+ await preloadRoomChat(runtime, queryClient, "tenant-northstar", "room-all");+ return queryClient;+}++async function preloadRoomChat(+ runtime: TeamHubRuntime,+ queryClient: QueryClient,+ tenantId: string,+ roomId: string,+) {await Promise.all([queryClient.ensureInfiniteQueryData(roomMessagesInfiniteQueryOptions(runtime.client, tenantId, roomId),@@ -260,7 +276,6 @@ export async function loadedRoomChatQueryClient(runtime: TeamHubRuntime) {),queryClient.ensureQueryData(teamHubIdentityQueryOptions(runtime.client)),]);- return queryClient;}export function testQueryClient() {diff --git a/apps/web/src/features/rooms/chat/room-chat.test.tsx b/apps/web/src/features/rooms/chat/room-chat.test.tsxindex d551d446..e0f07e3c 100644--- a/apps/web/src/features/rooms/chat/room-chat.test.tsx+++ b/apps/web/src/features/rooms/chat/room-chat.test.tsx@@ -68,7 +68,7 @@ describe("Room Chat", () => {try {await act(async () => {- renderRoomChat(runtime, await loadedRoomChatQueryClient(runtime));+ await renderRoomChat(runtime, await loadedRoomChatQueryClient(runtime));});await waitFor(() => expect(actorsSpy).toHaveBeenCalled());await waitFor(() =>@@ -306,7 +306,7 @@ describe("Room Chat", () => {const runtime = createTestTeamHubRuntime();await act(async () => {- renderRoomChat(runtime, await loadedRoomChatQueryClient(runtime));+ await renderRoomChat(runtime, await loadedRoomChatQueryClient(runtime));});const status = await screen.findByRole("button", {@@ -374,7 +374,7 @@ describe("Room Chat", () => {updated_at: "2026-10-20T02:00:00Z",};- renderRoomChat(+ await renderRoomChat(runtime,testQueryClient(),"/t/tenant-northstar/rooms/room-dm-codex/chat",@@ -450,7 +450,7 @@ describe("Room Chat", () => {},});- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());await screen.findByLabelText("Message Room");fireEvent.click(@@ -514,7 +514,7 @@ describe("Room Chat", () => {message: message("dropped-declared", ""),presentation: { attachments: [], mentions: [] },});- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());await screen.findByLabelText("Message Room");const target = screen.getByTestId("room-chat-file-drop-target");@@ -568,7 +568,7 @@ describe("Room Chat", () => {}),);- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());await screen.findByLabelText("Message Room");fireEvent.change(screen.getByLabelText("Choose message attachments"), {@@ -605,7 +605,7 @@ describe("Room Chat", () => {.mockRejectedValueOnce(new TypeError("Failed to fetch")).mockImplementation(originalCreateMessage);- renderRoomChat(runtime, testQueryClient());+ await renderRoomChat(runtime, testQueryClient());const editor = await screen.findByLabelText("Message Room");fireEvent.change(editor, { target: { value: "Ambiguous delivery" } });@@ -633,7 +633,7 @@ describe("Room Chat replied Run", () => {const scenario = repliedRunScenario();const queryClient = await loadedRoomChatQueryClient(scenario.runtime);await act(async () => {- renderRoomChat(scenario.runtime, queryClient);+ await renderRoomChat(scenario.runtime, queryClient);});expect(await screen.findByRole("button", {@@ -668,7 +668,7 @@ describe("Room Chat replied Run", () => {scenario.publish({ replied, revision: 2 });const queryClient = await loadedRoomChatQueryClient(scenario.runtime);await act(async () => {- renderRoomChat(scenario.runtime, queryClient);+ await renderRoomChat(scenario.runtime, queryClient);});const editor = await screen.findByLabelText("Message Room");diff --git a/apps/web/src/features/rooms/members/room-members-section.test.tsx b/apps/web/src/features/rooms/members/room-members-section.test.tsxindex dc052df0..1f7ec838 100644--- a/apps/web/src/features/rooms/members/room-members-section.test.tsx+++ b/apps/web/src/features/rooms/members/room-members-section.test.tsx@@ -17,6 +17,12 @@ import {import { teamHubErrorResponse } from "@/test/teamhub-test-server";import { TeamHubRuntimeProvider } from "@/features/teamhub/teamhub-runtime";+import {+ roomMembersQueryOptions,+ teamHubIdentityQueryOptions,+ tenantActorsQueryOptions,+} from "../room-queries";+import { RoomMembersSection } from "./room-members-section";describe("RoomMembersSection", () => {@@ -25,7 +31,7 @@ describe("RoomMembersSection", () => {it("issues Add member when the browser connectivity manager reports offline", async () => {const runtime = await runtimeWithOnlyCurrentMember();- renderPanel(runtime);+ await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });window.dispatchEvent(new Event("offline"));@@ -53,7 +59,7 @@ describe("RoomMembersSection", () => {),);- renderPanel(runtime);+ await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });fireEvent.click(screen.getByRole("button", { name: "Add member" }));@@ -82,7 +88,7 @@ describe("RoomMembersSection", () => {.mockReturnValue({ items: [], page: { has_more: false } });runtime.server.on("GET", "/v0/tenants/{tenantId}/agents", listTenantAgents);- renderPanel(runtime);+ await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });fireEvent.click(screen.getByRole("button", { name: "Add member" }));const dialog = screen.getByRole("dialog", { name: "Add Room member" });@@ -121,7 +127,7 @@ describe("RoomMembersSection", () => {listTenantAgentAvailability,);- renderPanel(runtime);+ await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });fireEvent.click(screen.getByRole("button", { name: "Add member" }));const dialog = screen.getByRole("dialog", { name: "Add Room member" });@@ -147,7 +153,7 @@ describe("RoomMembersSection", () => {it("lets a non-owner add eligible members without exposing removal", async () => {const runtime = await runtimeWithOnlyCurrentMember("member");- renderPanel(runtime);+ await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });expect(screen.getByRole("button", { name: "Add member" })).toBeVisible();@@ -166,7 +172,7 @@ describe("RoomMembersSection", () => {"/v0/rooms/{roomId}/members/{actorId}",);- renderPanel(runtime);+ await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });fireEvent.click(screen.getByRole("button", { name: "Remove Codex" }));@@ -214,7 +220,7 @@ describe("RoomMembersSection", () => {deleteRoomMember,);- renderPanel(runtime);+ await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });fireEvent.click(screen.getByRole("button", { name: "Remove Codex" }));const confirmation = screen.getByRole("dialog", {@@ -240,7 +246,7 @@ describe("RoomMembersSection", () => {const onOpenProfile = vi.fn();- renderPanel(runtime, { onOpenProfile });+ await renderPanel(runtime, { onOpenProfile });fireEvent.click(await screen.findByRole("button", { name: "Open Codex profile" }),@@ -252,7 +258,7 @@ describe("RoomMembersSection", () => {const runtime = createTestTeamHubRuntime();acceptRoomMembers(runtime);- const { unmount } = renderPanel(runtime);+ const { unmount } = await renderPanel(runtime);await screen.findByRole("region", { name: "Room members" });fireEvent.click(await screen.findByRole("button", { name: "Add member" }));expect(@@ -262,7 +268,7 @@ describe("RoomMembersSection", () => {).toBeVisible();unmount();- renderPanel(runtime, { roomId: "room-dm-codex" });+ await renderPanel(runtime, { roomId: "room-dm-codex" });fireEvent.click(await screen.findByRole("button", { name: "Add member" }));const dialog = screen.getByRole("dialog", { name: "Add Room member" });expect(@@ -294,20 +300,33 @@ async function runtimeWithOnlyCurrentMember(return runtime;}-function renderPanel(+// Loading the suspending queries first skips React's Suspense reveal+// throttle, which otherwise costs every test a fixed delay.+async function renderPanel(runtime: ReturnType<typeof createTestTeamHubRuntime>,callbacks: {onOpenProfile?: (actorId: string) => void;roomId?: string;} = {},) {+ const queryClient = createAppQueryClient();+ const roomId = callbacks.roomId ?? "room-all";+ await Promise.all([+ queryClient.ensureQueryData(teamHubIdentityQueryOptions(runtime.client)),+ queryClient.ensureQueryData(+ roomMembersQueryOptions(runtime.client, "tenant-northstar", roomId),+ ),+ queryClient.ensureQueryData(+ tenantActorsQueryOptions(runtime.client, "tenant-northstar"),+ ),+ ]);return render(- <QueryClientProvider client={createAppQueryClient()}>+ <QueryClientProvider client={queryClient}><TeamHubRuntimeProvider runtime={runtime}><Suspense fallback={<p>Loading members</p>}><RoomMembersSectiononOpenProfile={callbacks.onOpenProfile}- roomId={callbacks.roomId ?? "room-all"}+ roomId={roomId}tenantId="tenant-northstar"/></Suspense>diff --git a/apps/web/src/features/rooms/room-shell.test.tsx b/apps/web/src/features/rooms/room-shell.test.tsxindex 48a46d5e..c457d9cb 100644--- a/apps/web/src/features/rooms/room-shell.test.tsx+++ b/apps/web/src/features/rooms/room-shell.test.tsx@@ -35,7 +35,11 @@ import {TeamHubRuntimeProvider,} from "@/features/teamhub/teamhub-runtime";-import { teamHubIdentityQueryKey } from "./room-queries";+import {+ teamHubIdentityQueryKey,+ teamHubIdentityQueryOptions,+ teamHubTenantQueryOptions,+} from "./room-queries";import { browserRoomMessageOutbox } from "./chat/room-message-outbox";import { RoomShell } from "./room-shell";import {@@ -413,6 +417,14 @@ describe("Room shell Tenant transition", () => {],{ initialEntries: ["/t/tenant-northstar/rooms/room-all/chat"] },);+ // Loading what RoomShell suspends on before rendering skips React's+ // Suspense reveal throttle, which otherwise costs the test a fixed delay.+ await Promise.all([+ queryClient.ensureQueryData(teamHubIdentityQueryOptions(runtime.client)),+ queryClient.ensureQueryData(+ teamHubTenantQueryOptions(runtime.client, "tenant-northstar"),+ ),+ ]);render(<QueryClientProvider client={queryClient}><TeamHubRuntimeProvider runtime={runtime}>diff --git a/apps/web/src/features/rooms/room-surface.test.tsx b/apps/web/src/features/rooms/room-surface.test.tsxindex 347f2100..708b3bc1 100644--- a/apps/web/src/features/rooms/room-surface.test.tsx+++ b/apps/web/src/features/rooms/room-surface.test.tsx@@ -29,6 +29,14 @@ import {} from "@/features/teamhub/teamhub-runtime";import { RoomChat } from "./chat/room-chat";+import {+ roomDocumentsQueryOptions,+ roomMembersQueryOptions,+ roomMessagesInfiniteQueryOptions,+ roomQueryOptions,+ teamHubIdentityQueryOptions,+ tenantActorsQueryOptions,+} from "./room-queries";import { RoomSurface } from "./room-surface";import {openPanelTab,@@ -1089,12 +1097,36 @@ async function renderRoomSurface({ initialEntries: [`/t/tenant-northstar/rooms/${roomId}/chat${search}`] },);+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ // Loading what RoomSurface suspends on before rendering skips React's+ // Suspense reveal throttle, which otherwise costs every test a fixed delay.+ // A failed load stays in the cache so RoomSurface surfaces it as before.+ const tenantId = "tenant-northstar";+ await Promise.all([+ queryClient.ensureQueryData(+ roomQueryOptions(runtime.client, tenantId, roomId),+ ),+ queryClient.ensureQueryData(+ roomMembersQueryOptions(runtime.client, tenantId, roomId),+ ),+ queryClient.ensureInfiniteQueryData(+ roomMessagesInfiniteQueryOptions(runtime.client, tenantId, roomId),+ ),+ queryClient.ensureQueryData(teamHubIdentityQueryOptions(runtime.client)),+ ]).catch(() => undefined);+ // The panel sidebar also suspends on these. They are not awaited so a test+ // that holds one back still sees the sidebar's loading state.+ void queryClient.prefetchQuery(+ tenantActorsQueryOptions(runtime.client, tenantId),+ );+ void queryClient.prefetchQuery(+ roomDocumentsQueryOptions(runtime.client, tenantId, roomId),+ );+render(- <QueryClientProvider- client={- new QueryClient({ defaultOptions: { queries: { retry: false } } })- }- >+ <QueryClientProvider client={queryClient}><TeamHubRuntimeProvider runtime={runtime}><RouterProvider router={router} /></TeamHubRuntimeProvider>