Compare commits

...

2 Commits

Author SHA1 Message Date
yushen
cabdc3c2cf refactor: rename nodeId param to instanceId and update test values
- client.ts: deleteCloudRuntimeNode(nodeId) → deleteCloudRuntimeNode(instanceId)
- cloud-runtime.ts: hook mutationFn param nodeId → instanceId
- client.test.ts: description says 'instance id', test value is i-0123456789abcdef0

Co-authored-by: multica-agent <github@multica.ai>
2026-05-21 18:52:24 +08:00
yushen
710406d2ab fix(api): use instance_id in deleteCloudRuntimeNode body
Fleet API requires instance_id, not id. Fixes 'instance_id is required' error.

MUL-2510

Co-authored-by: multica-agent <github@multica.ai>
2026-05-21 18:52:24 +08:00
3 changed files with 6 additions and 6 deletions

View File

@@ -234,21 +234,21 @@ describe("ApiClient", () => {
).resolves.toMatchObject({ id: "", status: "" });
});
it("deleteCloudRuntimeNode sends DELETE with JSON body containing node id", async () => {
it("deleteCloudRuntimeNode sends DELETE with JSON body containing instance 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");
await client.deleteCloudRuntimeNode("i-0123456789abcdef0");
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" }),
body: JSON.stringify({ instance_id: "i-0123456789abcdef0" }),
});
expect((opts.headers as Record<string, string>)["Content-Type"]).toBe(
"application/json",

View File

@@ -869,10 +869,10 @@ export class ApiClient {
);
}
async deleteCloudRuntimeNode(nodeId: string): Promise<void> {
async deleteCloudRuntimeNode(instanceId: string): Promise<void> {
await this.fetchRaw("/api/cloud-runtime/nodes", {
method: "DELETE",
body: JSON.stringify({ id: nodeId }),
body: JSON.stringify({ instance_id: instanceId }),
extraHeaders: { "Content-Type": "application/json" },
});
}

View File

@@ -83,7 +83,7 @@ export function useCreateCloudRuntimeNode(wsId: string) {
export function useDeleteCloudRuntimeNode(wsId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: (nodeId: string) => api.deleteCloudRuntimeNode(nodeId),
mutationFn: (instanceId: string) => api.deleteCloudRuntimeNode(instanceId),
onSettled: () => {
qc.invalidateQueries({ queryKey: cloudRuntimeKeys.all(wsId) });
},