fix: polish agent voice controls
This commit is contained in:
@@ -83,3 +83,48 @@ test("speech recognition writes final transcript into the prompt", async ({ page
|
||||
|
||||
await expect(page.getByPlaceholder("输入调度问题,Agent 将通过后端会话流式响应")).toHaveValue("检查城南泵站水位");
|
||||
});
|
||||
|
||||
test("speech recognition pulse stays transparent across its loop boundary", async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
Object.defineProperty(window, "SpeechRecognition", {
|
||||
configurable: true,
|
||||
value: class SpeechRecognition {
|
||||
start() {}
|
||||
|
||||
stop() {}
|
||||
|
||||
abort() {}
|
||||
}
|
||||
});
|
||||
});
|
||||
await page.goto("/", { waitUntil: "domcontentloaded" });
|
||||
|
||||
await page.getByRole("button", { name: "语音输入" }).click();
|
||||
|
||||
const pulse = page.locator('[data-slot="voice-input-pulse"]');
|
||||
await expect(pulse).toBeVisible();
|
||||
const seamOpacity = await pulse.evaluate((element) => {
|
||||
const animation = element
|
||||
.getAnimations()
|
||||
.find((candidate) =>
|
||||
(candidate.effect as KeyframeEffect | null)
|
||||
?.getKeyframes()
|
||||
.some((keyframe) => keyframe.opacity !== undefined)
|
||||
);
|
||||
if (!animation?.effect) {
|
||||
throw new Error("Voice input pulse opacity animation was not found");
|
||||
}
|
||||
|
||||
animation.pause();
|
||||
const duration = Number(animation.effect.getTiming().duration);
|
||||
animation.currentTime = duration - 1;
|
||||
const before = Number(window.getComputedStyle(element).opacity);
|
||||
animation.currentTime = duration + 1;
|
||||
const after = Number(window.getComputedStyle(element).opacity);
|
||||
|
||||
return { before, after };
|
||||
});
|
||||
|
||||
expect(seamOpacity.before).toBeLessThan(0.02);
|
||||
expect(seamOpacity.after).toBeLessThan(0.02);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user