| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import { expect, test } from "@playwright/test"
- test("failed connection keeps the entered credentials for an explicit retry", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?ux")
- await page.evaluate(() => {
- window.paasUX.connectError = "无法连接 AgentPaaS,请检查网络。"
- })
- await page.getByLabel("API Key", { exact: true }).fill("retry-test-only")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByRole("alert")).toBeVisible()
- await expect(page.getByLabel("API Key", { exact: true })).toHaveValue("retry-test-only")
- await page.evaluate(() => {
- window.paasUX.connectError = ""
- })
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
- expect(await page.evaluate(() => window.paasTestCalls.some((c) => c.action === "execute"))).toBe(false)
- })
- test("directory failures change connection status while preserving drafts and recover without execution", async ({
- page,
- }, info) => {
- await page.goto("/e2e/paas/index.html?ux")
- await page.getByLabel("API Key", { exact: true }).fill("health-test-only")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await page.getByRole("textbox", { name: "消息", exact: true }).fill("保留我的研究问题")
- await page.evaluate(() => {
- window.paasUX.catalogError = "HTTP 401:平台凭证已失效"
- })
- await page.getByRole("button", { name: "查看平台连接状态", exact: true }).click()
- await page.getByRole("button", { name: "检查连接", exact: true }).click()
- await expect(page.getByRole("button", { name: "查看平台连接状态" })).toHaveText("连接待检查")
- await page.getByRole("button", { name: "会话", exact: true }).click()
- await expect(page.getByLabel("平台同步异常")).toBeVisible()
- await page.screenshot({ path: info.outputPath("connection-recovery.png"), fullPage: true })
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toHaveValue("保留我的研究问题")
- await page.evaluate(() => {
- window.paasUX.catalogError = ""
- })
- await page.getByRole("button", { name: "重试同步", exact: true }).click()
- await expect(page.getByRole("button", { name: "查看平台连接状态" })).toHaveText("平台已连接")
- await expect(page.getByLabel("平台同步异常")).toHaveCount(0)
- await expect(page.getByRole("alert")).toHaveCount(0)
- expect(await page.evaluate(() => window.paasTestCalls.some((c) => c.action === "execute"))).toBe(false)
- })
- test("editing connection returns to the form and restores the same account draft", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?ux")
- await page.getByLabel("API Key", { exact: true }).fill("same-account")
- 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 page.getByRole("button", { name: "修改连接", exact: true }).click()
- await expect(page.getByLabel("API Key", { exact: true })).toHaveValue("")
- await page.getByLabel("API Key", { exact: true }).fill("same-account")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toHaveValue("重连后继续填写")
- })
- test("disconnected conversation has an actionable connection entry", async ({ page }) => {
- await page.goto("/e2e/paas/index.html?ux")
- await page.getByRole("button", { name: "会话", exact: true }).click()
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByLabel("API Key", { exact: true })).toBeVisible()
- await expect(page.getByText("当前平台还没有可用智能体。", { exact: true })).toHaveCount(0)
- })
|