@@ -399,11 +399,11 @@ test.describe('CSR', () => {
399
399
} ) ;
400
400
401
401
test . describe ( 'Dynamic' , ( ) => {
402
- test ( `GIVEN an Accordion with items added dynamically
402
+ test ( `GIVEN an Accordion with three items
403
403
WHEN the first item is opened
404
- AND a new item is added and opened
405
- THEN the original first item should be closed
406
- AND the new item should be open
404
+ AND an item is added to the front and opened
405
+ THEN the second item should be closed
406
+ AND the new first item should be open
407
407
` , async ( { page } ) => {
408
408
const { driver : d } = await setup ( page , 'dynamic' ) ;
409
409
@@ -415,4 +415,24 @@ test.describe('Dynamic', () => {
415
415
await expect ( d . getContentAt ( 0 ) ) . toBeVisible ( ) ;
416
416
await expect ( d . getContentAt ( 1 ) ) . toBeHidden ( ) ;
417
417
} ) ;
418
+
419
+ test ( `GIVEN an Accordion with three items
420
+ WHEN two items are added
421
+ AND the end key is pressed
422
+ AND the 5th item should be focused
423
+ ` , async ( { page } ) => {
424
+ const { driver : d } = await setup ( page , 'dynamic' ) ;
425
+
426
+ await d . getTriggerAt ( 0 ) . click ( ) ;
427
+ await d . locator . getByRole ( 'button' , { name : 'Add Item' } ) . click ( ) ;
428
+ await d . locator . getByRole ( 'button' , { name : 'Add Item' } ) . click ( ) ;
429
+
430
+ await expect ( d . getTriggerAt ( 3 ) ) . toBeVisible ( ) ;
431
+ await expect ( d . getTriggerAt ( 4 ) ) . toBeVisible ( ) ;
432
+
433
+ await d . getTriggerAt ( 0 ) . focus ( ) ;
434
+ await d . getTriggerAt ( 0 ) . press ( 'End' ) ;
435
+
436
+ await expect ( d . getTriggerAt ( 4 ) ) . toBeFocused ( ) ;
437
+ } ) ;
418
438
} ) ;
0 commit comments