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
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
// @vitest-environment node
|
|
import { describe, it, expect, vi } from "vitest";
|
|
import express from "express";
|
|
import { get as performGet, request as performRequest } from "../test-request.js";
|
|
import { createResearchRouter } from "../research-routes.js";
|
|
|
|
function createMockStore() {
|
|
const run = {
|
|
id: "RR-1",
|
|
query: "test",
|
|
topic: "test",
|
|
status: "pending",
|
|
sources: [],
|
|
events: [],
|
|
tags: [],
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
};
|
|
|
|
const researchStore = {
|
|
listRuns: vi.fn(() => [run]),
|
|
createRun: vi.fn(() => run),
|
|
getRun: vi.fn(() => run),
|
|
updateStatus: vi.fn(),
|
|
updateRun: vi.fn(),
|
|
appendEvent: vi.fn(),
|
|
addSource: vi.fn(),
|
|
};
|
|
|
|
return {
|
|
getResearchStore: () => researchStore,
|
|
createTask: vi.fn(async () => ({ id: "FN-1", title: "Task" })),
|
|
upsertTaskDocument: vi.fn(async () => ({ key: "research-rr-1" })),
|
|
addAttachment: vi.fn(async () => ({ filename: "RR-1.md" })),
|
|
};
|
|
}
|
|
|
|
describe("research-routes", () => {
|
|
it("lists runs with availability envelope", async () => {
|
|
const app = express();
|
|
app.use(express.json());
|
|
app.use(createResearchRouter(createMockStore() as any));
|
|
|
|
const response = await performGet(app, "/runs");
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.availability.available).toBe(true);
|
|
expect(Array.isArray(response.body.runs)).toBe(true);
|
|
});
|
|
|
|
it("creates task from run", async () => {
|
|
const app = express();
|
|
app.use(express.json());
|
|
app.use(createResearchRouter(createMockStore() as any));
|
|
|
|
const response = await performRequest(
|
|
app,
|
|
"POST",
|
|
"/runs/RR-1/create-task",
|
|
JSON.stringify({ includeSummary: true, includeCitations: true }),
|
|
{ "content-type": "application/json" },
|
|
);
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.task.id).toBe("FN-1");
|
|
});
|
|
});
|