fix(webui): stabilize interaction tests and tooltip dismissal
This commit is contained in:
1 parent
c4dac649da
commit
8aa0deaca3
9 files changed
+172
-24
No files matched your search
@@ -318,11 +318,15 @@ test("archived task results stay with the retained boundary when earlier message
|
||||
const body = page.getByTestId("thread-message-region");
|
||||
const otherTasks = body.getByRole("region", { name: "Other tasks" });
|
||||
await expect(otherTasks).toBeAttached();
|
||||
// Clicking an offscreen disclosure scrolls it into view and can prefetch history.
|
||||
await positionAtTop(body);
|
||||
await otherTasks.getByRole("button", { name: /Other tasks/ }).click();
|
||||
await expect(otherTasks.getByRole("button", { name: /Earlier check Completed/ })).toBeVisible();
|
||||
await stableLayout(body);
|
||||
const originalTop = await positionAtTop(body);
|
||||
await body.hover();
|
||||
await expect(body.locator(".thread-history-slot")).toHaveCount(0);
|
||||
expect(history.reads).toHaveLength(0);
|
||||
await page.mouse.wheel(0, -100);
|
||||
await expect(page.locator(".thread-history-status")).toHaveAttribute("data-state", "loading");
|
||||
const held = await expectHeld(body, "Question 40");
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
async function fixture(page: Page) {
|
||||
await page.goto("/browser/fixture.html?case=subagent-dock");
|
||||
// Hold the observed pending-animation window open; input remains native.
|
||||
await page.addStyleTag({ content: "[data-radix-popper-content-wrapper] > [data-state] { animation-delay: 3s !important; }" });
|
||||
await expect(page.getByTestId("subagent-task-dock-trigger")).toContainText("Running: 3");
|
||||
}
|
||||
|
||||
async function showDockHint(page: Page) {
|
||||
const trigger = page.getByTestId("subagent-task-dock-trigger");
|
||||
await trigger.hover();
|
||||
await expect(trigger).toHaveAttribute("data-state", /open/);
|
||||
await expect(page.getByRole("tooltip")).toContainText("Subtasks");
|
||||
}
|
||||
|
||||
test("a disabled completed-dock hint cannot consume Escape", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 390, height: 900 });
|
||||
await fixture(page);
|
||||
const trigger = page.getByTestId("subagent-task-dock-trigger");
|
||||
const tree = page.getByTestId("subagent-task-tree");
|
||||
await page.getByRole("button", { name: "增加任务", exact: true }).click();
|
||||
await expect(trigger).toContainText("Running: 23");
|
||||
await page.getByRole("button", { name: "全部完成", exact: true }).click();
|
||||
await expect(trigger).toContainText("Completed: 23");
|
||||
await showDockHint(page);
|
||||
await trigger.click();
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(tree.locator('[data-task-state="done"]')).toHaveCount(23);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(tree).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("a disabled dragged-dock hint cannot consume Escape", async ({ page }) => {
|
||||
await fixture(page);
|
||||
const trigger = page.getByTestId("subagent-task-dock-trigger");
|
||||
await page.getByRole("button", { name: "增加任务", exact: true }).click();
|
||||
await expect(trigger).toContainText("Running: 23");
|
||||
await showDockHint(page);
|
||||
const bounds = (await trigger.boundingBox())!;
|
||||
const x = bounds.x + 8, y = bounds.y + bounds.height / 2;
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x, y + 30, { steps: 4 });
|
||||
await page.keyboard.press("Escape");
|
||||
await page.mouse.move(x, y - 60, { steps: 6 });
|
||||
await page.mouse.up();
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "false");
|
||||
});
|
||||
|
||||
test("an actually open task tooltip owns the first Escape", async ({ page }) => {
|
||||
await fixture(page);
|
||||
const trigger = page.getByTestId("subagent-task-dock-trigger");
|
||||
const tree = page.getByTestId("subagent-task-tree");
|
||||
await trigger.click();
|
||||
await expect(tree).toBeVisible();
|
||||
const stop = tree.getByRole("button", { name: "Stop 检查项目实现", exact: true });
|
||||
await stop.hover();
|
||||
await expect(stop).toHaveAttribute("data-state", /open/);
|
||||
await expect(page.getByRole("tooltip")).toContainText("Stop 检查项目实现");
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.locator("[data-radix-popper-content-wrapper]")).toHaveCount(0);
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(tree).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(tree).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("a task detail dialog owns the first Escape and returns focus before the next", async ({ page }) => {
|
||||
await fixture(page);
|
||||
const trigger = page.getByTestId("subagent-task-dock-trigger");
|
||||
const tree = page.getByTestId("subagent-task-tree");
|
||||
const row = tree.locator('[data-subagent-id="preview-0"]');
|
||||
await trigger.click();
|
||||
await row.click();
|
||||
const dialog = page.getByRole("dialog", { name: "检查项目实现", exact: true });
|
||||
await expect(dialog).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(tree).toBeVisible();
|
||||
// The dialog can lose its name before its exit and focus restoration finish.
|
||||
await expect(page.locator('[role="dialog"]')).toHaveCount(0);
|
||||
await expect(row).toBeFocused();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(tree).toHaveCount(0);
|
||||
});
|
||||
@@ -243,20 +243,45 @@ test("browsers without View Transitions keep a working palette fade", async ({ p
|
||||
Object.defineProperty(document, "startViewTransition", { value: undefined });
|
||||
});
|
||||
await page.goto("/browser/fixture.html?case=theme-toggle&chat");
|
||||
const pane = page.locator(".workbench-pane");
|
||||
const sampleHandle = await pane.evaluateHandle(node => {
|
||||
const sample: { before: string; midpoint: string | null; transitions: number; duration: number | null } = {
|
||||
before: getComputedStyle(node).backgroundColor, midpoint: null, transitions: 0, duration: null,
|
||||
};
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!document.documentElement.classList.contains("dark")) return;
|
||||
observer.disconnect();
|
||||
// Capture at the class commit, before a protocol round-trip can outlive the fade.
|
||||
const paint = node.getAnimations().filter(animation => animation instanceof CSSTransition
|
||||
&& animation.transitionProperty === "background-color");
|
||||
sample.transitions = paint.length;
|
||||
const duration = paint[0]?.effect?.getTiming().duration;
|
||||
sample.duration = typeof duration === "number" ? duration : null;
|
||||
if (sample.duration !== null) {
|
||||
paint.forEach(animation => { animation.pause(); animation.currentTime = sample.duration! / 2; });
|
||||
}
|
||||
sample.midpoint = getComputedStyle(node).backgroundColor;
|
||||
paint.forEach(animation => animation.finish());
|
||||
});
|
||||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
||||
return sample;
|
||||
});
|
||||
await page.getByRole("button", { name: "Toggle theme from header", exact: true }).click();
|
||||
await expect(page.locator("html")).toHaveClass(/dark/);
|
||||
const midpoint = await page.locator(".workbench-pane").evaluate(async node => {
|
||||
await new Promise(requestAnimationFrame);
|
||||
const paint = node.getAnimations().filter(animation => animation instanceof CSSTransition);
|
||||
paint.forEach(animation => { animation.pause(); animation.currentTime = 140; });
|
||||
const color = getComputedStyle(node).backgroundColor;
|
||||
paint.forEach(animation => animation.finish());
|
||||
return color;
|
||||
});
|
||||
expect(midpoint).not.toBe("rgb(48, 48, 48)");
|
||||
expect(midpoint).not.toBe("rgb(255, 255, 255)");
|
||||
const sample = await sampleHandle.jsonValue();
|
||||
await sampleHandle.dispose();
|
||||
expect(sample.transitions).toBe(1);
|
||||
expect(sample.duration).toBeGreaterThan(0);
|
||||
expect(sample.before).toBe("rgb(255, 255, 255)");
|
||||
expect(sample.midpoint).not.toBeNull();
|
||||
expect(sample.midpoint).not.toBe("rgb(48, 48, 48)");
|
||||
expect(sample.midpoint).not.toBe(sample.before);
|
||||
await expect.poll(() => page.locator("html").getAttribute("data-theme-transition")).toBeNull();
|
||||
await expect(page.getByRole("textbox")).toBeEditable();
|
||||
await expect(pane).toHaveCSS("background-color", "rgb(48, 48, 48)");
|
||||
const input = page.getByRole("textbox");
|
||||
await expect(input).toBeEditable();
|
||||
await input.fill("Editing remains available after the fallback fade");
|
||||
await expect(input).toHaveValue("Editing remains available after the fallback fade");
|
||||
});
|
||||
|
||||
test("a browser-skipped transition still applies the theme and releases the toggle", async ({ page }) => {
|
||||
|
||||
Reference in new issue
Block a user