From 09bb0cbbe82f98958b14723c24cf20cf816aa4d1 Mon Sep 17 00:00:00 2001 From: kiranmagic7 <262980978+kiranmagic7@users.noreply.github.com> Date: Tue, 4 Aug 2026 08:41:49 +0530 Subject: [PATCH] test(desktop): stabilize keyboard community reorder Signed-off-by: kiranmagic7 <262980978+kiranmagic7@users.noreply.github.com> --- desktop/tests/e2e/community-rail.spec.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/desktop/tests/e2e/community-rail.spec.ts b/desktop/tests/e2e/community-rail.spec.ts index b432d17f2a..3adb822429 100644 --- a/desktop/tests/e2e/community-rail.spec.ts +++ b/desktop/tests/e2e/community-rail.spec.ts @@ -986,8 +986,24 @@ test.describe("community rail", () => { }), ); }, `community-rail-button-${COMMUNITY_B.id}`); + + // KeyboardSensor attaches its document keydown listener on the next timer + // tick. Wait for dnd-kit to expose the active drag before sending ArrowUp. + await expect(buttonB).toHaveAttribute("aria-pressed", "true"); + // ArrowUp moves the active item one slot up. await page.keyboard.press("ArrowUp"); + + // Let dnd-kit publish the new collision target before dropping. Otherwise + // the drop can still observe B's original position and become a no-op. + await expect + .poll(async () => { + const boxA = await buttonA.boundingBox(); + const boxB = await buttonB.boundingBox(); + return boxA !== null && boxB !== null && boxB.y < boxA.y; + }) + .toBe(true); + // Space drops the item — same synthetic dispatch for consistency. await page.evaluate((testId) => { const el = document.querySelector(`[data-testid="${testId}"]`);