From e1366a8222c7e0d41958b60c5126bfa48162e003 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Fri, 20 Nov 2026 20:11:56 -0800 Subject: [PATCH] Host browser tests: open Settings submenus and choose their items by keyboard The harness's chooseSetting and openSettingsSubmenu clicked a submenu's trigger and then its item. Where a submenu opens to the left, the menu reads the pointer's jump into it as moving away from it, closes the submenu as the pointer leaves its trigger, and a click on the item lands only while it fades out: the race #129 fixed in the renderer harness's annotations.spec, where on a slow WebKit runner the click fell through to the renderer's frame. The helpers now open the submenu with Right Arrow and choose with Enter, which no pointer position can undo. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- packages/host/core/browser/harness.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/host/core/browser/harness.ts b/packages/host/core/browser/harness.ts index fdb9668f..43067405 100644 --- a/packages/host/core/browser/harness.ts +++ b/packages/host/core/browser/harness.ts @@ -189,7 +189,10 @@ export const submenuItem = (menu: Locator, name: string) => export async function openSettingsSubmenu(scope: Scope, name: string): Promise { const menu = openMenu(scope, name) if (await menu.isVisible()) return menu - await submenuItem(await openSettings(scope), name).click() + // By keyboard: where a submenu opens to the left, the menu reads the pointer's jump into it as moving away from it (its + // first move in the menu always reads as rightward), so the submenu closes as the pointer leaves its item, and a click + // on one of its items lands only while it fades out; on a slow runner it falls through to whatever is behind. + await submenuItem(await openSettings(scope), name).press('ArrowRight') await menu.waitFor() return menu } @@ -202,10 +205,10 @@ export const menuItem = (menu: Locator, name: string) => { .or(menu.getByRole('menuitemcheckbox', {name: label})) .or(menu.getByRole('menuitem', {name: label})) } -/** Chooses an item in Settings, or in one of its submenus (`submenu`); choosing closes the menu. */ +/** Chooses an item in Settings, or in one of its submenus (`submenu`), by keyboard (see `openSettingsSubmenu`); choosing closes the menu. */ export async function chooseSetting(scope: Scope, name: string, submenu?: string) { const menu = submenu ? await openSettingsSubmenu(scope, submenu) : await openSettings(scope) - await menuItem(menu, name).click() + await menuItem(menu, name).press('Enter') await closeMenus(scope) } /** Shows every item: the All scope, from Settings' "Show" (the toolbar's scope switch leaves narrow rows). */