From 27d240b41bacb43ae6b2d10ea13e4c927af0c7e3 Mon Sep 17 00:00:00 2001 From: CieanYau Date: Sat, 7 Nov 2026 02:39:35 +0800 Subject: [PATCH] verify mobile drawer focus wraps at both boundaries --- tests/review-ui-foundation.e2e.test.mjs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/review-ui-foundation.e2e.test.mjs b/tests/review-ui-foundation.e2e.test.mjs index 15c165d..8adf743 100644 --- a/tests/review-ui-foundation.e2e.test.mjs +++ b/tests/review-ui-foundation.e2e.test.mjs @@ -46,19 +46,27 @@ test( Boolean, "Opening navigation focuses its close action", ); + const firstLink = drawer.getByRole("link", { + name: "破碎工坊首页", + exact: true, + }); + const lastLink = drawer.getByRole("link").last(); + await firstLink.focus(); await page.keyboard.press("Shift+Tab"); assert.equal( - await drawer.evaluate((element) => - element.contains(document.activeElement), + await lastLink.evaluate( + (element) => element === document.activeElement, ), true, + "Shift+Tab from the first item wraps to the last drawer action", ); await page.keyboard.press("Tab"); assert.equal( - await drawer.evaluate((element) => - element.contains(document.activeElement), + await firstLink.evaluate( + (element) => element === document.activeElement, ), true, + "Tab from the last item wraps to the first drawer action", ); await page.keyboard.press("Escape"); await drawer.waitFor({ state: "hidden" });