automationTerminologyI18n.test.ts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import { describe, expect, it } from "vitest";
  2. import enUS from "@/i18n/locales/en-US.js";
  3. import zhCN from "@/i18n/locales/zh-CN.js";
  4. import {
  5. appendLocalCustomizeTemplate,
  6. resolveOffPeakTemplateText,
  7. } from "@/settings/automationTemplateCatalog.js";
  8. describe("Automations terminology", () => {
  9. it("localizes the top-level area as Automations / 自动化", () => {
  10. expect(enUS["workspace.openScheduledSettings"]).toBe("Automations");
  11. expect(enUS["settings.automations.title"]).toBe("Automations");
  12. expect(zhCN["workspace.openScheduledSettings"]).toBe("自动化");
  13. expect(zhCN["settings.automations.title"]).toBe("自动化");
  14. });
  15. it("keeps 定时任务 for the scheduled-task subtype", () => {
  16. expect(zhCN["automations.list.title"]).toBe("定时任务");
  17. expect(zhCN["offPeak.tabs.scheduled"]).toBe("定时任务");
  18. expect(zhCN["taskList.cronTaskLabel"]).toBe("定时任务");
  19. });
  20. it("keeps the empty-state description focused on task creation modes", () => {
  21. expect(enUS["automations.description"]).toBe(
  22. "Schedule recurring tasks or queue background work that runs during idle time.",
  23. );
  24. expect(zhCN["automations.description"]).toBe("创建定时任务,或排队在闲时算力空闲时后台执行。");
  25. });
  26. it("keeps idle-time permissions on the main conversation vocabulary", () => {
  27. const modeValues = ["build", "edit", "plan", "yolo"] as const;
  28. expect(modeValues.map((value) => zhCN[`mode.label.glm.${value}`])).toEqual([
  29. "变更前确认",
  30. "自动编辑",
  31. "计划模式",
  32. "完全访问",
  33. ]);
  34. expect(modeValues.map((value) => enUS[`mode.label.glm.${value}`])).toEqual([
  35. "Ask before changes",
  36. "Edit automatically",
  37. "Plan mode",
  38. "Full access",
  39. ]);
  40. for (const value of modeValues) {
  41. expect(zhCN[`offPeak.mode.${value}`]).toBeUndefined();
  42. expect(enUS[`offPeak.mode.${value}`]).toBeUndefined();
  43. }
  44. });
  45. it("keeps the local Customize fallback copy for Client Scenes failures", () => {
  46. const customize = appendLocalCustomizeTemplate([])[0]!;
  47. const format =
  48. (messages: Record<string, string>) =>
  49. ({ id }: { id: string }) =>
  50. messages[id] ?? id;
  51. expect(resolveOffPeakTemplateText(customize, "title", "zh-CN", format(zhCN))).toBe("自定义");
  52. expect(resolveOffPeakTemplateText(customize, "title", "en-US", format(enUS))).toBe("Customize");
  53. expect(
  54. resolveOffPeakTemplateText(customize, "description", "zh-CN", format(zhCN)),
  55. ).toBeTruthy();
  56. expect(
  57. resolveOffPeakTemplateText(customize, "description", "en-US", format(enUS)),
  58. ).toBeTruthy();
  59. });
  60. it("does not retain locale entries for deleted static template catalogs", () => {
  61. const removedPrefixes = [
  62. "automations.template.",
  63. "offPeak.newTask.template.standupGitSummary.",
  64. "offPeak.newTask.template.ciFlakyReport.",
  65. "offPeak.newTask.template.documentationSyncCheck.",
  66. ];
  67. for (const messages of [enUS, zhCN]) {
  68. expect(
  69. Object.keys(messages).some((key) =>
  70. removedPrefixes.some((prefix) => key.startsWith(prefix)),
  71. ),
  72. ).toBe(false);
  73. }
  74. });
  75. it("uses action labels for scheduled and idle task creation", () => {
  76. expect(enUS["automations.createManually"]).toBe("Create scheduled task");
  77. expect(zhCN["automations.createManually"]).toBe("创建定时任务");
  78. expect(enUS["automations.createViaChat"]).toBe("Create in chat");
  79. expect(zhCN["automations.createViaChat"]).toBe("去会话中创建");
  80. expect(enUS["offPeak.createButton"]).toBe("Create idle-time task");
  81. expect(zhCN["offPeak.createButton"]).toBe("创建闲时任务");
  82. });
  83. it("removes the idle-time form queue guidance copy", () => {
  84. expect(enUS["offPeak.form.idleTimeLabel"]).toBeUndefined();
  85. expect(enUS["offPeak.form.scheduleHint"]).toBeUndefined();
  86. expect(zhCN["offPeak.form.idleTimeLabel"]).toBeUndefined();
  87. expect(zhCN["offPeak.form.scheduleHint"]).toBeUndefined();
  88. });
  89. it("uses the approved pause re-queue guidance without confirmation copy", () => {
  90. expect(enUS["offPeak.action.pauseHint"]).toBe(
  91. "Tasks paused beyond the queue wait time will be placed back in the queue",
  92. );
  93. expect(zhCN["offPeak.action.pauseHint"]).toBe(
  94. "暂停时长超过队列等待时限的任务,将会被重新放回队列。",
  95. );
  96. expect(enUS["offPeak.pause.title"]).toBeUndefined();
  97. expect(enUS["offPeak.pause.description"]).toBeUndefined();
  98. expect(zhCN["offPeak.pause.title"]).toBeUndefined();
  99. expect(zhCN["offPeak.pause.description"]).toBeUndefined();
  100. });
  101. it("uses an explicit create action on the idle-time primary button", () => {
  102. expect(enUS["offPeak.createButton"]).toBe("Create idle-time task");
  103. expect(zhCN["offPeak.createButton"]).toBe("创建闲时任务");
  104. });
  105. it("uses the approved idle-time delete confirmation copy", () => {
  106. expect(enUS["offPeak.delete.title"]).toBe("Delete this idle-time task?");
  107. expect(enUS["offPeak.delete.description"]).toBe(
  108. "This action can't be undone. If the task is currently queued or running, it will stop immediately.",
  109. );
  110. expect(enUS["offPeak.delete.confirm"]).toBe("Delete idle-time task");
  111. expect(zhCN["offPeak.delete.title"]).toBe("删除此闲时任务?");
  112. expect(zhCN["offPeak.delete.description"]).toBe(
  113. "此操作无法撤销。如果任务当前正在排队或运行中,将立即停止。",
  114. );
  115. expect(zhCN["offPeak.delete.confirm"]).toBe("删除闲时任务");
  116. });
  117. it("keeps imminent next-run copy grammatical across locales", () => {
  118. const englishNextRun = enUS["automations.nextRun"].replace(
  119. "{when}",
  120. enUS["automations.time.soon"],
  121. );
  122. const chineseNextRun = zhCN["automations.nextRun"].replace(
  123. "{when}",
  124. zhCN["automations.time.soon"],
  125. );
  126. expect(englishNextRun).toBe("Next run soon");
  127. expect(chineseNextRun).toBe("下次运行 1 分钟内");
  128. });
  129. it("uses productized discard-draft copy for both task types", () => {
  130. expect(enUS["automations.unsaved.title"]).toBe("Discard scheduled task draft?");
  131. expect(enUS["automations.unsaved.description"]).toBe(
  132. "Your changes to this scheduled task will be lost",
  133. );
  134. expect(zhCN["automations.unsaved.title"]).toBe("丢弃定时任务的草稿?");
  135. expect(zhCN["automations.unsaved.description"]).toBe("你对这个定时任务的更改将会丢失");
  136. expect(zhCN["automations.unsaved.discard"]).toBe("丢弃");
  137. expect(zhCN["offPeak.discard.title"]).toBe("丢弃闲时任务的草稿?");
  138. expect(zhCN["offPeak.discard.description"]).toBe("你对当前闲时任务的更改将会丢失。");
  139. expect(zhCN["offPeak.discard.confirm"]).toBe("丢弃");
  140. expect(enUS["offPeak.discard.title"]).toBe("Discard Idle-time task draft?");
  141. expect(enUS["offPeak.discard.description"]).toBe(
  142. "Your changes to the current idle-time task will be lost.",
  143. );
  144. expect(enUS["offPeak.discard.confirm"]).toBe("Discard");
  145. });
  146. });