From d49f54931df055fa7cf8b0caf761122b44aa7d74 Mon Sep 17 00:00:00 2001 From: shrimbly Date: Sat, 28 Mar 2026 21:29:34 +1300 Subject: [PATCH] fix: update Header tests for WorkflowBrowserModal-based open flow The open button now opens a WorkflowBrowserModal instead of calling the browse-directory API. Updated the test to assert modal rendering and removed two obsolete tests that tested the old fetch-based flow. Co-Authored-By: Claude Opus 4.6 --- src/components/__tests__/Header.test.tsx | 59 ++++-------------------- 1 file changed, 9 insertions(+), 50 deletions(-) diff --git a/src/components/__tests__/Header.test.tsx b/src/components/__tests__/Header.test.tsx index 4962bff3..efa6fd1f 100644 --- a/src/components/__tests__/Header.test.tsx +++ b/src/components/__tests__/Header.test.tsx @@ -24,6 +24,13 @@ vi.mock("@/components/ProjectSetupModal", () => ({ ), })); +// Mock WorkflowBrowserModal +vi.mock("@/components/WorkflowBrowserModal", () => ({ + WorkflowBrowserModal: ({ isOpen }: { isOpen: boolean }) => ( + isOpen ?
Workflow Browser
: null + ), +})); + // Mock CostIndicator vi.mock("@/components/CostIndicator", () => ({ CostIndicator: () =>
$0.00
, @@ -250,18 +257,12 @@ describe("Header", () => { expect(openButton).toBeInTheDocument(); }); - it("should call browse-directory API when open button is clicked", async () => { - const mockFetch = vi.fn().mockResolvedValue({ - ok: true, - json: () => Promise.resolve({ success: true, cancelled: true }), - }); - global.fetch = mockFetch; - + it("should open WorkflowBrowserModal when open button is clicked", () => { render(
); const openButton = screen.getByTitle("Open project"); fireEvent.click(openButton); - expect(mockFetch).toHaveBeenCalledWith("/api/browse-directory"); + expect(screen.getByTestId("workflow-browser-modal")).toBeInTheDocument(); }); }); @@ -399,48 +400,6 @@ describe("Header", () => { }); }); - describe("File Loading via Directory Picker", () => { - it("should not call loadWorkflow when directory picker is cancelled", async () => { - const mockFetch = vi.fn().mockResolvedValue({ - ok: true, - json: () => Promise.resolve({ success: true, cancelled: true }), - }); - global.fetch = mockFetch; - - render(
); - const openButton = screen.getByTitle("Open project"); - fireEvent.click(openButton); - - // Wait for the async handler to settle - await vi.waitFor(() => { - expect(mockFetch).toHaveBeenCalledWith("/api/browse-directory"); - }); - expect(mockLoadWorkflow).not.toHaveBeenCalled(); - }); - - it("should load workflow from selected directory", async () => { - const mockWorkflow = { version: "1.0", nodes: [], edges: [], name: "Test" }; - const mockFetch = vi.fn() - .mockResolvedValueOnce({ - ok: true, - json: () => Promise.resolve({ success: true, path: "/path/to/project" }), - }) - .mockResolvedValueOnce({ - ok: true, - json: () => Promise.resolve({ success: true, workflow: mockWorkflow, filename: "Test" }), - }); - global.fetch = mockFetch; - - render(
); - const openButton = screen.getByTitle("Open project"); - fireEvent.click(openButton); - - await vi.waitFor(() => { - expect(mockLoadWorkflow).toHaveBeenCalledWith(mockWorkflow, "/path/to/project"); - }); - }); - }); - describe("Comments Navigation Icon", () => { it("should not render comments icon when no comments exist", () => { mockGetNodesWithComments.mockReturnValue([]);