|
|
@@ -124,3 +124,76 @@ test("completed unread stays read after a reload", async ({ page }) => {
|
|
|
await expect(page.getByRole("heading", { name: "研究计划", exact: true })).toBeVisible()
|
|
|
await expect(page.getByRole("button", { name: /待处理/ })).toHaveCount(0)
|
|
|
})
|
|
|
+
|
|
|
+for (const width of [360, 520]) {
|
|
|
+ test(`inbox stays within a ${width}px window and restores focus when closed`, async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html?completed")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill(`inbox-width-${width}`)
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await page
|
|
|
+ .getByRole("button", { name: /已有研究/ })
|
|
|
+ .first()
|
|
|
+ .click()
|
|
|
+ await page.setViewportSize({ width, height: 650 })
|
|
|
+ const toggle = page.getByRole("button", { name: "待处理 1 项", exact: true })
|
|
|
+ await toggle.click()
|
|
|
+ const panel = page.getByRole("dialog", { name: "待处理" })
|
|
|
+ const bounds = await panel.boundingBox()
|
|
|
+ expect(bounds!.x).toBeGreaterThanOrEqual(0)
|
|
|
+ expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(width)
|
|
|
+ expect(bounds!.y + bounds!.height).toBeLessThanOrEqual(650)
|
|
|
+ await page.getByRole("button", { name: "关闭待处理", exact: true }).click()
|
|
|
+ await expect(panel).toHaveCount(0)
|
|
|
+ await expect(toggle).toBeFocused()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+test("unloaded inbox results stay unread after a failed fetch, then open the exact run on retry", async ({ page }) => {
|
|
|
+ await page.goto("/e2e/paas/index.html?ux")
|
|
|
+ await page.getByLabel("API Key", { exact: true }).fill("inbox-load")
|
|
|
+ await page.getByRole("button", { name: "连接平台", exact: true }).click()
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).fill("最初的研究")
|
|
|
+ await page.getByRole("button", { name: "发送消息", exact: true }).click()
|
|
|
+ await expect(page.getByRole("button", { name: "暂停", exact: true })).toBeVisible()
|
|
|
+ await page.evaluate(() => {
|
|
|
+ window.paasUX.update("ux_1", { status: "completed", output: "第一轮研究结果" })
|
|
|
+ })
|
|
|
+ await page.getByRole("button", { name: "刷新状态", exact: true }).click()
|
|
|
+ await expect(page.getByText("第一轮研究结果", { exact: true }).first()).toBeVisible()
|
|
|
+ await page.getByRole("textbox", { name: "消息", exact: true }).fill("保留的草稿")
|
|
|
+ await page.evaluate(() => {
|
|
|
+ window.paasUX.add({
|
|
|
+ run_id: "external_result",
|
|
|
+ agent_id: "research",
|
|
|
+ thread_id: "thread_ux_1",
|
|
|
+ status: "completed",
|
|
|
+ input: "另一轮研究",
|
|
|
+ output: "# 新增研究成果\n\n完成证据核验。",
|
|
|
+ updated_at: "2026-11-30T12:00:00Z",
|
|
|
+ })
|
|
|
+ Object.assign(window.paasUX, { threadError: "模拟会话读取失败" })
|
|
|
+ })
|
|
|
+ await page.getByRole("button", { name: "平台任务", exact: true }).click()
|
|
|
+ const toggle = page.getByRole("button", { name: "待处理 2 项", exact: true })
|
|
|
+ await expect(toggle).toBeVisible()
|
|
|
+ await toggle.click()
|
|
|
+ await page
|
|
|
+ .getByRole("dialog", { name: "待处理" })
|
|
|
+ .getByRole("button", { name: /另一轮研究/ })
|
|
|
+ .click()
|
|
|
+ await expect(page.getByRole("alert")).toBeVisible()
|
|
|
+ await page.getByText("查看错误详情", { exact: true }).click()
|
|
|
+ await expect(page.getByText("模拟会话读取失败", { exact: true })).toBeVisible()
|
|
|
+ await expect(toggle).toBeVisible()
|
|
|
+ await page.evaluate(() => Object.assign(window.paasUX, { threadError: "" }))
|
|
|
+ await toggle.click()
|
|
|
+ await page
|
|
|
+ .getByRole("dialog", { name: "待处理" })
|
|
|
+ .getByRole("button", { name: /另一轮研究/ })
|
|
|
+ .click()
|
|
|
+ const target = page.locator('.paas-chat-message[data-run-id="external_result"]')
|
|
|
+ await expect(target).toBeFocused()
|
|
|
+ await expect(target).toContainText("新增研究成果")
|
|
|
+ await expect(page.getByRole("textbox", { name: "消息", exact: true })).toHaveValue("保留的草稿")
|
|
|
+ await expect(page.getByRole("button", { name: "待处理 1 项", exact: true })).toBeVisible()
|
|
|
+})
|