automationCustomRepeatTestIds.test.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. const automationEditViewSource = readFileSync(
  4. new URL("../src/settings/AutomationEditView.tsx", import.meta.url),
  5. "utf8",
  6. );
  7. describe("AutomationEditView Custom Repeat E2E 契约", () => {
  8. it("提供 0–200 的可输入频率、统一步进按钮,并保留分钟和重新编辑入口", () => {
  9. // 回归保护:频率不能重新退回只能选择 1–31 的下拉框,分钟也不能只在组件默认值里存在而被调用方隐藏。
  10. expect(automationEditViewSource).toContain(
  11. "const CUSTOM_REPEAT_INTERVAL_INPUT_MIN = 0;",
  12. );
  13. expect(automationEditViewSource).toContain(
  14. "const CUSTOM_REPEAT_INTERVAL_MAX = 200;",
  15. );
  16. expect(automationEditViewSource).toMatch(
  17. /<Input[\s\S]*?type="number"[\s\S]*?min=\{CUSTOM_REPEAT_INTERVAL_INPUT_MIN\}[\s\S]*?max=\{CUSTOM_REPEAT_INTERVAL_MAX\}[\s\S]*?data-testid=\{TID_AUTOMATION_CUSTOM_INTERVAL_SELECT\}/,
  18. );
  19. expect(automationEditViewSource).toContain(
  20. "data-testid={TID_AUTOMATION_CUSTOM_INTERVAL_INCREMENT}",
  21. );
  22. expect(automationEditViewSource).toContain(
  23. "data-testid={TID_AUTOMATION_CUSTOM_INTERVAL_DECREMENT}",
  24. );
  25. expect(automationEditViewSource).toContain("[appearance:textfield]");
  26. expect(automationEditViewSource).toMatch(/value="minute"[\s\S]*?value="hourly"/);
  27. expect(automationEditViewSource).not.toContain("includeMinuteUnit={false}");
  28. expect(automationEditViewSource).toContain("data-testid={TID_AUTOMATION_CUSTOM_REPEAT_EDIT}");
  29. });
  30. });