整理测试代码并清理文档引用
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getAttachmentPermissionKey } from "./attachmentPermissions";
|
||||
|
||||
describe("attachment permission mapping", () => {
|
||||
it("maps attachment entity types to module attachment permissions", () => {
|
||||
expect(getAttachmentPermissionKey("contract_fee_contract", "create")).toBe("fees_contracts:create");
|
||||
expect(getAttachmentPermissionKey("contract_fee_contract", "read")).toBe("fees_contracts:read");
|
||||
expect(getAttachmentPermissionKey("contract_fee_contract", "delete")).toBe("fees_contracts_attachments:delete");
|
||||
expect(getAttachmentPermissionKey("startup_feasibility", "create")).toBe("startup_initiation:create");
|
||||
expect(getAttachmentPermissionKey("startup_feasibility", "read")).toBe("startup_initiation:read");
|
||||
expect(getAttachmentPermissionKey("startup_feasibility", "delete")).toBe("startup_initiation_attachments:delete");
|
||||
expect(getAttachmentPermissionKey("startup_ethics", "create")).toBe("startup_ethics:create");
|
||||
expect(getAttachmentPermissionKey("startup_ethics", "read")).toBe("startup_ethics:read");
|
||||
expect(getAttachmentPermissionKey("startup_ethics", "delete")).toBe("startup_ethics_attachments:delete");
|
||||
expect(getAttachmentPermissionKey("startup_kickoff_ppt", "create")).toBe("startup_auth:create");
|
||||
expect(getAttachmentPermissionKey("startup_kickoff_ppt", "read")).toBe("startup_auth:read");
|
||||
expect(getAttachmentPermissionKey("training_authorization", "delete")).toBe("startup_auth_attachments:delete");
|
||||
expect(getAttachmentPermissionKey("drug_shipment", "create")).toBe("drug_shipments:create");
|
||||
expect(getAttachmentPermissionKey("drug_shipment", "read")).toBe("drug_shipments:read");
|
||||
expect(getAttachmentPermissionKey("drug_shipment", "delete")).toBe("drug_shipments_attachments:delete");
|
||||
expect(getAttachmentPermissionKey("material_equipment", "create")).toBe("material_equipments:update");
|
||||
expect(getAttachmentPermissionKey("material_equipment", "read")).toBe("material_equipments:read");
|
||||
expect(getAttachmentPermissionKey("material_equipment", "delete")).toBe("material_equipments_attachments:delete");
|
||||
expect(getAttachmentPermissionKey("precaution", "create")).toBe("precautions:create");
|
||||
expect(getAttachmentPermissionKey("precaution", "read")).toBe("precautions:read");
|
||||
expect(getAttachmentPermissionKey("precaution", "delete")).toBe("precautions_attachments:delete");
|
||||
expect(getAttachmentPermissionKey("faq_replies", "create")).toBe("faq_reply:create");
|
||||
expect(getAttachmentPermissionKey("faq_replies", "read")).toBe("faq:read");
|
||||
expect(getAttachmentPermissionKey("faq_replies", "delete")).toBe("faq_attachments:delete");
|
||||
});
|
||||
|
||||
it("does not return generic attachments permissions", () => {
|
||||
expect(getAttachmentPermissionKey("unknown", "read")).toBeNull();
|
||||
expect(getAttachmentPermissionKey("precaution", "read")).not.toBe("attachments:read");
|
||||
});
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useDrawerDirtyGuard } from "./drawerDirtyGuard";
|
||||
|
||||
vi.mock("element-plus", () => ({
|
||||
ElMessage: {
|
||||
warning: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe("useDrawerDirtyGuard", () => {
|
||||
it("allows drawer close when the form has no changes", () => {
|
||||
const form = reactive({ name: "设备A", status: "启用" });
|
||||
const guard = useDrawerDirtyGuard(() => form);
|
||||
const done = vi.fn();
|
||||
|
||||
guard.syncBaseline();
|
||||
guard.beforeClose(done);
|
||||
|
||||
expect(done).toHaveBeenCalledTimes(1);
|
||||
expect(ElMessage.warning).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("blocks drawer close when the form has unsaved changes", () => {
|
||||
const form = reactive({ name: "设备A", status: "启用" });
|
||||
const guard = useDrawerDirtyGuard(() => form);
|
||||
const done = vi.fn();
|
||||
|
||||
guard.syncBaseline();
|
||||
form.name = "设备B";
|
||||
guard.beforeClose(done);
|
||||
|
||||
expect(done).not.toHaveBeenCalled();
|
||||
expect(ElMessage.warning).toHaveBeenCalledWith("请先保存或取消编辑");
|
||||
});
|
||||
});
|
||||
@@ -1,76 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ProjectPublishSnapshot } from "../types/setupConfig";
|
||||
import { buildProjectDiffRows } from "./setupPublishWorkflow";
|
||||
import { serializeDiffValue } from "./setupDiffRows";
|
||||
|
||||
const emptyProjectSnapshot = (): ProjectPublishSnapshot => ({
|
||||
code: "",
|
||||
name: "",
|
||||
project_full_name: "",
|
||||
sponsor: "",
|
||||
protocol_no: "",
|
||||
lead_unit: "",
|
||||
principal_investigator: "",
|
||||
main_pm: "",
|
||||
research_analysis: "",
|
||||
research_product: "",
|
||||
control_product: "",
|
||||
indication: "",
|
||||
research_population: "",
|
||||
research_design: "",
|
||||
plan_start_date: "",
|
||||
plan_end_date: "",
|
||||
planned_site_count: null,
|
||||
planned_enrollment_count: null,
|
||||
status: "",
|
||||
visit_schedule: [],
|
||||
});
|
||||
|
||||
describe("setup publish workflow project diff rows", () => {
|
||||
it("shows visit schedule changes under the summary module", () => {
|
||||
const current = emptyProjectSnapshot();
|
||||
current.visit_schedule = [
|
||||
{
|
||||
visit_code: "V1",
|
||||
baseline_offset_days: 0,
|
||||
window_before_days: 0,
|
||||
window_after_days: 3,
|
||||
},
|
||||
];
|
||||
|
||||
const rows = buildProjectDiffRows(current, emptyProjectSnapshot(), serializeDiffValue);
|
||||
|
||||
expect(rows).toEqual([
|
||||
{
|
||||
moduleLabel: "方案摘要",
|
||||
path: "访视计划",
|
||||
changeType: "修改",
|
||||
localValue: "已配置列表(1项)",
|
||||
serverValue: "已配置列表(0项)",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("does not treat equivalent visit schedule arrays as changed", () => {
|
||||
const current = emptyProjectSnapshot();
|
||||
const base = emptyProjectSnapshot();
|
||||
current.visit_schedule = [
|
||||
{
|
||||
visit_code: "V1",
|
||||
baseline_offset_days: 0,
|
||||
window_before_days: 0,
|
||||
window_after_days: 3,
|
||||
},
|
||||
];
|
||||
base.visit_schedule = [
|
||||
{
|
||||
visit_code: "V1",
|
||||
baseline_offset_days: 0,
|
||||
window_before_days: 0,
|
||||
window_after_days: 3,
|
||||
},
|
||||
];
|
||||
|
||||
expect(buildProjectDiffRows(current, base, serializeDiffValue)).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user