uiFontTokenMigration.test.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. const readSource = (path: string) => readFileSync(path, "utf8");
  4. describe("UI font token migration", () => {
  5. it("maps legacy 13px UI text to text-ui-base", () => {
  6. const tokenSpec = readSource("docs/ui/ui-font-tokens.md");
  7. const remoteFields = readSource("packages/ui/src/RemoteConnectionFields.tsx");
  8. const automationEditor = readSource(
  9. "packages/ui/src/settings/AutomationEditView.tsx",
  10. );
  11. const conversationRows = readSource("packages/ui/src/v4/ConversationRowView.tsx");
  12. expect(tokenSpec).toContain("Replace legacy explicit 13px UI text with `text-ui-base`");
  13. expect(tokenSpec).not.toContain(
  14. "Normalize arbitrary 10px through 13px UI text to `text-ui-xs`",
  15. );
  16. expect(remoteFields).toContain('className="h-9 text-ui-base"');
  17. // Bug 原因:调度选择器已收敛为共享的 SelectItem 样式,旧断言仍绑定被删除的 trigger class。
  18. expect(automationEditor).toContain(
  19. '"min-h-8 rounded-[8px] px-2 py-1.5 pr-8 text-ui-base leading-5',
  20. );
  21. // 附件 pill 重构为 FileDisplayInline 后,13px 文案 token 锚点迁移到
  22. // fileNameClassName;源码可能跨行,这里只断言 token 组合本身仍在文件里。
  23. expect(conversationRows).toContain(
  24. '"truncate text-ui-base font-medium text-foreground"',
  25. );
  26. });
  27. it("uses the base token for the time-of-day picker controls", () => {
  28. const automationEditor = readSource(
  29. "packages/ui/src/settings/AutomationEditView.tsx",
  30. );
  31. expect(automationEditor).toContain(
  32. '"rounded-md px-2 py-1 text-center text-ui-base tabular-nums transition-colors"',
  33. );
  34. expect(automationEditor).toContain(
  35. 'pl-2 pr-1.5 text-ui-base leading-5 tabular-nums text-foreground',
  36. );
  37. });
  38. it("does not hard-code an 18px line height on scalable UI copy", () => {
  39. const scalableUiSources = [
  40. readSource("packages/ui/src/settings/AutomationsSection.tsx"),
  41. readSource("packages/ui/src/settings/AutomationEditView.tsx"),
  42. readSource("packages/ui/src/settings/AutomationDesignPrimitives.tsx"),
  43. readSource("packages/ui/src/settings/OffPeakEditView.tsx"),
  44. readSource("packages/ui/src/settings/OffPeakHistoryTab.tsx"),
  45. readSource("packages/ui/src/settings/OffPeakTaskList.tsx"),
  46. readSource("packages/ui/src/v4/OffPeakNewTaskEntry.tsx"),
  47. readSource("packages/ui/src/components/ui/toast.tsx"),
  48. ];
  49. for (const source of scalableUiSources) {
  50. expect(source).not.toContain("leading-[18px]");
  51. }
  52. });
  53. });