mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 13:29:44 +02:00
fix(api): correct deleteCloudRuntimeNode contract to match server
- Change from DELETE /api/cloud-runtime/nodes/:nodeId (no body) to
DELETE /api/cloud-runtime/nodes with JSON body { id: nodeId }
- Use fetchRaw + Content-Type header to match server's withBody proxy
- Add contract test verifying URL, method, body, and Content-Type
Fixes review feedback on MUL-2510
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -234,6 +234,27 @@ describe("ApiClient", () => {
|
||||
).resolves.toMatchObject({ id: "", status: "" });
|
||||
});
|
||||
|
||||
it("deleteCloudRuntimeNode sends DELETE with JSON body containing node id", async () => {
|
||||
const fetchMock = vi.fn().mockResolvedValueOnce(
|
||||
new Response(null, { status: 204 }),
|
||||
);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
const client = new ApiClient("https://api.example.test");
|
||||
await client.deleteCloudRuntimeNode("node-abc-123");
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
const [url, opts] = fetchMock.mock.calls[0]!;
|
||||
expect(url).toBe("https://api.example.test/api/cloud-runtime/nodes");
|
||||
expect(opts).toMatchObject({
|
||||
method: "DELETE",
|
||||
body: JSON.stringify({ id: "node-abc-123" }),
|
||||
});
|
||||
expect((opts.headers as Record<string, string>)["Content-Type"]).toBe(
|
||||
"application/json",
|
||||
);
|
||||
});
|
||||
|
||||
describe("getAttachment", () => {
|
||||
it("returns the parsed attachment for a well-formed response", async () => {
|
||||
vi.stubGlobal(
|
||||
|
||||
@@ -870,8 +870,10 @@ export class ApiClient {
|
||||
}
|
||||
|
||||
async deleteCloudRuntimeNode(nodeId: string): Promise<void> {
|
||||
await this.fetch(`/api/cloud-runtime/nodes/${nodeId}`, {
|
||||
await this.fetchRaw("/api/cloud-runtime/nodes", {
|
||||
method: "DELETE",
|
||||
body: JSON.stringify({ id: nodeId }),
|
||||
extraHeaders: { "Content-Type": "application/json" },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user