From c285c30c193a98cc4cf45a69886e15be91e20d61 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Tue, 9 Jun 2026 07:24:39 -0700 Subject: [PATCH] FN-6076: align dashboard tests with updated labels and mocks Update dashboard tests to match current project copy and test doubles. - rename project selector expectations from 'Select Project'/'View All Projects' to 'Projects'/'Manage Projects' - update mailbox split-handle CSS assertion for the new color-mix background - simplify SessionTerminal xterm addon mocks and type the mocked AbortController signal in useDocuments tests Files changed: .../app/components/__tests__/Header.test.tsx | 8 ++++---- .../app/components/__tests__/MailboxView.test.tsx | 2 +- .../components/__tests__/MultiProjectFlow.test.tsx | 2 +- .../__tests__/SessionTerminal.mobile.test.tsx | 21 ++++----------------- .../app/hooks/__tests__/useDocuments.test.ts | 4 ++-- 5 files changed, 12 insertions(+), 25 deletions(-) Fusion-Task-Id: FN-6076 Fusion-Task-Lineage: 9bd7bd36-75c0-4d88-93b4-53bfb75283fa --- .../app/components/__tests__/Header.test.tsx | 8 +++---- .../components/__tests__/MailboxView.test.tsx | 2 +- .../__tests__/MultiProjectFlow.test.tsx | 2 +- .../__tests__/SessionTerminal.mobile.test.tsx | 21 ++++--------------- .../app/hooks/__tests__/useDocuments.test.ts | 4 ++-- 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/packages/dashboard/app/components/__tests__/Header.test.tsx b/packages/dashboard/app/components/__tests__/Header.test.tsx index 4c7eafdc66..2640be0b6f 100644 --- a/packages/dashboard/app/components/__tests__/Header.test.tsx +++ b/packages/dashboard/app/components/__tests__/Header.test.tsx @@ -1592,7 +1592,7 @@ describe("Header", () => { expect(trigger).toHaveTextContent(longName); }); - it("falls back to 'Select Project' label when current project is missing", () => { + it("falls back to 'Projects' label when current project is missing", () => { renderHeader({ projects, currentProject: null, @@ -1601,10 +1601,10 @@ describe("Header", () => { }, "desktop"); const trigger = screen.getByTestId("project-selector-trigger"); - expect(trigger).toHaveTextContent("Select Project"); + expect(trigger).toHaveTextContent("Projects"); }); - it("shows View All Projects action in dropdown and calls onViewAllProjects", () => { + it("shows Manage Projects action in dropdown and calls onViewAllProjects", () => { const onViewAllProjects = vi.fn(); renderHeader({ projects, @@ -1614,7 +1614,7 @@ describe("Header", () => { }, "desktop"); fireEvent.click(screen.getByTestId("project-selector-trigger")); - fireEvent.click(screen.getByText("View All Projects")); + fireEvent.click(screen.getByText("Manage Projects")); expect(onViewAllProjects).toHaveBeenCalled(); expect(screen.queryByTestId("project-selector-dropdown")).toBeNull(); }); diff --git a/packages/dashboard/app/components/__tests__/MailboxView.test.tsx b/packages/dashboard/app/components/__tests__/MailboxView.test.tsx index dd2c10ef03..79bfe204f7 100644 --- a/packages/dashboard/app/components/__tests__/MailboxView.test.tsx +++ b/packages/dashboard/app/components/__tests__/MailboxView.test.tsx @@ -1829,7 +1829,7 @@ describe("MailboxView", () => { expect(splitPaneBlock).toContain("border: var(--btn-border-width) solid var(--border);"); expect(splitPaneBlock).toContain("background: var(--surface);"); - expect(css).toMatch(/\.mailbox-view\s+\.mailbox-split-resize-handle\s*\{[^}]*cursor:\s*col-resize;[^}]*background:\s*transparent;[^}]*\}/); + expect(css).toMatch(/\.mailbox-view\s+\.mailbox-split-resize-handle\s*\{[^}]*cursor:\s*col-resize;[^}]*background:\s*color-mix\(in srgb,\s*var\(--border\)\s*70%,\s*transparent\);[^}]*\}/); const splitEmptyBlockMatch = css.match(/\.mailbox-view\s+\.mailbox-split-empty\s*\{([^}]*)\}/); expect(splitEmptyBlockMatch).toBeTruthy(); diff --git a/packages/dashboard/app/components/__tests__/MultiProjectFlow.test.tsx b/packages/dashboard/app/components/__tests__/MultiProjectFlow.test.tsx index c93decd594..4337cbe144 100644 --- a/packages/dashboard/app/components/__tests__/MultiProjectFlow.test.tsx +++ b/packages/dashboard/app/components/__tests__/MultiProjectFlow.test.tsx @@ -156,7 +156,7 @@ describe("MultiProjectFlow", () => { ); fireEvent.click(screen.getByTestId("project-selector-trigger")); - const manageProjectsAction = screen.getByText("View All Projects"); + const manageProjectsAction = screen.getByText("Manage Projects"); fireEvent.click(manageProjectsAction); expect(handleViewAllProjects).toHaveBeenCalled(); diff --git a/packages/dashboard/app/components/__tests__/SessionTerminal.mobile.test.tsx b/packages/dashboard/app/components/__tests__/SessionTerminal.mobile.test.tsx index 9e909650d0..247a6cd94c 100644 --- a/packages/dashboard/app/components/__tests__/SessionTerminal.mobile.test.tsx +++ b/packages/dashboard/app/components/__tests__/SessionTerminal.mobile.test.tsx @@ -13,24 +13,11 @@ const mockTerm = { cols: 80, rows: 24, }; -vi.mock("@xterm/xterm", () => ({ - Terminal: vi.fn(function (this: typeof mockTerm) { - Object.assign(this, mockTerm); - }), -})); -vi.mock("@xterm/addon-fit", () => ({ - FitAddon: vi.fn(function (this: { fit: ReturnType }) { - this.fit = vi.fn(); - }), -})); -vi.mock("@xterm/addon-unicode11", () => ({ - Unicode11Addon: vi.fn(function () {}), -})); +vi.mock("@xterm/xterm", () => ({ Terminal: vi.fn(function Terminal() { return mockTerm; }) })); +vi.mock("@xterm/addon-fit", () => ({ FitAddon: vi.fn(function FitAddon() { return { fit: vi.fn() }; }) })); +vi.mock("@xterm/addon-unicode11", () => ({ Unicode11Addon: vi.fn(function Unicode11Addon() { return {}; }) })); vi.mock("@xterm/addon-webgl", () => ({ - WebglAddon: vi.fn(function (this: { onContextLoss: ReturnType; dispose: ReturnType }) { - this.onContextLoss = vi.fn(); - this.dispose = vi.fn(); - }), + WebglAddon: vi.fn(function WebglAddon() { return { onContextLoss: vi.fn(), dispose: vi.fn() }; }), })); const apiMock = vi.fn(); diff --git a/packages/dashboard/app/hooks/__tests__/useDocuments.test.ts b/packages/dashboard/app/hooks/__tests__/useDocuments.test.ts index ecd7d9e320..1a5b95e8eb 100644 --- a/packages/dashboard/app/hooks/__tests__/useDocuments.test.ts +++ b/packages/dashboard/app/hooks/__tests__/useDocuments.test.ts @@ -228,8 +228,8 @@ describe("useDocuments", () => { const abortMock = vi.fn(); const originalAbortController = globalThis.AbortController; - globalThis.AbortController = class { - signal = {}; + globalThis.AbortController = class MockAbortController { + signal = {} as AbortSignal; abort = abortMock; } as unknown as typeof AbortController;