Commits merged: - fix(FN-2994): gate unavailable research workflow and humanize provider labels - fix(FN-2994): polish research view form and history interactions - feat(FN-2994): complete Step 5 — document research view architecture - fix(FN-2994): align status-dot variant and hook/test conventions - fix(FN-2994): address lint and typecheck issues - test(FN-2994): cover research lifecycle actions and pending status - fix(FN-2994): polish research actions and cited reader behavior - feat(FN-2994): complete Step 3 — add lifecycle actions and task flows - fix(FN-2994): ensure research enables header overflow gate - feat(FN-2994): complete Step 2 — implement research view shell layout - feat(FN-2994): complete Step 2 — gate research navigation and view - feat(FN-2994): complete Step 1 — add research api surface and hook Files changed: docs/architecture.md | 7 +- docs/dashboard-guide.md | 21 ++ packages/dashboard/app/App.tsx | 11 +- packages/dashboard/app/api/legacy.ts | 143 ++++----- packages/dashboard/app/components/Header.tsx | 29 +- packages/dashboard/app/components/MobileNavBar.tsx | 22 +- packages/dashboard/app/components/ResearchView.css | 247 +++++++++------ packages/dashboard/app/components/ResearchView.tsx | 347 ++++++++++++++------- .../app/components/__tests__/ResearchView.test.tsx | 183 ++++++----- .../app/hooks/__tests__/useResearch.test.ts | 66 ++++ packages/dashboard/app/hooks/useResearch.ts | 162 ++++++++++ packages/dashboard/app/research-types.ts | 43 +++ packages/dashboard/app/styles.css | 4 + .../src/__tests__/research-routes.test.ts | 65 ++++ packages/dashboard/src/research-routes.ts | 195 ++++++++++-- 15 files changed, 1111 insertions(+), 434 deletions(-) Fusion-Task-Id: FN-2994
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { act, renderHook, waitFor } from "@testing-library/react";
|
|
import { useResearch } from "../useResearch";
|
|
|
|
const mockListResearchRuns = vi.fn();
|
|
const mockGetResearchRun = vi.fn();
|
|
|
|
vi.mock("../../api", () => ({
|
|
listResearchRuns: (...args: unknown[]) => mockListResearchRuns(...args),
|
|
getResearchRun: (...args: unknown[]) => mockGetResearchRun(...args),
|
|
createResearchRun: vi.fn(),
|
|
cancelResearchRun: vi.fn(),
|
|
retryResearchRun: vi.fn(),
|
|
exportResearchRun: vi.fn(),
|
|
createTaskFromResearchRun: vi.fn(),
|
|
attachResearchRunToTask: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("../../sse-bus", () => ({
|
|
subscribeSse: vi.fn(() => () => {}),
|
|
}));
|
|
|
|
describe("useResearch", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("loads research runs and availability", async () => {
|
|
mockListResearchRuns.mockResolvedValue({
|
|
runs: [
|
|
{
|
|
id: "RR-1",
|
|
query: "query",
|
|
title: "query",
|
|
status: "running",
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
},
|
|
],
|
|
availability: { available: true },
|
|
});
|
|
|
|
const { result } = renderHook(() => useResearch({ projectId: "p1" }));
|
|
|
|
await waitFor(() => {
|
|
expect(result.current.loading).toBe(false);
|
|
expect(result.current.runs).toHaveLength(1);
|
|
expect(result.current.availability.available).toBe(true);
|
|
});
|
|
});
|
|
|
|
it("loads selected run detail", async () => {
|
|
mockListResearchRuns.mockResolvedValue({ runs: [], availability: { available: true } });
|
|
mockGetResearchRun.mockResolvedValue({ run: { id: "RR-2", title: "t" }, availability: { available: true } });
|
|
|
|
const { result } = renderHook(() => useResearch({ projectId: "p1" }));
|
|
|
|
act(() => {
|
|
result.current.setSelectedRunId("RR-2");
|
|
});
|
|
|
|
await waitFor(() => {
|
|
expect(mockGetResearchRun).toHaveBeenCalledWith("RR-2", "p1");
|
|
});
|
|
});
|
|
});
|