Skip to content

Commit b1aa122

Browse files
new focus test
1 parent f24570c commit b1aa122

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/kit-headless/src/components/select/select.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ test.describe('Keyboard Behavior', () => {
331331
});
332332

333333
test.describe('selecting options', () => {
334-
test(`GIVEN an opened hero select with the first option highlighted
334+
test(`GIVEN an opened select with the first option highlighted
335335
WHEN the Enter key is pressed
336336
THEN the listbox should be closed and aria-expanded should be false`, async ({
337337
page,
@@ -346,7 +346,7 @@ test.describe('Keyboard Behavior', () => {
346346
await expect(d.getTrigger()).toHaveAttribute('aria-expanded', 'false');
347347
});
348348

349-
test(`GIVEN an open hero select
349+
test(`GIVEN an open select
350350
WHEN an option has data-highlighted
351351
AND the Enter key is pressed
352352
THEN option value should be the selected value
@@ -361,7 +361,7 @@ test.describe('Keyboard Behavior', () => {
361361
await expect(d.getValueElement()).toHaveText(expectedValue!);
362362
});
363363

364-
test(`GIVEN an open hero select
364+
test(`GIVEN an open select
365365
WHEN an option has data-highlighted
366366
AND the Space key is pressed
367367
THEN the listbox should be closed and aria-expanded false`, async ({
@@ -393,6 +393,17 @@ test.describe('Keyboard Behavior', () => {
393393
await expect(d.getValueElement()).toHaveText(expectedValue!);
394394
});
395395

396+
test(`GIVEN an open select
397+
WHEN an option is selected
398+
THEN focus should go back to the trigger`, async ({ page }) => {
399+
const { driver: d } = await setup(page, 'hero');
400+
401+
await d.openListbox('Space');
402+
403+
await d.getHighlightedItem().press('Enter');
404+
await expect(d.getTrigger()).toBeFocused();
405+
});
406+
396407
test(`GIVEN no selected item and a placeholder
397408
WHEN pressing the right arrow key once
398409
THEN the first enabled option should be selected and have aria-selected`, async ({

0 commit comments

Comments
 (0)