acceptance.spec.ts 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { expect, test, type Page } from "@playwright/test"
  2. async function connect(page: Page) {
  3. await page.goto("/e2e/paas/index.html?ux")
  4. await page.getByLabel("API Key", { exact: true }).fill("acceptance")
  5. await page.getByRole("button", { name: "连接平台", exact: true }).click()
  6. await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
  7. }
  8. test("IME confirmation retains the draft until a separate Enter sends it", async ({ page }) => {
  9. await connect(page)
  10. const input = page.getByRole("textbox", { name: "消息", exact: true })
  11. await input.fill("确认中文研究目标")
  12. await input.dispatchEvent("keydown", { key: "Enter", code: "Enter", keyCode: 229, bubbles: true })
  13. await expect(input).toHaveValue("确认中文研究目标")
  14. expect(
  15. await page.evaluate(
  16. () =>
  17. (window as unknown as { paasTestCalls: { action: string }[] }).paasTestCalls.filter(
  18. (c) => c.action === "execute",
  19. ).length,
  20. ),
  21. ).toBe(0)
  22. await input.press("Enter")
  23. await expect(input).toHaveValue("")
  24. })
  25. test("widening the window releases the drawer keyboard trap", async ({ page }) => {
  26. await page.setViewportSize({ width: 587, height: 800 })
  27. await connect(page)
  28. await page.getByRole("button", { name: "打开导航", exact: true }).click()
  29. await expect(page.locator(".paas-nav-open")).toHaveCount(1)
  30. await page.setViewportSize({ width: 1280, height: 800 })
  31. await expect(page.locator(".paas-nav-open")).toHaveCount(0)
  32. await page.setViewportSize({ width: 587, height: 800 })
  33. await expect(page.getByRole("button", { name: "打开导航", exact: true })).toBeVisible()
  34. await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeInViewport()
  35. })
  36. test("choosing a suggested research task focuses the editable draft", async ({ page }) => {
  37. await connect(page)
  38. await page.locator(".paas-suggestions button").first().click()
  39. const input = page.getByRole("textbox", { name: "消息", exact: true })
  40. await expect(input).toBeFocused()
  41. await expect(input).not.toHaveValue("")
  42. })
  43. test("long attachment names keep removal and sending accessible in narrow windows", async ({ page }) => {
  44. await page.setViewportSize({ width: 520, height: 705 })
  45. await connect(page)
  46. const name = `${"research_material_".repeat(15)}.txt`
  47. const transfer = await page.evaluateHandle((name) => {
  48. const data = new DataTransfer()
  49. data.items.add(new File(["research"], name, { type: "text/plain" }))
  50. return data
  51. }, name)
  52. await page.locator(".paas-composer").dispatchEvent("drop", { dataTransfer: transfer })
  53. const remove = page.getByRole("button", { name: `移除${name}`, exact: true })
  54. await expect(remove).toBeInViewport()
  55. expect(await page.locator(".paas-composer").evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true)
  56. await remove.click()
  57. await expect(remove).toHaveCount(0)
  58. })
  59. test("partial research explains generated output failures and keeps the report available", async ({ page }) => {
  60. await connect(page)
  61. await page.getByRole("textbox", { name: "消息", exact: true }).fill("部分成果验收")
  62. await page.getByRole("button", { name: "发送消息", exact: true }).click()
  63. await expect(page.getByRole("button", { name: "暂停", exact: true })).toBeVisible()
  64. await page.evaluate(() =>
  65. window.paasUX.update("ux_1", {
  66. status: "partial",
  67. output: "已保留的研究方案",
  68. research: {
  69. science: {
  70. outcome: {
  71. plan: {
  72. issues: [
  73. {
  74. code: "review_format_failure",
  75. stage: "round-01-plan-build",
  76. message: "Plan generation exhausted local structural repairs; prior artifacts were preserved",
  77. },
  78. ],
  79. },
  80. },
  81. },
  82. },
  83. }),
  84. )
  85. await page.getByRole("button", { name: "刷新状态", exact: true }).click()
  86. await page.getByText("待处理原因(1 项)", { exact: true }).click()
  87. await expect(page.getByText("生成结果未通过格式校验", { exact: true })).toBeVisible()
  88. await expect(page.getByText("需要检查输入材料", { exact: true })).toHaveCount(0)
  89. await expect(page.getByRole("button", { name: "基于已有成果续研", exact: true })).toBeVisible()
  90. await expect(page.getByRole("button", { name: "阅读与对比", exact: true })).toBeVisible()
  91. })