conversation-session-r3-project-entry.test.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { mkdir, writeFile } from "node:fs/promises";
  2. import { resolve } from "node:path";
  3. import { parseRemoteWorkspaceIdentity } from "@zcode/shared";
  4. import * as app from "#e2e/helpers/desktop-app";
  5. import * as ssh from "#e2e/helpers/ssh-remote-p0";
  6. import * as v4 from "#e2e/helpers/v4-conversation";
  7. import * as recorder from "#e2e/helpers/electron-window-recorder";
  8. const marker = "E2E_R3_PROJECT_ENTRY";
  9. describe(`${marker}: R3 首连后显式添加项目`, () => {
  10. after(async () => {
  11. await browser.electron.restoreAllMocks();
  12. await app.clearAppData();
  13. });
  14. it("真实 SSH 连接后经目录步骤打开指定远端项目,并绑定稳定 Source 身份", async function () {
  15. this.timeout(120_000);
  16. const config = ssh.readSSHRuntimeConfig(marker);
  17. await v4.prepareV4ConversationE2E({ skipProvider: true });
  18. const artifact = resolve(process.env.ZCODE_E2E_ARTIFACT_DIR!);
  19. await mkdir(artifact, { recursive: true });
  20. const recording =
  21. process.env.ZCODE_E2E_FAILURE_ARTIFACTS === "1"
  22. ? undefined
  23. : await recorder.startElectronWindowRecording({
  24. outputPath: resolve(artifact, "project-entry.webm"),
  25. });
  26. try {
  27. const tab = await ssh.connectSSHWorkspace({
  28. config,
  29. workspacePath: config.workspacePaths[0],
  30. caseMarker: marker,
  31. });
  32. expect(tab.remoteKind).toBe("ssh");
  33. expect(tab.workspacePath).toBe(config.workspacePaths[0]);
  34. expect(tab.remoteSessionId).toBeTruthy();
  35. expect(tab.secretPersistedInTab).toBe(false);
  36. expect(parseRemoteWorkspaceIdentity(tab.workspaceIdentity!)?.sourceServerId).toBeTruthy();
  37. await writeFile(resolve(artifact, "project-entry-facts.json"), JSON.stringify(tab, null, 2));
  38. } finally {
  39. await browser.saveScreenshot(resolve(artifact, "project-entry-final.png"));
  40. await recording?.stop();
  41. }
  42. });
  43. });