fix(KB-503): address code review feedback for Step 1
- Add optional globalDir parameter to resolveProject(), getDefaultProject(), setDefaultProject(), and clearDefaultProject() for test isolation - Remove ESLint suppression by using void operator for intentionally unused var - Update all tests to use isolated globalDir parameter - Complete tests for default project resolution
This commit is contained in:
@@ -36,7 +36,7 @@ const FAKE_DETAIL: TaskDetail = {
|
||||
log: [],
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
prompt: "# KB-001",
|
||||
prompt: "# FN-001",
|
||||
};
|
||||
|
||||
function mockFetchResponse(
|
||||
@@ -125,7 +125,7 @@ describe("updateTask", () => {
|
||||
const result = await updateTask("FN-001", { dependencies: ["FN-002"] });
|
||||
|
||||
expect(result.dependencies).toEqual(["FN-002"]);
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ dependencies: ["FN-002"] }),
|
||||
@@ -166,7 +166,7 @@ describe("task comments api", () => {
|
||||
const result = await fetchTaskComments("FN-001");
|
||||
|
||||
expect(result).toEqual(comments);
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/comments", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/comments", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
});
|
||||
@@ -177,7 +177,7 @@ describe("task comments api", () => {
|
||||
const result = await addTaskComment("FN-001", "Hello", "user");
|
||||
|
||||
expect(result).toEqual(FAKE_TASK);
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/comments", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/comments", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
body: JSON.stringify({ text: "Hello", author: "user" }),
|
||||
@@ -189,7 +189,7 @@ describe("task comments api", () => {
|
||||
|
||||
await updateTaskComment("FN-001", "c1", "Updated");
|
||||
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/comments/c1", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/comments/c1", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ text: "Updated" }),
|
||||
@@ -201,7 +201,7 @@ describe("task comments api", () => {
|
||||
|
||||
await deleteTaskComment("FN-001", "c1");
|
||||
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/comments/c1", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/comments/c1", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "DELETE",
|
||||
});
|
||||
@@ -513,7 +513,7 @@ describe("addSteeringComment", () => {
|
||||
expect(result.id).toBe("FN-001");
|
||||
expect(result.steeringComments).toHaveLength(1);
|
||||
expect(result.steeringComments![0].text).toBe("Please handle the edge case");
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/steer", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/steer", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
body: JSON.stringify({ text: "Please handle the edge case" }),
|
||||
@@ -778,7 +778,7 @@ describe("approvePlan", () => {
|
||||
|
||||
expect(result.column).toBe("todo");
|
||||
expect(result.status).toBeUndefined();
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/approve-plan", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/approve-plan", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
});
|
||||
@@ -812,7 +812,7 @@ describe("rejectPlan", () => {
|
||||
|
||||
expect(result.column).toBe("triage");
|
||||
expect(result.status).toBeUndefined();
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/reject-plan", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/reject-plan", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
});
|
||||
@@ -838,7 +838,7 @@ describe("refineTask", () => {
|
||||
|
||||
const FAKE_REFINED_TASK: Task = {
|
||||
id: "FN-002",
|
||||
description: "Refinement of KB-001",
|
||||
description: "Refinement of FN-001",
|
||||
column: "triage",
|
||||
dependencies: ["FN-001"],
|
||||
steps: [],
|
||||
@@ -856,7 +856,7 @@ describe("refineTask", () => {
|
||||
expect(result.id).toBe("FN-002");
|
||||
expect(result.column).toBe("triage");
|
||||
expect(result.dependencies).toContain("FN-001");
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/refine", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/refine", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
body: JSON.stringify({ feedback: "Need to add more tests and improve error handling" }),
|
||||
@@ -1155,7 +1155,7 @@ describe("Git Management API", () => {
|
||||
const response = await archiveTask("FN-001");
|
||||
|
||||
expect(response.column).toBe("archived");
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/archive", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/archive", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
});
|
||||
@@ -1176,7 +1176,7 @@ describe("Git Management API", () => {
|
||||
const response = await unarchiveTask("FN-001");
|
||||
|
||||
expect(response.column).toBe("done");
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/KB-001/unarchive", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/tasks/FN-001/unarchive", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
});
|
||||
@@ -1212,7 +1212,7 @@ describe("Git Management API", () => {
|
||||
const response = await fetchWorkspaceFileList("FN-001", "src");
|
||||
|
||||
expect(response).toEqual(payload);
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/files?workspace=KB-001&path=src", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/files?workspace=FN-001&path=src", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
});
|
||||
@@ -1236,7 +1236,7 @@ describe("Git Management API", () => {
|
||||
const response = await saveWorkspaceFileContent("FN-001", "src/index.ts", "hello");
|
||||
|
||||
expect(response).toEqual(payload);
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/files/src%2Findex.ts?workspace=KB-001", {
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith("/api/files/src%2Findex.ts?workspace=FN-001", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
body: JSON.stringify({ content: "hello" }),
|
||||
@@ -1799,4 +1799,3 @@ describe("summarizeTitle", () => {
|
||||
await expect(summarizeTitle("a".repeat(200))).rejects.toThrow("API returned empty title");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user