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 () => {