Skip to content

Commit 6baffd1

Browse files
committed
test(webui): measure the shared dialog after its entrance has settled
The shared presentation layer replaced the message dialog with the shared dialog, and the shared dialog enters over 200ms: the entrance translates and scales it, so a geometry measured while the entrance runs is not the dialog's geometry. - The rewind dialog's surface and action row are the shared dialog's classes now; the message dialog's own classes are gone - The two geometry measurements wait for the entrance to finish, the way the plugin catalogue's own dialog measurement already does - The session leading marker's column is 24px wide because the disclosure inside it is a 24px target; the stylesheet says so where the rule is written, and the assertion still said 18px
1 parent 17a6a02 commit 6baffd1

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎packages/webui/test/integration/agent-transcript.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,16 @@ it("a real agent turn resumes after refresh and drains a queued message in order
577577
await persistedSourceActions.getByRole("button", { name: "回退" }).click();
578578
const persistedSourceRewindDialog = page.getByTestId("rewind-preview-dialog");
579579
await browserExpect(persistedSourceRewindDialog).toBeVisible();
580+
// The shared dialog enters over 200ms, and the entrance moves it. The
581+
// geometry is the dialog's own geometry only once the entrance has
582+
// settled, so the measurement waits for it.
583+
await persistedSourceRewindDialog.evaluate((node) => Promise.all(node.getAnimations({ subtree: true }).map((animation) => animation.finished)));
580584
const rewindGeometry = await persistedSourceRewindDialog.evaluate((node) => {
581585
const viewportWidth = document.body.clientWidth;
582586
const viewportHeight = document.body.clientHeight;
583587
const dialog = node.getBoundingClientRect();
584-
const surface = node.querySelector(".webui-message-dialog-surface")!.getBoundingClientRect();
585-
const buttons = [...node.querySelectorAll<HTMLButtonElement>(".webui-message-dialog-actions button")];
588+
const surface = node.querySelector(".webui-dialog-surface")!.getBoundingClientRect();
589+
const buttons = [...node.querySelectorAll<HTMLButtonElement>(".webui-dialog-actions button")];
586590
return {
587591
fixedBackdrop: getComputedStyle(node).position === "fixed",
588592
backdropCoversViewport: dialog.left <= 0 && dialog.top <= 0 &&
@@ -1193,6 +1197,10 @@ it("a real agent turn resumes after refresh and drains a queued message in order
11931197
await page.getByRole("menuitem", { name: "添加 MCP server" }).click();
11941198
const mcpDialog = page.getByRole("dialog", { name: "MCP Server" });
11951199
await browserExpect(mcpDialog).toBeVisible();
1200+
// The shared dialog enters over 200ms, and the entrance moves it. The
1201+
// geometry is the dialog's own geometry only once the entrance has
1202+
// settled, so the measurement waits for it.
1203+
await mcpDialog.evaluate((node) => Promise.all(node.getAnimations({ subtree: true }).map((animation) => animation.finished)));
11961204
const mcpGeometry = await mcpDialog.evaluate((node) => {
11971205
const backdrop = node.parentElement;
11981206
const rect = node.getBoundingClientRect();

‎packages/webui/test/integration/real-host-loopback.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ describe("real host over the loopback service", () => {
343343
await page.getByRole("menuitem", { name: "添加 MCP server" }).click();
344344
const dialog = page.getByRole("dialog", { name: "MCP Server" });
345345
await browserExpect(dialog).toBeVisible();
346+
// The shared dialog enters over 200ms, and the entrance moves it. The
347+
// geometry is the dialog's own geometry only once the entrance has
348+
// settled, so the measurement waits for it.
349+
await dialog.evaluate((node) => Promise.all(node.getAnimations({ subtree: true }).map((animation) => animation.finished)));
346350
const geometry = await dialog.evaluate((node) => {
347351
const backdrop = node.parentElement!;
348352
const backdropRect = backdrop.getBoundingClientRect();

‎packages/webui/test/unit/webui-shell.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,11 @@ describe("WebUI shell", () => {
948948
/\.webui-session-leading-marker\s*\{([^}]*)\}/u,
949949
);
950950
expect(leadingMarkerRule, "session leading marker rule is missing").not.toBeNull();
951-
expect(leadingMarkerRule![1]).toMatch(/width:\s*18px/u);
952-
expect(leadingMarkerRule![1]).toMatch(/flex:\s*0\s+0\s+18px/u);
951+
// The column is 24px wide because the disclosure inside it is a 24px
952+
// target; an 18px column clipped the one place a session row is opened
953+
// from. The stylesheet says so where the rule is written.
954+
expect(leadingMarkerRule![1]).toMatch(/width:\s*24px/u);
955+
expect(leadingMarkerRule![1]).toMatch(/flex:\s*0\s+0\s+24px/u);
953956
});
954957

955958
it("keeps subagent sessions visibly nested under their parent session", () => {

0 commit comments

Comments
 (0)