composerPermissionGrant.test.ts 793 B

1234567891011121314151617181920212223
  1. import { describe, expect, it } from "vitest";
  2. import { sortPermissionOptions } from "../src/lib/permissionRequest.js";
  3. describe("审批权限定向同步", () => {
  4. it("完全访问位于始终允许之后、拒绝之前,不靠序号决定 response", () => {
  5. const options = [
  6. { optionId: "deny", kind: "deny" },
  7. { optionId: "fullAccess", kind: "custom" },
  8. { optionId: "allowAlways", kind: "allow_always" },
  9. { optionId: "allowOnce", kind: "allow_once" },
  10. ].map((option) => ({
  11. ...option,
  12. name: option.optionId,
  13. response: { decision: "deny" as const },
  14. }));
  15. expect(sortPermissionOptions(options).map((option) => option.optionId)).toEqual([
  16. "allowOnce",
  17. "allowAlways",
  18. "fullAccess",
  19. "deny",
  20. ]);
  21. });
  22. });