feat(workbench): integrate runtime data and map tooling

This commit is contained in:
2026-09-22 10:45:46 +08:00
parent bf44cc0f25
commit bebcf2a06c
163 changed files with 15642 additions and 1312 deletions
+22 -5
View File
@@ -1,4 +1,14 @@
import { expect, test } from "@playwright/test";
import { expect, test, type Page } from "@playwright/test";
import { mockAgentApi } from "./support/mock-agent-api";
test.beforeEach(async ({ page }) => {
await mockAgentApi(page);
});
async function openAgentPanel(page: Page) {
await page.getByRole("button", { name: /展开 Agent 助手面板/ }).click();
await expect(page.getByRole("complementary", { name: "Agent 命令面板" })).toBeVisible();
}
test("speech capability detection preserves the server hydration tree", async ({ page }) => {
const hydrationErrors: string[] = [];
@@ -16,6 +26,7 @@ test("speech capability detection preserves the server hydration tree", async ({
});
});
await page.goto("/", { waitUntil: "domcontentloaded" });
await openAgentPanel(page);
await expect(page.getByRole("button", { name: "语音输入" })).toBeVisible();
await expect(page.getByRole("button", { name: "权限批准模式" })).toBeVisible();
@@ -46,6 +57,7 @@ test("speech recognition failure clears the active animation and explains the er
});
});
await page.goto("/", { waitUntil: "domcontentloaded" });
await openAgentPanel(page);
await page.getByRole("button", { name: "语音输入" }).click();
@@ -54,7 +66,7 @@ test("speech recognition failure clears the active animation and explains the er
await expect(page.getByText("无法使用麦克风,请在浏览器地址栏允许麦克风权限后重试")).toBeVisible();
});
test("speech recognition writes final transcript into the prompt", async ({ page }) => {
test("speech recognition appends every final transcript in one result batch", async ({ page }) => {
await page.addInitScript(() => {
Object.defineProperty(window, "SpeechRecognition", {
configurable: true,
@@ -64,8 +76,11 @@ test("speech recognition writes final transcript into the prompt", async ({ page
start() {
window.setTimeout(() => {
const result = Object.assign([{ transcript: "检查城南泵站水位" }], { isFinal: true });
this.onresult?.({ resultIndex: 0, results: [result] });
const firstResult = Object.assign([{ transcript: "检查城南泵站" }], {
isFinal: true
});
const secondResult = Object.assign([{ transcript: "水位" }], { isFinal: true });
this.onresult?.({ resultIndex: 0, results: [firstResult, secondResult] });
}, 20);
}
@@ -78,10 +93,11 @@ test("speech recognition writes final transcript into the prompt", async ({ page
});
});
await page.goto("/", { waitUntil: "domcontentloaded" });
await openAgentPanel(page);
await page.getByRole("button", { name: "语音输入" }).click();
await expect(page.getByPlaceholder("输入调度问题,Agent 将通过后端会话流式响应")).toHaveValue("检查城南泵站水位");
await expect(page.getByPlaceholder("输入调度问题,Agent 将通过后端会话流式响应")).toHaveValue("检查城南泵站 水位");
});
test("speech recognition pulse stays transparent across its loop boundary", async ({ page }) => {
@@ -98,6 +114,7 @@ test("speech recognition pulse stays transparent across its loop boundary", asyn
});
});
await page.goto("/", { waitUntil: "domcontentloaded" });
await openAgentPanel(page);
await page.getByRole("button", { name: "语音输入" }).click();