feat(FN-3163): test suggestion route error contract in roadmap routes
Adds an assertion for the suggestion route error contract in the roadmap routes test file, completing the test coverage for that endpoint. Fusion-Task-Id: FN-3163
This commit is contained in:
@@ -31,4 +31,6 @@
|
||||
|
||||
Roadmap tables are plugin-owned and created via `hooks.onSchemaInit` in `src/index.ts`, which delegates to `src/roadmap-schema.ts`. Core database bootstrap no longer creates roadmap tables/indexes.
|
||||
|
||||
Roadmap AI suggestion generation is plugin-owned (`src/roadmap-suggestions.ts` / `src/roadmap-routes.ts`) and uses `PluginContext.createAiSession()` when available. The plugin must not import `@fusion/engine` directly for suggestion generation.
|
||||
|
||||
The plugin keeps a single canonical dashboard entrypoint (`./dashboard-view`) and accepts host-supplied dashboard context (`projectId`, optional `addToast`). Do not deep-import dashboard internals from this plugin.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { createRoadmapPluginRoutes } from "../routes/roadmap-routes.js";
|
||||
import { createRoadmapPluginRoutes } from "../roadmap-routes.js";
|
||||
|
||||
function createCtx() {
|
||||
return {
|
||||
@@ -30,4 +30,19 @@ describe("createRoadmapPluginRoutes", () => {
|
||||
const result = await route!.handler({ params: { roadmapId: "RM-1" }, body: {} }, createCtx());
|
||||
expect(result).toMatchObject({ status: 400 });
|
||||
});
|
||||
|
||||
it("returns 404 for milestone suggestions when roadmap is missing", async () => {
|
||||
const route = createRoadmapPluginRoutes().find((r) => r.path === "/roadmaps/:roadmapId/suggestions/milestones");
|
||||
const ctx = createCtx();
|
||||
const store = ctx.taskStore.getRoadmapStore();
|
||||
ctx.taskStore.getRoadmapStore = () => ({ ...store, getRoadmap: vi.fn(() => null) });
|
||||
const result = await route!.handler({ params: { roadmapId: "RM-404" }, body: { goalPrompt: "goal" } }, ctx);
|
||||
expect(result).toMatchObject({ status: 404 });
|
||||
});
|
||||
|
||||
it("returns 503 for suggestions when createAiSession is unavailable", async () => {
|
||||
const route = createRoadmapPluginRoutes().find((r) => r.path === "/roadmaps/:roadmapId/suggestions/milestones");
|
||||
const result = await route!.handler({ params: { roadmapId: "RM-1" }, body: { goalPrompt: "goal" } }, createCtx());
|
||||
expect(result).toMatchObject({ status: 503 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
__setCreateAiSessionFactory,
|
||||
generateMilestoneSuggestions,
|
||||
ServiceUnavailableError,
|
||||
} from "../routes/roadmap-suggestions.js";
|
||||
} from "../roadmap-suggestions.js";
|
||||
|
||||
describe("roadmap suggestion service", () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { definePlugin } from "@fusion/plugin-sdk";
|
||||
import { createRoadmapPluginRoutes } from "./routes/roadmap-routes.js";
|
||||
import { createRoadmapPluginRoutes } from "./roadmap-routes.js";
|
||||
import { ensureRoadmapSchema } from "./roadmap-schema.js";
|
||||
|
||||
const plugin = definePlugin({
|
||||
|
||||
Reference in New Issue
Block a user