mirror of
https://github.com/saltbo/agent-kanban.git
synced 2026-09-19 09:01:47 +08:00
a2fa54a729
Replace the v1 Agent/Machine runtime and CLI architecture with the v2 Resource Server, AMA-backed projections, task lifecycle, session observation, BDD specifications, and a single-package layered codebase. BREAKING CHANGE: remove the v1 CLI, internal Agent/Machine runtime entities, workspace layout, and legacy runtime coordination APIs.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { V2_API_VERSION } from "@shared";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { api } from "../../../src/lib/api";
|
|
|
|
vi.mock("../../../src/lib/auth-client", () => ({
|
|
getCsrfToken: () => "csrf-token",
|
|
getSession: vi.fn(),
|
|
}));
|
|
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
describe("Web Task review API", () => {
|
|
it("reads the current submission ETag before replacing a Task Review Completion", async () => {
|
|
const fetchMock = vi
|
|
.fn<typeof fetch>()
|
|
.mockResolvedValueOnce(Response.json({ id: "submission-one", taskId: "task/one" }, { status: 200, headers: { ETag: '"submission-version"' } }))
|
|
.mockResolvedValueOnce(Response.json({ id: "completion-one" }, { status: 201 }));
|
|
vi.stubGlobal("fetch", fetchMock);
|
|
|
|
await expect(api.tasks.complete("task/one")).resolves.toEqual({ id: "completion-one" });
|
|
|
|
expect(fetchMock).toHaveBeenNthCalledWith(1, "/api/task-review-submissions/task%2Fone", {
|
|
headers: { "API-Version": V2_API_VERSION },
|
|
credentials: "include",
|
|
});
|
|
expect(fetchMock).toHaveBeenNthCalledWith(2, "/api/task-review-completions/task%2Fone", {
|
|
method: "PUT",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"API-Version": V2_API_VERSION,
|
|
"x-csrf-token": "csrf-token",
|
|
},
|
|
credentials: "include",
|
|
body: JSON.stringify({ reviewSubmissionVersion: "submission-version" }),
|
|
});
|
|
});
|
|
});
|