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,
"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" });