Merge pull request #21706 from calixteman/test-menu-first-last

Add integration tests for the Home/End keys in the `Menu` class
This commit is contained in:
calixteman 2026-08-04 16:16:41 +02:00 committed by GitHub
commit e57a46436f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -327,6 +327,80 @@ describe("PDF Thumbnail View", () => {
}) })
); );
}); });
it("must move to the previous item after pressing the End key", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await showViewsManager(page);
await waitForThumbnailVisible(page, 1);
await enableMenuItems(page);
await kbFocusNext(page, "#viewsManagerStatusActionButton");
await page.keyboard.press("Enter");
await waitForMenu(page, "#viewsManagerStatusActionButton");
await page.waitForSelector("#viewsManagerStatusActionCopy:focus", {
visible: true,
});
// Move to the second menu item.
await page.keyboard.press("ArrowDown");
await page.waitForSelector("#viewsManagerStatusActionCut:focus", {
visible: true,
});
// Jump to the last menu item.
await page.keyboard.press("End");
await page.waitForSelector("#viewsManagerStatusActionExport:focus", {
visible: true,
});
// The focus must move relative to the last menu item, and not
// relative to the item that was focused before pressing End.
await page.keyboard.press("ArrowUp");
await page.waitForSelector("#viewsManagerStatusActionDelete:focus", {
visible: true,
});
})
);
});
it("must move to the next item after pressing the Home key", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await showViewsManager(page);
await waitForThumbnailVisible(page, 1);
await enableMenuItems(page);
await kbFocusNext(page, "#viewsManagerStatusActionButton");
await page.keyboard.press("Enter");
await waitForMenu(page, "#viewsManagerStatusActionButton");
await page.waitForSelector("#viewsManagerStatusActionCopy:focus", {
visible: true,
});
// Wrap around to the last menu item.
await page.keyboard.press("ArrowUp");
await page.waitForSelector("#viewsManagerStatusActionExport:focus", {
visible: true,
});
// Jump to the first menu item.
await page.keyboard.press("Home");
await page.waitForSelector("#viewsManagerStatusActionCopy:focus", {
visible: true,
});
// The focus must move relative to the first menu item, and not
// relative to the item that was focused before pressing Home.
await page.keyboard.press("ArrowDown");
await page.waitForSelector("#viewsManagerStatusActionCut:focus", {
visible: true,
});
})
);
});
}); });
describe("Checkbox accessibility", () => { describe("Checkbox accessibility", () => {