feat(FN-1869): merge fusion/fn-1869
This commit is contained in:
@@ -1664,12 +1664,19 @@ describe("Planning Mode API", () => {
|
||||
await expect(startPlanning("Build something")).rejects.toThrow("Rate limit exceeded");
|
||||
});
|
||||
|
||||
it("throws on validation error", async () => {
|
||||
globalThis.fetch = vi.fn().mockReturnValue(
|
||||
mockFetchResponse(false, { error: "initialPlan must be 500 characters or less" }, 400)
|
||||
);
|
||||
it("accepts long initialPlan values (no character limit)", async () => {
|
||||
// Test that long initialPlan values are accepted by the server (removed 500-char limit)
|
||||
const response = { sessionId: "plan-456", currentQuestion: FAKE_QUESTION, summary: null };
|
||||
globalThis.fetch = vi.fn().mockReturnValue(mockFetchResponse(true, response, 201));
|
||||
|
||||
await expect(startPlanning("a".repeat(600))).rejects.toThrow("500 characters");
|
||||
const result = await startPlanning("a".repeat(2000));
|
||||
|
||||
expect(result.sessionId).toBe("plan-456");
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/planning/start", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
body: JSON.stringify({ initialPlan: "a".repeat(2000) }),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -7832,8 +7832,9 @@ describe("Planning Mode Routes", () => {
|
||||
expect(res.body.error).toContain("initialPlan is required");
|
||||
});
|
||||
|
||||
it("rejects initialPlan longer than 500 chars", async () => {
|
||||
const longPlan = "a".repeat(501);
|
||||
it("accepts long initialPlan (no character limit)", async () => {
|
||||
// Test that the server accepts long initialPlan values (removed 500-char limit)
|
||||
const longPlan = "a".repeat(2000);
|
||||
const res = await REQUEST(
|
||||
buildApp(),
|
||||
"POST",
|
||||
@@ -7842,8 +7843,8 @@ describe("Planning Mode Routes", () => {
|
||||
{ "Content-Type": "application/json" }
|
||||
);
|
||||
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.body.error).toContain("500 characters");
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.body.sessionId).toBeDefined();
|
||||
});
|
||||
|
||||
it("enforces rate limiting (5 sessions per hour per IP)", async () => {
|
||||
|
||||
@@ -7688,10 +7688,6 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
|
||||
throw badRequest("initialPlan is required and must be a string");
|
||||
}
|
||||
|
||||
if (initialPlan.length > 500) {
|
||||
throw badRequest("initialPlan must be 500 characters or less");
|
||||
}
|
||||
|
||||
const { store: scopedStore } = await getProjectContext(req);
|
||||
const settings = await scopedStore.getSettings();
|
||||
const ip = req.ip || req.socket.remoteAddress || "unknown";
|
||||
@@ -7737,10 +7733,6 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
|
||||
throw badRequest("initialPlan is required and must be a string");
|
||||
}
|
||||
|
||||
if (initialPlan.length > 500) {
|
||||
throw badRequest("initialPlan must be 500 characters or less");
|
||||
}
|
||||
|
||||
if (planningModelProvider !== undefined && typeof planningModelProvider !== "string") {
|
||||
throw badRequest("planningModelProvider must be a string when provided");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user