feat(FN-1445): add project-scoping and fallback handling for AI routes and missions

- Add projectId parameter to refineText API and TaskForm for proper scoping
- Update mission routes to require projectId and add regression tests
- Add mission interview fallback to mission-level context when target not found
- Add AI refine route scoping tests for project isolation
- Update component tests to expect projectId argument
- Update prompt-keys test counts for new system prompts
This commit is contained in:
gsxdsm
2026-04-11 15:23:03 -07:00
parent 18f242b2bc
commit b76a1011b6
16 changed files with 828 additions and 35 deletions

View File

@@ -1892,6 +1892,21 @@ describe("refineText", () => {
});
});
it("passes projectId as query param for scoped settings resolution", async () => {
globalThis.fetch = vi.fn().mockReturnValue(
mockFetchResponse(true, { refined: "Refined with scoped settings" })
);
const result = await refineText("Original text", "clarify", "proj-123");
expect(result).toBe("Refined with scoped settings");
expect(globalThis.fetch).toHaveBeenCalledWith("/api/ai/refine-text?projectId=proj-123", {
headers: { "Content-Type": "application/json" },
method: "POST",
body: JSON.stringify({ text: "Original text", type: "clarify" }),
});
});
it("works with all four refinement types", async () => {
globalThis.fetch = vi.fn().mockReturnValue(
mockFetchResponse(true, { refined: "Refined" })