From 602d11f59a16a5f1f23233250877143f4a56572d Mon Sep 17 00:00:00 2001 From: Timothy Wayne Gregg <5861166+CompleteDotTech@users.noreply.github.com> Date: Wed, 19 Aug 2026 18:50:11 -0400 Subject: [PATCH] fix(test): stop a swallowed Escape sinking the shortcuts sheet suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `gotoApp` opened the command palette to prove the Workspace global-shortcut handler was attached, then closed it with a single Escape and asserted `toBeHidden()`. Closing is setup here — all three tests in this file are about the shortcuts sheet, and nothing covers the palette's own Escape behavior — so a one-shot press made an incidental step a failure mode for the whole suite. The press can be swallowed rather than merely late: `useFocusTrap` attaches its Escape listener and moves focus in the same post-paint effect, and the handler no-ops unless its trap is topmost. A key that lands a beat early is dropped, not queued, so `toBeHidden()` then polls a palette that will never close. That is why it failed outright instead of flaking to a pass — main run 32303914004 held the dialog visible through the whole 5s window. Wait for the trap's observable half (focus inside the dialog, the same guard right-chat-panel.spec.ts uses) and then press Escape until the palette actually closes, mirroring the open poll directly above. Both loops stop on the first press that takes effect, so neither sends a stray key. Verified: 22 passes across `--repeat-each=6 --workers=1` locally. Note this hardens the helper against a dropped key; it does not attempt to fix why the key is dropped, which is not reproducible on an idle machine. --- tests/keyboard-shortcuts.spec.ts | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/keyboard-shortcuts.spec.ts b/tests/keyboard-shortcuts.spec.ts index 73b3fc3d77..e334fdebd3 100644 --- a/tests/keyboard-shortcuts.spec.ts +++ b/tests/keyboard-shortcuts.spec.ts @@ -28,8 +28,33 @@ async function gotoApp(page: Page) { { timeout: 30_000, message: "Workspace global shortcuts should be interactive" }, ) .toBe(true); - await page.keyboard.press("Escape"); - await expect(palette).toBeHidden(); + // Getting the palette shut again is setup, not the assertion under test — + // every test below is about the shortcuts sheet, and nothing here covers the + // palette's own Escape behavior. A one-shot press therefore made an + // incidental step a failure mode for all three. + // + // It is a swallowed key rather than a slow one, which is why retrying the + // assertion could not recover it: `useFocusTrap` attaches its Escape listener + // and moves focus in the SAME post-paint effect, and the handler no-ops + // unless its trap is topmost — so a press that lands a beat early is dropped, + // not queued, and `toBeHidden` then polls a palette that will never close. + // That is how main run 32303914004 held it visible through the whole 5s + // window and failed outright rather than flaking to a pass (cave-i1c). + // + // So wait for the trap's observable half — focus inside the dialog, the guard + // right-chat-panel.spec.ts already uses — and then press until it actually + // closes, mirroring the open poll above. Both loops stop on the first press + // that takes effect, so neither sends a stray key. + await expect(palette.locator(":focus")).toHaveCount(1); + await expect + .poll( + async () => { + await page.keyboard.press("Escape"); + return palette.isVisible(); + }, + { timeout: 15_000, message: "Command palette should close on Escape" }, + ) + .toBe(false); } // The sheet is a Modal labelled via its breadcrumb header (aria-labelledby),