refactor: simplify workbench layout and browser tests

This commit is contained in:
2026-08-18 17:06:42 +08:00
parent bdf4436899
commit bdd5eff776
12 changed files with 448 additions and 201 deletions
+19 -12
View File
@@ -1,4 +1,19 @@
import { expect, test, type Locator } from "@playwright/test";
import { mockAgentApi } from "./support/mock-agent-api";
test.beforeEach(async ({ page }) => {
await mockAgentApi(page, {
sessions: [
{
session_id: "browser-history-session",
title: "城南供水压力复核",
created_at: "2026-07-21T09:30:00+08:00",
updated_at: "2026-07-21T10:35:00+08:00",
run_status: "completed"
}
]
});
});
type BoundingBox = {
x: number;
@@ -12,9 +27,7 @@ async function waitForAnimations(locator: Locator) {
const animations = element
.getAnimations({ subtree: true })
.filter((animation) => animation.effect?.getTiming().iterations !== Infinity);
await Promise.all(
animations.map((animation) => animation.finished.catch(() => undefined))
);
await Promise.all(animations.map((animation) => animation.finished.catch(() => undefined)));
});
}
@@ -103,9 +116,7 @@ async function expectIntegratedHeader(header: Locator) {
expect(composition.borderRadius).toBe("0px");
}
test("desktop Agent header expands into one attached acrylic history surface", async ({
page
}) => {
test("desktop Agent header expands into one attached acrylic history surface", async ({ page }) => {
await page.goto("/", { waitUntil: "domcontentloaded" });
const agentPanel = page.locator('aside[aria-label="Agent 命令面板"]');
@@ -194,16 +205,12 @@ test("desktop Agent header expands into one attached acrylic history surface", a
await expect(history).toBeHidden();
});
test("mobile Agent mirrors the desktop floating history surface", async ({
page
}) => {
test("mobile Agent mirrors the desktop floating history surface", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("/", { waitUntil: "domcontentloaded" });
await page.getByRole("button", { name: "打开 Agent 面板" }).click();
const agentPanel = page
.locator('aside[aria-label="Agent 命令面板"]')
.filter({ visible: true });
const agentPanel = page.locator('aside[aria-label="Agent 命令面板"]').filter({ visible: true });
await expect(agentPanel).toBeVisible();
await waitForAnimations(agentPanel);
const mobileSheet = page.getByRole("region", { name: "Agent 工作台抽屉" });