conversation-session-settings-no-editing-notice.test.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { mkdir } from "node:fs/promises";
  2. import { resolve } from "node:path";
  3. import {
  4. TID_SETTINGS_PAGE,
  5. TID_SETTINGS_SECTION_NAV,
  6. TID_TASK_SETTINGS_BUTTON,
  7. testId,
  8. } from "@zcode/shared/test-ids";
  9. import { clearAppData, clickTestIdByDom } from "#e2e/helpers/desktop-app";
  10. import { prepareV4ConversationE2E } from "#e2e/helpers/v4-conversation";
  11. // 截图不需要 SSH,独立运行以避免被远端队列的环境门禁整份排除。
  12. describe("E2E_REMOTE_SETTINGS_SAFEGUARDS: 设置防护、连接编辑与机器标注", () => {
  13. after(async () => {
  14. await browser.electron.restoreAllMocks();
  15. await clearAppData();
  16. });
  17. it("设置分区不显示正在编辑提示", async function () {
  18. this.timeout(120_000);
  19. await prepareV4ConversationE2E({ skipProvider: true });
  20. const artifactDir = resolve(
  21. process.env.ZCODE_E2E_ARTIFACT_DIR ?? ".e2e-artifacts/settings-notice",
  22. );
  23. await mkdir(artifactDir, { recursive: true });
  24. for (const theme of ["zai-light", "zai-dark"] as const) {
  25. await browser.execute((value) => {
  26. const actions = (
  27. window as Window & {
  28. __testActions?: { setTheme(theme: "zai-light" | "zai-dark"): void };
  29. }
  30. ).__testActions;
  31. if (!actions) throw new Error("Missing theme actions");
  32. actions.setTheme(value);
  33. }, theme);
  34. for (const width of [1400, 480]) {
  35. await browser.electron.execute((electron, size) => {
  36. const window = electron.BrowserWindow.getAllWindows().find((item) => !item.isDestroyed());
  37. window?.setMinimumSize(360, 600);
  38. window?.setSize(size, 900);
  39. }, width);
  40. for (const name of [
  41. "general",
  42. "plugin",
  43. "mcp",
  44. "skill",
  45. "commands",
  46. "hooks",
  47. "subagents",
  48. ]) {
  49. if (!(await $(`[data-testid="${TID_SETTINGS_PAGE}"]`).isDisplayed()))
  50. await clickTestIdByDom(TID_TASK_SETTINGS_BUTTON);
  51. await clickTestIdByDom(testId(TID_SETTINGS_SECTION_NAV, name));
  52. const frame = $("[data-settings-content-frame]");
  53. await frame.waitForDisplayed();
  54. expect(await frame.getText()).not.toMatch(/正在编辑:|Editing:/u);
  55. expect(await $("[data-settings-machine]").isExisting()).toBe(false);
  56. await browser.saveScreenshot(resolve(artifactDir, `${name}-${theme}-${width}.png`));
  57. }
  58. }
  59. }
  60. });
  61. });