unified-workbench.spec.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { expect, test } from "@playwright/test"
  2. test("applications use the shared shell and preserve chat and code drafts", async ({ page }) => {
  3. await page.goto("/e2e/paas/index.html?unified&agent-groups")
  4. await expect(page.getByLabel("λ-Agent", { exact: true })).toBeVisible()
  5. await page.getByRole("button", { name: "代码工作区", exact: true }).click()
  6. await expect(page.getByLabel("代码草稿")).toBeVisible()
  7. await page.getByLabel("代码草稿").fill("unsaved code")
  8. await page.getByRole("button", { name: "应用与插件", exact: true }).click()
  9. await page.getByRole("button", { name: "连接后使用", exact: true }).click()
  10. await page.getByLabel("API Key", { exact: true }).fill("unified-test")
  11. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  12. await page.getByRole("textbox", { name: "消息", exact: true }).fill("保留当前草稿")
  13. await page.getByRole("button", { name: "代码工作区", exact: true }).click()
  14. await expect(page.getByLabel("代码草稿")).toHaveValue("unsaved code")
  15. await expect(page.getByRole("button", { name: "代码工作区", exact: true })).toHaveAttribute("aria-current", "page")
  16. await expect(page.getByRole("button", { name: "会话", exact: true })).not.toHaveAttribute("aria-current", "page")
  17. await page.getByRole("button", { name: "会话", exact: true }).click()
  18. await expect(page.getByRole("textbox", { name: "消息", exact: true })).toHaveValue("保留当前草稿")
  19. await page.getByRole("button", { name: "应用与插件", exact: true }).click()
  20. await expect(page.getByRole("heading", { name: "λ-Scientist", exact: true })).toBeVisible()
  21. await page.getByRole("button", { name: "开始分析", exact: true }).click()
  22. await expect(page.getByRole("button", { name: "选择执行角色", exact: true })).toContainText("data67")
  23. await page.getByRole("textbox", { name: "消息", exact: true }).fill("分析数据")
  24. await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
  25. await expect
  26. .poll(() =>
  27. page.evaluate(
  28. () =>
  29. (window as unknown as { paasTestCalls: { action: string; agentID?: string }[] }).paasTestCalls.find(
  30. (call) => call.action === "execute",
  31. )?.agentID,
  32. ),
  33. )
  34. .toBe("data67")
  35. })
  36. test("code entry receives the selected project's directory", async ({ page }) => {
  37. await page.goto("/e2e/paas/index.html?unified&workspace")
  38. await page.getByLabel("API Key", { exact: true }).fill("project-code")
  39. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  40. await page.getByRole("button", { name: "项目设置", exact: true }).click()
  41. await page.getByRole("button", { name: "添加工作文件夹", exact: true }).click()
  42. await page.getByRole("button", { name: "完成", exact: true }).click()
  43. await page.getByRole("button", { name: "代码工作区", exact: true }).click()
  44. await expect(page.getByRole("region", { name: "代码测试区" })).toContainText("D:/Research/optics")
  45. await expect(page.getByLabel("λ-Agent 工作台导航")).toBeVisible()
  46. await page.getByRole("button", { name: "应用与插件", exact: true }).click()
  47. await page.getByRole("button", { name: "进入科研应用", exact: true }).click()
  48. await expect(page.getByRole("button", { name: "选择执行角色", exact: true })).toContainText("科研助手")
  49. })