From 0a1d4fa7ea469c05d6a21904a7e37d60bd8550a1 Mon Sep 17 00:00:00 2001 From: xarmian Date: Wed, 22 Jul 2026 11:13:59 +0000 Subject: [PATCH] fix(e2e): de-flake pane j/k re-target test by opening the first row (BUG-2279) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pane-controller.spec.ts:160 flaked ~50% (fails once, passes on retry). Root cause via instrumentation: the test opened a NAMED seeded row and pressed `j` (down) expecting the pane to re-target to a different item. But the two seeds share a same-second created_at, so their list order is a non-deterministic tie-break (BUG-2270) — the named row could land LAST, where `j` clamps at the final index (Math.min(idx+1, len-1)) and the cursor doesn't move. The pane-follow then correctly finds the focused row is already the paned item and skips (no re-target), so `openItemParam` stays put and the assertion fails. Not a product bug — the follow logic behaves correctly. Fix is test-only: open the FIRST rendered row instead of a named one, so `j` always has a row beneath it to move to, regardless of seed tie-break order. Verified: :160 now 10/10 stable in isolation (was ~50-60% flaky); full pane-controller.spec.ts 21 passed. Claude-Session: https://claude.ai/code/session_01EZ6yr6pAUFb1uffan912ra --- web/e2e/pane-controller.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/e2e/pane-controller.spec.ts b/web/e2e/pane-controller.spec.ts index 35ceb3ae..39d40809 100644 --- a/web/e2e/pane-controller.spec.ts +++ b/web/e2e/pane-controller.spec.ts @@ -170,7 +170,13 @@ test.describe('pane controller: depth/ownership state machine (PLAN-2154 / TASK- await page.goto(docsUrl(fixture)); const prePaneUrl = page.url(); - const row = page.locator('.item-card', { hasText: 'Ctrl regress alpha' }).first(); + // Open the FIRST rendered row (not a NAMED one) so the `j` (down) below + // always has a row beneath it to re-target to. The two seeds share a + // same-second `created_at`, so their list order is a non-deterministic + // tie-break (BUG-2270); a named row could land LAST, where `j` clamps at + // the final index and the pane-follow correctly finds nothing new to + // target — a test-ordering artifact, not a follow-logic bug (BUG-2279). + const row = page.locator('.item-card').first(); await expect(row).toBeVisible(); await row.click(); @@ -181,8 +187,9 @@ test.describe('pane controller: depth/ownership state machine (PLAN-2154 / TASK- // First-open MINTS ownership at depth 0. await expect.poll(() => paneState(page)).toEqual({ paneDepth: 0, paneOwned: true }); - // j moves the list cursor; the pane FOLLOWS (re-target replace) — still - // depth 0, still owned, and NO new history entry (the PLAN-2105 fix). + // j moves the list cursor to the row below; the pane FOLLOWS (re-target + // replace) — still depth 0, still owned, and NO new history entry (the + // PLAN-2105 fix). const lenAfterOpen = await historyLength(page); await page.keyboard.press('j'); await expect.poll(() => openItemParam(page)).not.toBe(refA);