M2c:前端镜树页(路径阅读流/候答切换/采用归真/局部树图/SSE 芽体)与灵胚页(创建/导入卡/照心试演/启镜),契约错误码段接入前端
This commit is contained in:
1 parent
30447fc40f
commit
2a640a901b
21 files changed
+2126
-4
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("./client", () => ({
|
||||
apiRequest: vi.fn(),
|
||||
apiGet: vi.fn(),
|
||||
apiPatch: vi.fn(),
|
||||
apiPost: vi.fn(),
|
||||
}));
|
||||
|
||||
import { apiRequest, apiGet, apiPost } from "./client";
|
||||
import {
|
||||
activateEmbryo,
|
||||
importCard,
|
||||
listEmbryos,
|
||||
rehearseEmbryo,
|
||||
} from "./embryos";
|
||||
|
||||
describe("embryos api", () => {
|
||||
it("listEmbryos GET /embryo-drafts", async () => {
|
||||
vi.mocked(apiGet).mockResolvedValue([]);
|
||||
await listEmbryos();
|
||||
expect(apiGet).toHaveBeenCalledWith("/embryo-drafts");
|
||||
});
|
||||
|
||||
it("rehearseEmbryo POST /embryo-drafts/:id/rehearse", async () => {
|
||||
vi.mocked(apiPost).mockResolvedValue({
|
||||
run_id: "run_1",
|
||||
kind: "rehearsal",
|
||||
});
|
||||
await rehearseEmbryo("embryo_1", "你是谁");
|
||||
expect(apiPost).toHaveBeenCalledWith("/embryo-drafts/embryo_1/rehearse", {
|
||||
prompt: "你是谁",
|
||||
});
|
||||
});
|
||||
|
||||
it("activateEmbryo POST /embryo-drafts/:id/activate", async () => {
|
||||
vi.mocked(apiPost).mockResolvedValue({ character_id: "character_1" });
|
||||
await activateEmbryo("embryo_1");
|
||||
expect(apiPost).toHaveBeenCalledWith("/embryo-drafts/embryo_1/activate");
|
||||
});
|
||||
|
||||
it("importCard 以 FormData POST /characters/import-card", async () => {
|
||||
vi.mocked(apiRequest).mockResolvedValue({ embryo_id: "embryo_2" });
|
||||
const file = new File(["{}"], "card.json", { type: "application/json" });
|
||||
await importCard(file);
|
||||
expect(apiRequest).toHaveBeenCalledWith(
|
||||
"/characters/import-card",
|
||||
expect.objectContaining({ method: "POST", body: expect.any(FormData) }),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user