workbench.spec.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. import { expect, test } from "@playwright/test"
  2. test("independent workbench connects, uploads, confirms and saves without a developer server", async ({ page }) => {
  3. const errors: string[] = []
  4. page.on("pageerror", (error) => errors.push(error.message))
  5. await page.goto("/e2e/paas/index.html")
  6. await expect(page.getByText("连接工作平台", { exact: true })).toBeVisible()
  7. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  8. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  9. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  10. await expect(page.locator(".paas-topbar-chat-title")).toBeVisible()
  11. await expect(page.getByText("任务后台执行 · 会话与草稿自动保存", { exact: true })).toHaveCount(0)
  12. await page.getByRole("button", { name: "智能体", exact: true }).click()
  13. await page.getByRole("button", { name: "与 科研助手 对话", exact: true }).click()
  14. await page.getByRole("button", { name: "添加文件", exact: true }).click()
  15. await expect(page.getByRole("button", { name: "移除材料.pdf", exact: true })).toBeVisible()
  16. await page.getByRole("textbox", { name: "消息", exact: true }).fill("分析材料并制定研究计划")
  17. await expect(page.getByText("草稿已保留", { exact: true })).toHaveCount(0)
  18. await expect(page.locator(".paas-chat-caption")).toHaveCount(0)
  19. await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
  20. await expect(page.getByRole("button", { name: "同意并继续", exact: true })).toBeVisible()
  21. await expect(page.locator(".paas-result-live")).toBeVisible()
  22. await expect(page.locator(".paas-notifications")).toHaveCount(0)
  23. await expect(page.getByText("是否执行验证?", { exact: true })).toBeVisible()
  24. await expect(page.getByRole("heading", { name: "研究计划", exact: true })).toBeVisible()
  25. await expect(page.getByRole("cell", { name: "证据清单", exact: true })).toBeVisible()
  26. await expect(page.getByRole("link", { name: "查看平台任务", exact: true })).toHaveAttribute("target", "_blank")
  27. await expect(page.getByText("工具活动 · 2 条", { exact: true })).toBeVisible()
  28. await page.getByText("工具活动 · 2 条", { exact: true }).click()
  29. await expect(page.getByText("调用工具 · file_search", { exact: true })).toBeVisible()
  30. await expect(page.getByText("找到 2 份材料", { exact: true })).toBeVisible()
  31. await page.locator("details.paas-activity").getByText("技术信息", { exact: true }).click()
  32. await expect(page.locator(".paas-activity-raw pre")).toContainText('"type": "tool_call"')
  33. await expect(page.getByRole("button", { name: "停止任务", exact: true })).toBeVisible()
  34. await page.getByRole("button", { name: "同意并继续", exact: true }).click()
  35. await expect(page.getByRole("button", { name: "同意并继续", exact: true })).toHaveCount(0)
  36. await page.locator(".paas-result-panel > summary").click()
  37. await expect(page.getByRole("heading", { name: "成果 · 1", exact: true })).toBeVisible()
  38. await expect(page.getByLabel("任务进度与成果").getByText("研究计划成果.pdf", { exact: true })).toBeVisible()
  39. await expect(page.getByText("没有可保存的工作文件。", { exact: true })).toHaveCount(0)
  40. await page.getByRole("button", { name: "保存成果", exact: true }).click()
  41. await expect(page.getByText("文件已保存。", { exact: true })).toBeVisible()
  42. await page.locator(".paas-work-directory > summary").click()
  43. await page.getByRole("button", { name: /^(查看|刷新)工作文件$/ }).click()
  44. await page.getByRole("button", { name: "保存文件", exact: true }).first().click()
  45. await expect(page.getByText("文件已保存。", { exact: true })).toBeVisible()
  46. await expect(page.getByText("没有可保存的工作文件。", { exact: true })).toHaveCount(0)
  47. const calls = await page.evaluate(
  48. () => (window as unknown as { paasTestCalls: Record<string, unknown>[] }).paasTestCalls,
  49. )
  50. expect(calls.find((value) => value.action === "execute")?.files).toEqual([{ file_id: "file_1", name: "材料.pdf" }])
  51. expect(calls.filter((value) => value.action === "execute")).toHaveLength(1)
  52. expect(calls.find((value) => value.action === "confirm")).toMatchObject({ approvalID: "approval_1", approved: true })
  53. const downloads = calls.filter((value) => value.action === "download")
  54. expect(downloads).toHaveLength(2)
  55. expect(downloads[0]).toMatchObject({ artifactID: "artifact_1", name: "研究计划成果.pdf" })
  56. expect(downloads[1]).toMatchObject({ path: "final/研究计划.pdf" })
  57. await expect(page.getByText("等待人工确认 · run_1", { exact: true })).toHaveCount(0)
  58. expect(errors).toEqual([])
  59. await page.screenshot({ path: "/tmp/lambda-desktop-workbench.png", fullPage: true })
  60. })
  61. test("pause, resume and stop use the existing task without resubmission", async ({ page }) => {
  62. await page.goto("/e2e/paas/index.html")
  63. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  64. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  65. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  66. await expect(page.locator(".paas-topbar-chat-title")).toBeVisible()
  67. await expect(page.getByText("任务后台执行 · 会话与草稿自动保存", { exact: true })).toHaveCount(0)
  68. await page.getByRole("button", { name: "智能体", exact: true }).click()
  69. await page.getByRole("button", { name: "与 科研助手 对话", exact: true }).click()
  70. await page.getByRole("textbox", { name: "消息", exact: true }).fill("持续研究")
  71. await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter")
  72. await page.getByRole("button", { name: "暂停", exact: true }).click()
  73. await expect(page.getByRole("button", { name: "停止任务", exact: true })).toBeVisible()
  74. await page.getByRole("button", { name: "继续执行", exact: true }).click()
  75. await page.getByRole("button", { name: "停止任务", exact: true }).click()
  76. await expect(page.getByRole("button", { name: "停止任务", exact: true })).toHaveCount(0)
  77. const calls = await page.evaluate(
  78. () => (window as unknown as { paasTestCalls: Record<string, unknown>[] }).paasTestCalls,
  79. )
  80. expect(calls.filter((value) => value.action === "execute")).toHaveLength(1)
  81. expect(calls.find((value) => value.action === "resume")).toMatchObject({ checkpointID: "checkpoint_1" })
  82. expect(calls.filter((value) => value.action === "run").length).toBeLessThan(12)
  83. })
  84. test("narrow navigation opens as a drawer and switches pages without leaving history behind", async ({ page }) => {
  85. await page.setViewportSize({ width: 600, height: 800 })
  86. await page.goto("/e2e/paas/index.html")
  87. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  88. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  89. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  90. await page.getByRole("button", { name: "打开导航", exact: true }).click()
  91. await expect(page.getByRole("textbox", { name: "搜索会话标题", exact: true })).toBeVisible()
  92. await expect(page.locator(".paas-new-session")).toBeFocused()
  93. await expect(page.locator('.paas-sidebar nav button[aria-label="工作台"]')).toHaveCount(0)
  94. await expect(page.locator('.paas-sidebar nav button[aria-label="资源检查"]')).toHaveCount(0)
  95. await expect(page.locator('.paas-sidebar nav button[aria-label="平台连接"]')).toHaveCount(0)
  96. await expect(page.locator('.paas-sidebar nav button[aria-label="平台设置"]')).toHaveCount(1)
  97. await page.locator('.paas-sidebar nav button[aria-label="智能体"]').click()
  98. await expect(page.getByRole("heading", { name: "智能体", exact: true })).toBeVisible()
  99. await expect(page.getByRole("button", { name: "打开导航", exact: true })).toBeVisible()
  100. await page.getByRole("button", { name: "打开导航", exact: true }).click()
  101. await expect(page.getByRole("textbox", { name: "搜索会话标题", exact: true })).toBeVisible()
  102. await page.keyboard.press("Escape")
  103. await expect(page.getByRole("textbox", { name: "搜索会话标题", exact: true })).toBeHidden()
  104. await expect(page.getByRole("button", { name: "打开导航", exact: true })).toBeFocused()
  105. })
  106. test("header actions stay aligned when the more menu opens", async ({ page }) => {
  107. await page.goto("/e2e/paas/index.html")
  108. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  109. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  110. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  111. await expect(page.getByRole("button", { name: "刷新历史会话", exact: true })).toBeVisible()
  112. await expect(page.locator(".paas-chat-header-actions")).toHaveCSS("display", "flex")
  113. const settings = page.locator(".paas-chat-header-actions").getByRole("button", { name: "研究设置", exact: true })
  114. const create = page.locator(".paas-chat-header-actions").getByRole("button", { name: "新会话", exact: true })
  115. const more = page.locator(".paas-more-actions > summary")
  116. const box = async (locator: typeof settings) => {
  117. const value = await locator.boundingBox()
  118. return (
  119. value && {
  120. x: Math.round(value.x),
  121. y: Math.round(value.y),
  122. width: Math.round(value.width),
  123. height: Math.round(value.height),
  124. }
  125. )
  126. }
  127. const before = { settings: await box(settings), create: await box(create), more: await box(more) }
  128. expect(new Set([before.settings?.y, before.create?.y, before.more?.y]).size).toBe(1)
  129. expect(before.more!.x).toBeGreaterThan(before.create!.x)
  130. await more.click()
  131. expect(await box(settings)).toEqual(before.settings)
  132. expect(await box(create)).toEqual(before.create)
  133. expect(await box(more)).toEqual(before.more)
  134. expect(await page.getByText("刷新历史会话", { exact: true }).count()).toBe(0)
  135. await page.keyboard.press("Escape")
  136. await expect(page.getByRole("button", { name: "重命名会话", exact: true })).toHaveCount(0)
  137. await more.click()
  138. await page.getByRole("textbox", { name: "消息", exact: true }).click()
  139. await expect(page.getByRole("button", { name: "重命名会话", exact: true })).toHaveCount(0)
  140. })
  141. test("wide layout keeps messages and composer on one reading axis", async ({ page }) => {
  142. await page.setViewportSize({ width: 1707, height: 1019 })
  143. await page.goto("/e2e/paas/index.html")
  144. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  145. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  146. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  147. await page.getByRole("textbox", { name: "消息", exact: true }).waitFor()
  148. const box = async (selector: string) => {
  149. const value = await page.locator(selector).boundingBox()
  150. return (
  151. value && {
  152. x: Math.round(value.x),
  153. width: Math.round(value.width),
  154. }
  155. )
  156. }
  157. const content = await box(".paas-chat-messages > div")
  158. const composer = await box(".paas-composer")
  159. expect(composer).toEqual(content)
  160. expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(1707)
  161. await page.getByRole("textbox", { name: "消息", exact: true }).fill("分析材料并制定研究计划")
  162. await page.getByRole("button", { name: "发送消息", exact: true }).click()
  163. await page.getByRole("button", { name: "同意并继续", exact: true }).waitFor()
  164. const live = await box(".paas-result-live")
  165. expect(live).toBeDefined()
  166. expect(Math.round(live!.x + live!.width / 2)).toBe(Math.round(content!.x + content!.width / 2))
  167. expect(live!.width).toBeLessThanOrEqual(content!.width)
  168. expect(live).toEqual(await box(".paas-chat-messages > div"))
  169. })
  170. test("history hides unused agents, collapses groups and starts a new session from any page", async ({ page }) => {
  171. await page.goto("/e2e/paas/index.html?groups")
  172. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  173. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  174. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  175. const sidebar = page.locator(".paas-sidebar")
  176. await expect(sidebar.locator(".paas-session-group")).toHaveCount(1)
  177. await expect(sidebar.getByText("未使用智能体", { exact: true })).toHaveCount(0)
  178. const group = sidebar.locator(".paas-session-group").first()
  179. await expect(group).toHaveAttribute("data-active", "true")
  180. const toggle = group.locator(".paas-session-toggle")
  181. await expect(toggle).toHaveAttribute("aria-expanded", "true")
  182. await toggle.click()
  183. await expect(group.locator(".paas-session-items")).toHaveCount(0)
  184. await toggle.click()
  185. await expect(group.locator(".paas-session-items")).toBeVisible()
  186. await sidebar.getByRole("button", { name: "平台任务", exact: true }).click()
  187. await page.getByLabel("项目范围", { exact: true }).selectOption("all")
  188. await expect(page.getByRole("heading", { name: "平台任务", exact: true })).toBeVisible()
  189. await expect(page.getByRole("columnheader", { name: "时间", exact: true })).toBeVisible()
  190. await page.locator(".paas-new-session").click()
  191. await expect(page.locator(".paas-topbar-page")).toHaveText("会话")
  192. await expect(page.locator(".paas-topbar-chat-title")).toHaveText("新会话")
  193. })
  194. test("agent directory filters locally and keeps distinct illustrations", async ({ page }) => {
  195. await page.goto("/e2e/paas/index.html?groups")
  196. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  197. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  198. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  199. await page.locator('.paas-sidebar nav button[aria-label="智能体"]').click()
  200. const cards = page.locator(".paas-agent-card")
  201. await expect(cards).toHaveCount(2)
  202. await page.getByLabel("搜索智能体", { exact: true }).fill("未使用")
  203. await expect(cards).toHaveCount(1)
  204. await expect(cards.locator("h2")).toHaveText("未使用智能体")
  205. await expect(cards.locator(".paas-agent-illustration")).toHaveAttribute("data-kind", "agent")
  206. await page.getByLabel("搜索智能体", { exact: true }).fill("")
  207. await expect(cards).toHaveCount(2)
  208. })
  209. test("settings tabs support arrow keys and expose the active tab panel", async ({ page }) => {
  210. await page.goto("/e2e/paas/index.html")
  211. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  212. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  213. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  214. await page.locator('.paas-sidebar nav button[aria-label="平台设置"]').click()
  215. const connection = page.getByRole("tab", { name: "平台连接", exact: true })
  216. const resources = page.getByRole("tab", { name: "资源检查", exact: true })
  217. await connection.focus()
  218. await page.keyboard.press("ArrowRight")
  219. await expect(resources).toHaveAttribute("aria-selected", "true")
  220. await expect(resources).toBeFocused()
  221. await expect(page.getByRole("tabpanel", { name: "资源检查", exact: true })).toBeVisible()
  222. await page.keyboard.press("ArrowLeft")
  223. await expect(connection).toHaveAttribute("aria-selected", "true")
  224. })
  225. test("empty new sessions stay out of history and persistence", async ({ page }) => {
  226. await page.goto("/e2e/paas/index.html")
  227. const connect = async () => {
  228. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  229. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  230. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  231. await page.getByRole("textbox", { name: "消息", exact: true }).waitFor()
  232. }
  233. await connect()
  234. const sidebar = page.locator(".paas-sidebar")
  235. await page.locator(".paas-new-session").click()
  236. await page.locator(".paas-new-session").click()
  237. await expect(sidebar.locator(".paas-session-items").getByRole("button", { name: "新会话", exact: true })).toHaveCount(
  238. 0,
  239. )
  240. await expect(page.locator(".paas-topbar-chat-title")).toHaveText("新会话")
  241. await page.getByRole("textbox", { name: "消息", exact: true }).fill("未发送草稿")
  242. await expect(sidebar.locator(".paas-session-items").getByRole("button", { name: "新会话", exact: true })).toHaveCount(
  243. 0,
  244. )
  245. await page.reload()
  246. await connect()
  247. await expect(sidebar.locator(".paas-session-items").getByRole("button", { name: "新会话", exact: true })).toHaveCount(
  248. 0,
  249. )
  250. await expect(page.getByRole("textbox", { name: "消息", exact: true })).toHaveValue("未发送草稿")
  251. await page.getByRole("textbox", { name: "消息", exact: true }).fill("真实研究")
  252. await page.getByRole("button", { name: "发送消息", exact: true }).click()
  253. await expect(sidebar.getByRole("button", { name: /真实研究/ })).toBeVisible()
  254. })
  255. test("the page-bar conversation title can be renamed and saved", async ({ page }) => {
  256. await page.goto("/e2e/paas/index.html")
  257. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  258. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  259. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  260. await page.getByRole("textbox", { name: "消息", exact: true }).fill("可改标题的研究")
  261. await page.getByRole("button", { name: "发送消息", exact: true }).click()
  262. await page.getByRole("button", { name: "同意并继续", exact: true }).waitFor()
  263. const title = page.locator(".paas-topbar-chat-title")
  264. await title.click()
  265. const input = page.getByRole("textbox", { name: "会话名称", exact: true })
  266. await input.fill("自定义研究标题")
  267. await input.press("Enter")
  268. await expect(title).toHaveText("自定义研究标题")
  269. })
  270. test("left navigation resizes, collapses into an icon rail and persists", async ({ page }) => {
  271. await page.setViewportSize({ width: 1440, height: 900 })
  272. await page.goto("/e2e/paas/index.html")
  273. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  274. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  275. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  276. await page.locator(".paas-topbar-chat-title").waitFor()
  277. const workspace = page.locator(".paas-workspace")
  278. const sidebar = page.locator(".paas-sidebar")
  279. const splitter = page.locator(".paas-splitter-nav")
  280. await expect(sidebar).toHaveCSS("width", "240px")
  281. const first = await splitter.boundingBox()
  282. await page.mouse.move(first!.x + 3, first!.y + 200)
  283. await page.mouse.down()
  284. await page.mouse.move(first!.x - 77, first!.y + 200, { steps: 6 })
  285. await page.mouse.up()
  286. await expect(workspace).toHaveClass(/paas-nav-rail/)
  287. await expect(sidebar).toHaveCSS("width", "56px")
  288. await expect(page.getByRole("button", { name: "会话", exact: true })).toBeVisible()
  289. await page.getByRole("button", { name: "展开导航", exact: true }).click()
  290. await expect(sidebar).toHaveCSS("width", "240px")
  291. const second = await splitter.boundingBox()
  292. await page.mouse.move(second!.x + 3, second!.y + 200)
  293. await page.mouse.down()
  294. await page.mouse.move(second!.x + 43, second!.y + 200, { steps: 4 })
  295. await page.mouse.up()
  296. await expect(sidebar).toHaveCSS("width", "280px")
  297. await page.reload()
  298. await expect(page.locator(".paas-sidebar")).toHaveCSS("width", "280px")
  299. })
  300. test("topbar actions are icon-only with accessible names and titles", async ({ page }) => {
  301. await page.goto("/e2e/paas/index.html")
  302. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  303. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  304. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  305. await page.locator(".paas-topbar-chat-title").waitFor()
  306. const actions = page.locator(".paas-chat-header-actions")
  307. const settings = actions.getByRole("button", { name: "研究设置", exact: true })
  308. const create = actions.getByRole("button", { name: "新会话", exact: true })
  309. const workspace = actions.getByRole("button", { name: "在开发区打开工作区", exact: true })
  310. await expect(settings).toHaveAttribute("title", "研究设置")
  311. await expect(create).toHaveAttribute("title", "新会话")
  312. await expect(workspace).toHaveAttribute("aria-label", "在开发区打开工作区")
  313. await expect(settings).not.toContainText("研究设置")
  314. await expect(create).not.toContainText("新会话")
  315. await expect(workspace).not.toContainText("在开发区打开工作区")
  316. const summary = page.locator(".paas-more-actions > summary")
  317. await expect(summary).toHaveAttribute("aria-label", "更多操作")
  318. await expect(summary).not.toContainText("更多操作")
  319. await summary.click()
  320. await expect(page.getByRole("button", { name: "重命名会话", exact: true })).toBeVisible()
  321. })
  322. test("generated file cards open the right preview, resize and close at the lower bound", async ({ page }) => {
  323. await page.setViewportSize({ width: 1440, height: 900 })
  324. await page.goto("/e2e/paas/index.html")
  325. await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
  326. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  327. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  328. await page.locator(".paas-topbar-chat-title").waitFor()
  329. const toggle = page.getByRole("button", { name: "预览", exact: true })
  330. await toggle.click()
  331. await expect(page.locator(".paas-preview-empty")).toBeVisible()
  332. await page.getByRole("button", { name: "关闭预览", exact: true }).click()
  333. await page
  334. .getByRole("button", { name: /已有研究/ })
  335. .first()
  336. .click()
  337. const card = page.getByRole("button", { name: "预览 研究计划.md", exact: true })
  338. await card.waitFor()
  339. await card.click()
  340. const preview = page.locator(".paas-preview")
  341. await expect(preview).toBeVisible()
  342. await expect(preview.locator(".paas-preview-meta")).toContainText("研究计划.md")
  343. await expect(preview.getByRole("heading", { name: "可预览的研究计划", exact: true })).toBeVisible()
  344. await expect(preview.getByRole("button", { name: "保存文件", exact: true })).toBeVisible()
  345. await expect(card).toHaveClass(/is-selected/)
  346. await expect(toggle).toHaveAttribute("aria-pressed", "true")
  347. await page.getByRole("button", { name: "预览 研究计划.pdf", exact: true }).click()
  348. await expect(preview.locator(".paas-preview-meta")).toContainText("研究计划.pdf")
  349. await card.click()
  350. await expect(preview.getByRole("heading", { name: "可预览的研究计划", exact: true })).toBeVisible()
  351. expect(
  352. await page.evaluate(
  353. () =>
  354. window.paasTestCalls.filter(
  355. (call) => call.action === "preview-file" && (call as Record<string, unknown>).name === "研究计划.md",
  356. ).length,
  357. ),
  358. ).toBe(2)
  359. const splitter = page.locator(".paas-splitter-preview")
  360. const first = await splitter.boundingBox()
  361. await page.mouse.move(first!.x + 3, first!.y + 200)
  362. await page.mouse.down()
  363. await page.mouse.move(first!.x - 77, first!.y + 200, { steps: 5 })
  364. await page.mouse.up()
  365. await expect(preview).toHaveCSS("width", "520px")
  366. const second = await splitter.boundingBox()
  367. await page.mouse.move(second!.x + 3, second!.y + 200)
  368. await page.mouse.down()
  369. await page.mouse.move(second!.x + 343, second!.y + 200, { steps: 6 })
  370. await page.mouse.up()
  371. await expect(preview).toHaveCount(0)
  372. await expect(toggle).toHaveAttribute("aria-pressed", "false")
  373. await toggle.click()
  374. await expect(page.locator(".paas-preview")).toHaveCSS("width", "520px")
  375. await page.keyboard.press("Escape")
  376. await expect(page.locator(".paas-preview")).toHaveCount(0)
  377. })
  378. test("managed deployment locks the platform address and model fields", async ({ page }) => {
  379. await page.goto("/e2e/paas/index.html?managed&ux")
  380. const address = page.locator('input[type="url"]')
  381. await expect(address).toHaveValue("https://team.example")
  382. await expect(address).toHaveAttribute("readonly", "")
  383. await expect(page.getByRole("button", { name: "一键连接本机", exact: true })).toHaveCount(0)
  384. await page.getByLabel("API Key", { exact: true }).fill("test-only")
  385. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  386. await expect(page.locator(".paas-topbar-chat-title")).toBeVisible()
  387. await page.getByRole("button", { name: "智能体", exact: true }).click()
  388. await page.getByRole("button", { name: "编辑 科研助手", exact: true }).click()
  389. await expect(page.getByRole("heading", { name: "编辑智能体", exact: true })).toBeVisible()
  390. await expect(page.getByText("模型由平台统一提供,不能在客户端修改。", { exact: true })).toBeVisible()
  391. await expect(page.getByText("模型提供商", { exact: true })).toHaveCount(0)
  392. await expect(page.getByText("高级配置(JSON)", { exact: true })).toHaveCount(0)
  393. })