统一项目权限读取模型
1、合并列表与详情读取权限,统一使用 subjects:read、project_members:read、monitoring_issues:read 等业务读取 key。 2、增加历史读取权限 key 的兼容映射,确保存量项目权限覆盖值不会丢失。 3、同步前端权限工具、路由权限与权限管理页面,避免继续引用已合并的旧权限 key。 4、补充项目角色启停保护与抽屉未保存变更守卫,防止停用 PM 或仍有关联成员的角色。
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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("请先保存或取消编辑");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user