整理测试代码并清理文档引用
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const readSource = () => readFileSync(resolve(__dirname, "./PrecautionDetail.vue"), "utf8");
|
||||
|
||||
describe("PrecautionDetail project permissions", () => {
|
||||
it("hides edit controls unless the backend update operation is allowed", () => {
|
||||
const source = readSource();
|
||||
|
||||
expect(source).toContain('const canUpdatePrecaution = computed(() => can("precautions.update"))');
|
||||
expect(source).toContain('v-if="canUpdatePrecaution"');
|
||||
expect(source).toContain("if (!canUpdatePrecaution.value)");
|
||||
expect(source).not.toContain("canWritePrecautions");
|
||||
});
|
||||
});
|
||||
|
||||
describe("PrecautionDetail drawer editor", () => {
|
||||
it("opens edit in the shared drawer editor instead of routing to the form page", () => {
|
||||
const source = readSource();
|
||||
|
||||
expect(source).toContain("PrecautionEditorDrawer");
|
||||
expect(source).toContain("precautionEditorVisible");
|
||||
expect(source).toContain("@success=\"handlePrecautionEditorSuccess\"");
|
||||
expect(source).not.toContain("router.push(`/knowledge/precautions/${precautionId}/edit`)");
|
||||
});
|
||||
});
|
||||
@@ -1,43 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const readSource = () => readFileSync(resolve(__dirname, "./PrecautionForm.vue"), "utf8");
|
||||
|
||||
describe("PrecautionForm project permissions", () => {
|
||||
it("uses create permission for new records and update permission for edits", () => {
|
||||
const source = readSource();
|
||||
|
||||
expect(source).toContain('const canCreatePrecaution = computed(() => can("precautions.create"))');
|
||||
expect(source).toContain('const canUpdatePrecaution = computed(() => can("precautions.update"))');
|
||||
expect(source).toContain("const canSavePrecaution = computed(() => (isEdit.value ? canUpdatePrecaution.value : canCreatePrecaution.value))");
|
||||
expect(source).toContain("if (!canSavePrecaution.value)");
|
||||
expect(source).not.toContain("canWritePrecautions");
|
||||
});
|
||||
|
||||
it("uses selects for site and level fields", () => {
|
||||
const source = readSource();
|
||||
|
||||
expect(source).toContain('<el-select v-model="form.site_name"');
|
||||
expect(source).toContain('v-for="site in sites"');
|
||||
expect(source).toContain(':value="site.name"');
|
||||
expect(source).toContain('<el-select v-model="form.level"');
|
||||
expect(source).toContain("const levelOptions = precautionLevelOptions");
|
||||
expect(source).toContain('v-for="level in levelOptions"');
|
||||
expect(source).not.toContain('<el-input v-model="form.site_name"');
|
||||
expect(source).not.toContain('<el-input v-model="form.level"');
|
||||
});
|
||||
|
||||
it("allows attachments to be selected before creating a precaution", () => {
|
||||
const source = readSource();
|
||||
|
||||
expect(source).toContain("<AttachmentList");
|
||||
expect(source).toContain('ref="attachmentPanelRef"');
|
||||
expect(source).toContain('entity-type="precaution"');
|
||||
expect(source).toContain(':entity-id="precautionId || \'\'"');
|
||||
expect(source).toContain(':mode="\'upload\'"');
|
||||
expect(source).toContain("await attachmentPanelRef.value?.uploadPending(savedId)");
|
||||
expect(source).not.toContain('v-if="isEdit && precautionId"');
|
||||
expect(source).not.toContain("StateEmpty");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user