fix(web): stabilize message More menu Escape in hover E2E

The desktop hover spec assumed Escape always closed the first page-level
menu within one keypress. On self-hosted Chromium the Copy menu could stay
open while the rail remained visible, failing getByRole('menu') count.

Wait for the Copy item to prove the menu opened, then retry Escape until
that item hides while asserting the More control stays on the hover rail.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-09-23 22:12:45 +00:00
parent f1bd94dda2
commit 80656d522c

View File

@ -10,6 +10,25 @@ async function sendComposerMessage(page: Page, composer: Locator, text: string)
await expect(composer).toHaveValue("");
}
/** Copy is unique to the message More menu while it is open. */
function messageMoreCopyItem(page: Page) {
return page.getByRole("menuitem", { name: "Copy" });
}
async function expectMessageMoreMenu(page: Page, open: boolean) {
const copyItem = messageMoreCopyItem(page);
if (open) {
await expect(copyItem).toBeVisible();
return;
}
await expect(async () => {
if (await copyItem.isVisible()) {
await page.keyboard.press("Escape");
}
await expect(copyItem).toBeHidden({ timeout: 500 });
}).toPass({ timeout: 10_000 });
}
async function revealHoverRail(row: Locator): Promise<Locator> {
const rail = row.getByTestId("message-hover-rail");
await expect
@ -180,12 +199,13 @@ test("message hover shows beside-bubble actions; reply links to parent", async (
expect(timeBox).not.toBeNull();
expect(rowBox).not.toBeNull();
expect(Math.abs(timeBox!.x - rowBox!.x)).toBeLessThan(2);
await toolbar.getByRole("button", { name: "More" }).click();
const moreButton = toolbar.getByRole("button", { name: "More" });
await moreButton.click();
await expectMessageMoreMenu(page, true);
await expect(page.getByRole("menu").locator("time")).toHaveCount(0);
// Escape closes More; the hover rail stays visible for the pinned row.
await page.keyboard.press("Escape");
await expect(page.getByRole("menu")).toHaveCount(0);
await expect(toolbar.getByRole("button", { name: "More" })).toBeVisible();
await expectMessageMoreMenu(page, false);
await expect(moreButton).toBeVisible();
await captureScreenshot(page, testInfo, "message-user-actions-hover-desktop");
await page.getByRole("combobox", { name: "Message" }).focus();
// Default transcript shot: rail at rest (no hover pin, mouse clear).