新增电子试验主文件目录与文件归档
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const apiGet = vi.fn();
|
||||
const apiPost = vi.fn();
|
||||
const apiPatch = vi.fn();
|
||||
|
||||
vi.mock("./axios", () => ({
|
||||
apiGet,
|
||||
apiPost,
|
||||
apiPatch,
|
||||
}));
|
||||
|
||||
describe("etmf api", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("uses canonical eTMF URLs", async () => {
|
||||
const { fetchEtmfTree, fetchEtmfNodeDocuments, createEtmfNode, updateEtmfNode, createEtmfDocument } = await import("./etmf");
|
||||
|
||||
fetchEtmfTree("study-1");
|
||||
fetchEtmfNodeDocuments("node-1", { site_id: "site-1" });
|
||||
createEtmfNode({ study_id: "study-1", code: "01", name: "项目管理" });
|
||||
updateEtmfNode("node-1", { name: "项目管理文件" });
|
||||
createEtmfDocument("node-1", {
|
||||
trial_id: "study-1",
|
||||
doc_no: "DOC-001",
|
||||
doc_type: "Protocol",
|
||||
title: "研究方案",
|
||||
scope_type: "GLOBAL",
|
||||
});
|
||||
|
||||
expect(apiGet).toHaveBeenCalledWith("/api/v1/etmf/tree", { params: { study_id: "study-1" } });
|
||||
expect(apiGet).toHaveBeenCalledWith("/api/v1/etmf/nodes/node-1/documents", { params: { site_id: "site-1" } });
|
||||
expect(apiPost).toHaveBeenCalledWith("/api/v1/etmf/nodes", { study_id: "study-1", code: "01", name: "项目管理" });
|
||||
expect(apiPatch).toHaveBeenCalledWith("/api/v1/etmf/nodes/node-1", { name: "项目管理文件" });
|
||||
expect(apiPost).toHaveBeenCalledWith(
|
||||
"/api/v1/etmf/nodes/node-1/documents",
|
||||
expect.objectContaining({ doc_no: "DOC-001" })
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user