workspace-passive-agent-startup.test.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { dirname } from "node:path";
  2. import { DEFAULT_WORKSPACE, clearAppData, waitForWorkspaceApp } from "#e2e/helpers/desktop-app";
  3. import {
  4. PASSIVE_AGENT_STARTUP_SCENARIO,
  5. getPassiveAgentStartupWorkspacePaths,
  6. } from "#e2e/helpers/passive-agent-startup-fixture";
  7. import {
  8. isMainRendererUrl,
  9. isResourceManagerUrl,
  10. openResourceManager,
  11. switchToElectronRendererTarget,
  12. waitForResourceManagerReady,
  13. } from "#e2e/helpers/resource-manager";
  14. import {
  15. assertStableAgentSelection,
  16. pickWorkspacePaths,
  17. waitForActiveWorkspacePath,
  18. waitForRestoredProjects,
  19. } from "#e2e/helpers/workspace-agent-warmup";
  20. describe("恢复 workspace 只预热 active 1 个 Agent", () => {
  21. after(async () => {
  22. await browser.electron.restoreAllMocks();
  23. await clearAppData();
  24. });
  25. it("TSL29: 9 个 restored workspace 启动只预热上次活动的 05,不按 recent 补位", async function () {
  26. this.timeout(120_000);
  27. const workspacePaths = getPassiveAgentStartupWorkspacePaths(
  28. dirname(DEFAULT_WORKSPACE),
  29. PASSIVE_AGENT_STARTUP_SCENARIO.workspaceCount,
  30. );
  31. const activeWorkspacePath = workspacePaths[PASSIVE_AGENT_STARTUP_SCENARIO.activeWorkspaceIndex];
  32. if (!activeWorkspacePath) throw new Error("启动 fixture 缺少 active workspace");
  33. const expectedWarmupWorkspacePaths = pickWorkspacePaths(
  34. workspacePaths,
  35. PASSIVE_AGENT_STARTUP_SCENARIO.expectedWarmupWorkspaceIndexes,
  36. );
  37. await waitForWorkspaceApp(activeWorkspacePath, 30_000);
  38. await waitForActiveWorkspacePath(activeWorkspacePath);
  39. await waitForRestoredProjects(workspacePaths);
  40. await openResourceManager();
  41. await switchToElectronRendererTarget(isResourceManagerUrl);
  42. await waitForResourceManagerReady();
  43. await assertStableAgentSelection(workspacePaths, expectedWarmupWorkspacePaths);
  44. });
  45. });