import { expect, test, type Locator } from "@playwright/test" async function typography(locator: Locator) { return locator.evaluate((element) => { const style = getComputedStyle(element) return { size: Number.parseFloat(style.fontSize), weight: Number.parseFloat(style.fontWeight), family: style.fontFamily, } }) } test("page, section, field and helper text retain a distinct hierarchy", async ({ page }) => { await page.goto("/e2e/paas/index.html?ux") await page.getByLabel("API Key", { exact: true }).fill("test-only") await page.getByRole("button", { name: "连接平台", exact: true }).click() await page.getByRole("button", { name: "智能体", exact: true }).click() const title = await typography(page.getByRole("heading", { name: "智能体", exact: true })) const card = await typography(page.getByRole("heading", { name: "科研助手", exact: true })) const description = await typography(page.locator(".paas-agent-card-description")) expect(title.size).toBeGreaterThan(card.size) expect(card.size).toBeGreaterThan(description.size) expect(card.weight).toBeGreaterThan(description.weight) await page.getByRole("button", { name: "编辑 科研助手", exact: true }).click() await expect(page.getByRole("button", { name: "保存修改", exact: true })).toBeVisible() const section = await typography(page.locator("legend").filter({ hasText: "基本信息" })) const field = await typography(page.getByLabel("智能体名称", { exact: true })) const helper = await typography(page.locator(".paas-agent-edit-heading p")) expect(title.size).toBeGreaterThan(section.size) expect(section.size).toBeGreaterThan(field.size) expect(field.size).toBeGreaterThan(helper.size) expect(field.family).toBe(title.family) }) test("research text has readable body size and descending heading levels", async ({ page }) => { await page.goto("/e2e/paas/index.html") await page.getByLabel("API Key", { exact: true }).fill("test-only") 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 page.getByRole("textbox", { name: "消息", exact: true }).fill("制定研究计划") await page.getByRole("textbox", { name: "消息", exact: true }).press("Enter") const heading = page.getByRole("heading", { name: "研究计划", exact: true }) await expect(heading).toBeVisible() const title = await typography(heading) const body = await typography(page.locator('[data-component="markdown"] p').filter({ hasText: "已整理材料" })) const code = await typography(page.locator('[data-component="markdown"] pre code').first()) expect(title.size).toBeGreaterThan(body.size) expect(body.size).toBeGreaterThanOrEqual(16) expect(code.size).toBeGreaterThanOrEqual(13) expect(code.family).not.toBe(body.family) })