userActionTraceCatalog.test.ts 863 B

123456789101112131415161718192021
  1. import { describe, expect, it } from "vitest";
  2. import { USER_ACTION_CATALOG } from "../src/lib/userActionTraceCatalog.js";
  3. describe("user action trace catalog", () => {
  4. it("feature/action 组合唯一且不使用动态标识", () => {
  5. const keys = USER_ACTION_CATALOG.map((entry) => `${entry.featureId}:${entry.action}`);
  6. expect(new Set(keys).size).toBe(keys.length);
  7. for (const entry of USER_ACTION_CATALOG) {
  8. expect(entry.featureId).toMatch(/^[a-z]+(?:[._][a-z]+)+$/u);
  9. expect(entry.action).toMatch(/^[a-z]+(?:_[a-z]+)*$/u);
  10. expect(entry.featureId).not.toMatch(/taskId|workspacePath|pluginId/iu);
  11. }
  12. });
  13. it("不声明 /event/report sink", () => {
  14. for (const entry of USER_ACTION_CATALOG) {
  15. expect(entry).not.toHaveProperty("eventPolicy");
  16. expect(entry).not.toHaveProperty("elementName");
  17. }
  18. });
  19. });