import { expect, test } from "@playwright/test" for (const theme of ["light", "dark"] as const) { for (const width of [360, 960, 1440]) { test(`workspace pages keep controls within their reading column at ${width}px in ${theme}`, async ({ page, }, info) => { await page.setViewportSize({ width, height: 800 }) await page.emulateMedia({ colorScheme: theme }) await page.goto("/e2e/paas/index.html?setup&ux&unified") await page.getByRole("button", { name: "准备本机服务并连接", exact: true }).click() if (width > 1100) { const sidebar = page.locator(".paas-sidebar") expect( await sidebar .locator(".paas-sidebar-controls") .evaluate((element) => element.scrollHeight - element.clientHeight), ).toBeLessThanOrEqual(1) await expect(sidebar.getByRole("button", { name: "平台设置", exact: true })).toBeInViewport() const archive = sidebar.locator(".paas-archive-toggle") await expect(archive).toBeVisible() const geometry = await archive.evaluate((element) => { const button = element.getBoundingClientRect() const history = element.closest(".paas-nav-history")!.getBoundingClientRect() const footer = document.querySelector(".paas-sidebar-footer")!.getBoundingClientRect() return { bottom: button.bottom, historyBottom: history.bottom, footerTop: footer.top } }) expect(geometry.bottom).toBeLessThanOrEqual(geometry.historyBottom) expect(geometry.bottom).toBeLessThanOrEqual(geometry.footerTop) } for (const [index, name] of ["应用与插件", "智能体", "平台任务", "成果", "平台设置"].entries()) { const nav = page.getByRole("navigation", { name: "功能导航", exact: true }) if (!(await nav.isVisible())) await page.getByRole("button", { name: "打开导航", exact: true }).click() await nav.getByRole("button", { name, exact: true }).click() await expect( page.getByRole("heading", { name: name === "平台设置" ? "平台连接" : name, exact: true }).first(), ).toBeVisible() const overflow = await page.locator(".paas-content").evaluate((element) => { const bounds = element.getBoundingClientRect() return [...element.querySelectorAll("button,input,select,textarea")] .filter((control) => control.getClientRects().length && !control.closest("[role=table],table,pre")) .flatMap((control) => { const rect = control.getBoundingClientRect() return rect.left < bounds.left - 1 || rect.right > bounds.right + 1 ? [ { text: control.getAttribute("aria-label") || control.textContent, left: rect.left, right: rect.right, }, ] : [] }) }) expect(overflow).toEqual([]) expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width) await page.screenshot({ path: info.outputPath(`${index}-${theme}-${width}.png`) }) } await page.getByRole("button", { name: "检查与配置资源", exact: true }).click() await expect(page.getByRole("heading", { name: "模型与资源", exact: true })).toBeVisible() const model = page.getByLabel("模型名称", { exact: true }) const provider = page.getByLabel("模型服务", { exact: true }) if (width > 760) { const fields = await Promise.all([model, provider].map((field) => field.boundingBox())) expect(Math.abs(fields[0]!.y - fields[1]!.y)).toBeLessThanOrEqual(1) expect(Math.abs(fields[0]!.height - fields[1]!.height)).toBeLessThanOrEqual(1) } await page.screenshot({ path: info.outputPath(`model-${theme}-${width}.png`) }) }) } } test("long delegated task names keep their arrow and dialog close action reachable", async ({ page }, info) => { await page.setViewportSize({ width: 360, height: 800 }) await page.goto("/e2e/paas/index.html?ux") const title = `分析_${"sales_2026_".repeat(12)}` await page.evaluate((title) => { window.paasUX.threads = [ { id: "parent", agent_id: "research", title: "主会话" }, { id: "child", agent_id: "research", title, delegated: true, origin: { kind: "paas", session_id: "parent" } }, ] window.paasUX.add({ run_id: "parent-run", agent_id: "research", thread_id: "parent", input: "主会话", output: "研究结果", status: "completed", }) }, title) await page.getByLabel("API Key", { exact: true }).fill("layout-only") await page.getByRole("button", { name: "连接平台", exact: true }).click() await page.getByRole("button", { name: "打开导航", exact: true }).click() await page.locator(".paas-sidebar").getByRole("button", { name: "主会话", exact: true }).click() const children = page.getByRole("region", { name: "本会话的子任务" }) const open = children.getByRole("button", { name: title, exact: true }) await open.scrollIntoViewIfNeeded() expect(await children.evaluate((element) => element.scrollWidth - element.clientWidth)).toBeLessThanOrEqual(1) await open.click() const dialog = page.getByRole("dialog") await expect(dialog).toBeVisible() const close = dialog.locator('[data-slot="dialog-close-button"]') await expect(close).toBeInViewport() expect(await dialog.evaluate((element) => element.scrollWidth - element.clientWidth)).toBeLessThanOrEqual(1) const heading = await dialog.locator('[data-slot="dialog-title"]').boundingBox() const button = await close.boundingBox() expect(heading!.x + heading!.width).toBeLessThanOrEqual(button!.x - 8) await page.screenshot({ path: info.outputPath("long-child-title.png") }) await close.click() await expect(open).toBeFocused() })