verify mobile drawer focus wraps at both boundaries

This commit is contained in:
cieanyau committed 2026-11-07 02:39:35 +08:00
1 parent c3a67377c7
commit 27d240b41b
1 file changed
+12 -4
+12 -4
View File
@@ -46,19 +46,27 @@ test(
Boolean, Boolean,
"Opening navigation focuses its close action", "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"); await page.keyboard.press("Shift+Tab");
assert.equal( assert.equal(
await drawer.evaluate((element) => await lastLink.evaluate(
element.contains(document.activeElement), (element) => element === document.activeElement,
), ),
true, true,
"Shift+Tab from the first item wraps to the last drawer action",
); );
await page.keyboard.press("Tab"); await page.keyboard.press("Tab");
assert.equal( assert.equal(
await drawer.evaluate((element) => await firstLink.evaluate(
element.contains(document.activeElement), (element) => element === document.activeElement,
), ),
true, true,
"Tab from the last item wraps to the first drawer action",
); );
await page.keyboard.press("Escape"); await page.keyboard.press("Escape");
await drawer.waitFor({ state: "hidden" }); await drawer.waitFor({ state: "hidden" });