test(library): drive every More menu key and drop its unused close export (#512)
CI's coverage gate found more-menu.mjs functions at 71.42% (floor 80): the ArrowUp-on-button, ArrowUp/Home/End-in-menu and Tab paths were untested and an unused close() export counted as uncovered. The delete spec now drives them; measured locally on that spec: 100% lines and functions.
This commit is contained in:
@@ -480,8 +480,12 @@ test('the prompt page\'s More menu opens Delete prompt…, by mouse and keyboard
|
||||
await page.keyboard.press('ArrowDown');await expect(item).toBeFocused();
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(moreMenu(page)).toBeHidden();await expect(more(page)).toBeFocused();await expect(more(page)).toHaveAttribute('aria-expanded','false');
|
||||
// ArrowUp opens on the last item; ArrowUp, Home and End move within it (one item here); Tab closes it.
|
||||
await page.keyboard.press('ArrowUp');await expect(item).toBeFocused();
|
||||
for(const key of ['ArrowUp','Home','End']) {await page.keyboard.press(key);await expect(item).toBeFocused();}
|
||||
await page.keyboard.press('Tab');await expect(moreMenu(page)).toBeHidden();await expect(more(page)).toHaveAttribute('aria-expanded','false');
|
||||
// Space opens too; an outside press closes it.
|
||||
await page.keyboard.press(' ');await expect(item).toBeFocused();
|
||||
await more(page).focus();await page.keyboard.press(' ');await expect(item).toBeFocused();
|
||||
await page.locator('#workspace-main h1').click();await expect(moreMenu(page)).toBeHidden();
|
||||
// Choosing it opens the page's review, titled for this prompt; Cancel returns focus to ⋯.
|
||||
await more(page).click();await item.click();
|
||||
|
||||
@@ -7,7 +7,7 @@ import { createButton } from '../shared/toolkit/core.js';
|
||||
* returns focus to the button; Tab, an outside pointer press or choosing an item closes it. A held button
|
||||
* (`aria-disabled`) or a disabled one opens nothing. Listeners live on `scope`.
|
||||
*
|
||||
* `items`: `[{ label, danger, onSelect }]`. Returns `{ element, button, close, setDisabled(disabled) }`.
|
||||
* `items`: `[{ label, danger, onSelect }]`. Returns `{ element, button, setDisabled(disabled) }`.
|
||||
*/
|
||||
let menus = 0;
|
||||
export function createMoreMenu({ scope, label, items }) {
|
||||
@@ -80,7 +80,6 @@ export function createMoreMenu({ scope, label, items }) {
|
||||
return {
|
||||
element,
|
||||
button,
|
||||
close: () => close(false),
|
||||
setDisabled(disabled) { button.disabled = disabled; if (disabled) close(false); },
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user