From 9eafab5a506b00631c9f955a204729ba22407fe2 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 6 May 2026 15:45:35 +0700 Subject: [PATCH] Fix index startup navigation test mock The cold workspace URL navigation fix changed the / startup path for a matching persisted workspace. Index no longer renders a workspace Redirect there; it calls navigateToWorkspace so the centralized workspace navigation path owns the transition, then keeps the startup splash visible while that imperative navigation runs. Update the test mock to expose navigateToWorkspace and assert that behavior directly. This keeps the test aligned with the route-shape fix and prevents CI failures on branches rebased over main. --- packages/app/src/app/index.test.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/app/src/app/index.test.tsx b/packages/app/src/app/index.test.tsx index a6ccf8635..1b200928d 100644 --- a/packages/app/src/app/index.test.tsx +++ b/packages/app/src/app/index.test.tsx @@ -8,7 +8,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { HostRuntimeBootstrapState } from "./_layout"; import type { ActiveWorkspaceSelection } from "@/stores/navigation-active-workspace-store"; -const { redirectMock, state } = vi.hoisted(() => { +const { navigateToWorkspaceMock, redirectMock, state } = vi.hoisted(() => { const hoistedState = { pathname: "/", bootstrapState: { @@ -22,6 +22,7 @@ const { redirectMock, state } = vi.hoisted(() => { }; return { + navigateToWorkspaceMock: vi.fn(), redirectMock: vi.fn(), state: hoistedState, }; @@ -49,6 +50,7 @@ vi.mock("@/screens/startup-splash-screen", () => ({ })); vi.mock("@/stores/navigation-active-workspace-store", () => ({ + navigateToWorkspace: navigateToWorkspaceMock, useActiveWorkspaceSelection: () => state.workspaceSelection, })); @@ -67,6 +69,7 @@ describe("Index route startup navigation", () => { }; state.anyOnlineHostServerId = null; state.workspaceSelection = null; + navigateToWorkspaceMock.mockReset(); redirectMock.mockReset(); container = document.createElement("div"); @@ -101,7 +104,11 @@ describe("Index route startup navigation", () => { await renderIndex(); - expect(redirectMock).toHaveBeenCalledWith("/h/server-1/workspace/workspace-a"); + expect(navigateToWorkspaceMock).toHaveBeenCalledWith("server-1", "workspace-a", { + currentPathname: "/", + }); + expect(redirectMock).not.toHaveBeenCalled(); + expect(container.querySelector("[data-testid='startup-splash']")).not.toBeNull(); }); it("navigates to the host root when the persisted workspace targets a different server", async () => {