| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import { expect, test, type Page } from "@playwright/test"
- async function connect(page: Page) {
- await page.goto("/e2e/paas/index.html?ux")
- await page.getByLabel("API Key", { exact: true }).fill("polish-test")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
- }
- test("optional resource probes never block research and model invocation is explicit", async ({ page }) => {
- await connect(page)
- await expect(page.getByRole("button", { name: "定时任务", exact: true })).toHaveCount(0)
- await page.getByRole("button", { name: "平台设置", exact: true }).click()
- await page.getByRole("tab", { name: "资源检查", exact: true }).click()
- await page.getByRole("button", { name: "检查资源", exact: true }).click()
- await page.getByRole("button", { name: "测试模型连接", exact: true }).click()
- await page.getByRole("button", { name: "直接开始任务", exact: true }).click()
- await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
- const calls = await page.evaluate(() => window.paasTestCalls)
- expect(calls.filter((c) => c.action === "verify").map((c) => c.checkModel)).toEqual([false, true])
- expect(calls.filter((c) => c.action === "execute")).toHaveLength(0)
- })
- test("continuation keeps a compact reference across reload and submits the original report once", async ({ page }) => {
- await connect(page)
- 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: "# 原始方案\n证据甲,不可丢失。" }),
- )
- 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.getByRole("textbox", { name: "消息", exact: true })).toHaveValue("补充对照设计")
- await expect(page.getByLabel("已引用研究报告")).toHaveCount(1)
- await page.reload()
- await page.getByLabel("API Key", { exact: true }).fill("polish-test")
- await page.getByRole("button", { name: "连接平台", exact: true }).click()
- await expect(page.getByLabel("已引用研究报告")).toContainText("证据甲")
- await page.getByRole("button", { name: "发送消息", exact: true }).click()
- const calls = await page.evaluate(() => window.paasTestCalls.filter((c) => c.action === "execute"))
- expect(calls).toHaveLength(1)
- expect(String(calls[0].input).match(/证据甲/g)).toHaveLength(1)
- expect(calls[0].input).toContain("补充对照设计")
- await expect(page.getByLabel("已引用研究报告")).toHaveCount(0)
- })
- test("report reader compares versions and passes the selected export format", async ({ page }, info) => {
- await connect(page)
- await page.evaluate(() => {
- window.paasUX.add({
- run_id: "v1",
- agent_id: "research",
- thread_id: "report",
- input: "版本一",
- output: "# 方案\n\n旧条件",
- status: "completed",
- })
- window.paasUX.add({
- run_id: "v2",
- agent_id: "research",
- thread_id: "report",
- input: "版本二",
- output: "# 方案\n\n新条件",
- status: "completed",
- })
- })
- await page.getByRole("button", { name: "平台任务", exact: true }).click()
- await page.getByLabel("项目范围", { exact: true }).selectOption("all")
- await page.getByRole("button", { name: "刷新任务", exact: true }).click()
- await page.getByRole("row").filter({ hasText: "版本二" }).getByRole("button", { name: "打开任务" }).click()
- await page.getByRole("button", { name: "阅读与对比", exact: true }).last().click()
- const dialog = page.getByRole("dialog")
- await dialog.getByRole("button", { name: "对比此前报告", exact: true }).click()
- await expect(dialog.locator('[data-change="added"]')).toContainText("新条件")
- await expect(dialog.locator('[data-change="removed"]')).toContainText("旧条件")
- await dialog.getByRole("button", { name: "导出 Word", exact: true }).click()
- expect(
- await page.evaluate(() => window.paasTestCalls.filter((c) => c.action === "export-report").at(-1)?.format),
- ).toBe("docx")
- await page.screenshot({ path: info.outputPath("report-reader.png"), fullPage: true })
- })
- test("research progress displays reported usage and outstanding work without inventing completion", async ({
- page,
- }, info) => {
- await connect(page)
- 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", {
- stage_name: "方案审阅",
- usage: { total_tokens: 42000, usage_complete: false },
- research: {
- science: {
- main_flow: { rounds_completed: 2 },
- next_step: "补充实验条件",
- outcome: { sections: [{ title: "已有产物与待办", lines: ["待办:核对适用范围"] }] },
- },
- },
- }),
- )
- await page.getByRole("button", { name: "刷新状态", exact: true }).click()
- await expect(page.getByLabel("研究进展")).toContainText("42,000")
- await expect(page.getByLabel("研究进展")).toContainText("方案审阅")
- await expect(page.getByLabel("研究进展")).toContainText("用量仍在汇总")
- await page.getByLabel("研究进展").scrollIntoViewIfNeeded()
- await page.screenshot({ path: info.outputPath("research-progress.png"), fullPage: true })
- })
|