import { expect, test, type Page } from "@playwright/test" async function connect(page: Page, query = "") { await page.goto(`/e2e/paas/index.html${query}`) await page.getByLabel("API Key", { exact: true }).fill("qa-fixes") await page.getByRole("button", { name: "连接平台", exact: true }).click() await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled() } test("all primary page bars share one height and right edge", async ({ page }) => { await page.setViewportSize({ width: 1280, height: 800 }) await connect(page, "?os=windows") const pages = ["会话", "智能体", "平台任务", "平台设置"] const boxes = [] for (const name of pages) { await page.getByRole("button", { name, exact: true }).click() await expect(page.locator(".paas-topbar-page")).toHaveText(name) boxes.push( await page.locator(".paas-topbar").evaluate((element) => { const box = element.getBoundingClientRect() return { height: box.height, right: box.right } }), ) } expect(new Set(boxes.map((box) => Math.round(box.height))).size).toBe(1) expect(new Set(boxes.map((box) => Math.round(box.right))).size).toBe(1) }) test("completed research does not display an elapsed-time label", async ({ page }) => { await connect(page, "?completed") await page .getByRole("button", { name: /已有研究/ }) .first() .click() const summary = page.locator(".paas-task-summary").first() await expect(summary).toContainText("已完成") await expect(summary).not.toContainText("已用时") }) test("generated files separate preview cards from collapsed technical files", async ({ page }) => { await page.setViewportSize({ width: 1280, height: 800 }) await connect(page, "?files") await page .getByRole("button", { name: /已有研究/ }) .first() .click() const section = page.getByRole("region", { name: "生成文件" }) await expect(section.locator("header span")).toHaveText("3") const card = section.getByRole("button", { name: "预览 研究计划.md", exact: true }) await expect(card).toBeVisible() const alignment = await card.evaluate((element) => { const label = element.querySelector("small")!.getBoundingClientRect() const name = element.querySelector(".paas-file-card-name")!.getBoundingClientRect() return { left: Math.abs(label.left - name.left), stacked: label.top >= name.bottom } }) expect(alignment.left).toBeLessThanOrEqual(1) expect(alignment.stacked).toBe(true) await expect(section.getByText("技术文件 · 4", { exact: true })).toBeVisible() await expect(section.locator('button[aria-label="预览 manifest.json"]')).toHaveCount(2) await expect(section.locator('button[aria-label="预览 trace.json"]')).toBeHidden() await expect(section.locator('button[aria-label="预览 analysis.py"]')).toBeHidden() await section.getByText("技术文件 · 4", { exact: true }).click() await expect(section.getByRole("button", { name: "预览 trace.json", exact: true })).toBeVisible() await expect(section.getByRole("button", { name: "预览 analysis.py", exact: true })).toBeVisible() await expect(section.locator('button[aria-label="预览 manifest.json"]')).toHaveCount(2) }) test("completed work files show a total and collapse technical files", async ({ page }) => { await page.goto("/e2e/paas/index.html?panel") await expect(page.getByRole("button", { name: "暂停", exact: true })).toBeVisible() await page.evaluate(() => { window.paasPanelTest.files = [ { name: "研究报告.md", path: "final/研究报告.md" }, { name: "config.json", path: "work/config.json" }, ] }) await page.locator(".paas-work-directory > summary").click() await page.getByRole("button", { name: "查看工作文件", exact: true }).click() await expect(page.getByRole("heading", { name: "工作文件 · 2 个路径", exact: true })).toBeVisible() await expect(page.getByText("final/研究报告.md", { exact: true })).toBeVisible() await expect(page.getByText("技术文件 · 1", { exact: true })).toBeVisible() await expect(page.getByText("work/config.json", { exact: true })).toBeHidden() await page.getByText("技术文件 · 1", { exact: true }).click() await expect(page.getByText("work/config.json", { exact: true })).toBeVisible() })