@@ -625,96 +625,104 @@ export const folderNavigationAndSelection = {
625625 play : async ( { canvasElement } ) => {
626626 const canvas = within ( canvasElement ) ;
627627
628- // Wait for items to load
628+ // Wait for initial load and verify state
629629 await waitFor ( ( ) => {
630- const items = canvas . getAllByRole ( 'row' ) ;
631- expect ( items . length ) . toBeGreaterThan ( 1 ) ;
630+ const orderedFolder = canvas . getByRole ( 'button' , { name : / A n O r d e r e d F o l d e r / i } ) ;
631+ expect ( orderedFolder ) . toBeInTheDocument ( ) ;
632+ expect ( canvas . getByRole ( 'button' , { name : / 0 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
633+ expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeDisabled ( ) ;
632634 } ) ;
633635
634- const items = canvas . getAllByRole ( 'row' ) ;
635-
636- // Select first item
637- await userEvent . click ( items [ 1 ] ) ;
638- expect ( items [ 1 ] ) . toHaveClass ( 'bcp-item-row-selected' ) ;
639- expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
640- expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
636+ // Navigate into "An Ordered Folder"
637+ const orderedFolder = canvas . getByRole ( 'button' , { name : / A n O r d e r e d F o l d e r / i } ) ;
638+ await userEvent . dblClick ( orderedFolder ) ;
641639
642- // Navigate into folder
643- await userEvent . dblClick ( items [ 2 ] ) ;
640+ // Wait for folder contents to load
644641 await waitFor ( ( ) => {
645- expect ( canvas . getByText ( 'Subfolder ' ) ) . toBeInTheDocument ( ) ;
642+ expect ( canvas . getByText ( 'Audio.mp3 ' ) ) . toBeInTheDocument ( ) ;
646643 expect ( canvas . getByText ( 'Preview Test Folder' ) ) . toBeInTheDocument ( ) ;
647644 } ) ;
648645
649- // Verify selection persists in subfolder
650- expect ( canvas . getByRole ( 'button ' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
651- expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
646+ // Select first item
647+ const audioRow = canvas . getByRole ( 'row ' , { name : / A u d i o \. m p 3 / i } ) ;
648+ await userEvent . click ( audioRow ) ;
652649
653- // Navigate back to root
654- await userEvent . click ( canvas . getByText ( 'Preview Test Folder' ) ) ;
650+ // Verify selection state
655651 await waitFor ( ( ) => {
656- expect ( canvas . queryByRole ( 'link' , { name : / S u b f o l d e r / i } ) ) . not . toBeInTheDocument ( ) ;
652+ expect ( audioRow ) . toHaveClass ( 'bcp-item-row-selected' ) ;
653+ expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
654+ expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
657655 } ) ;
658656
657+ // Navigate back to root
658+ await userEvent . click ( canvas . getByText ( 'Preview Test Folder' ) ) ;
659+
659660 // Verify selection persists in root
660- expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
661- expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
662- expect ( items [ 1 ] ) . toHaveClass ( 'bcp-item-row-selected' ) ;
661+ await waitFor ( ( ) => {
662+ expect ( canvas . queryByText ( 'Audio.mp3' ) ) . not . toBeInTheDocument ( ) ;
663+ expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
664+ expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
665+ } ) ;
663666 } ,
664667} ;
665668
666669export const searchFunctionality = {
667670 play : async ( { canvasElement } ) => {
668671 const canvas = within ( canvasElement ) ;
669672
670- // Wait for items to load
673+ // Wait for initial load and verify state
671674 await waitFor ( ( ) => {
672- const items = canvas . getAllByRole ( 'row' ) ;
673- expect ( items . length ) . toBeGreaterThan ( 1 ) ;
675+ const orderedFolder = canvas . getByRole ( 'button' , { name : / A n O r d e r e d F o l d e r / i } ) ;
676+ expect ( orderedFolder ) . toBeInTheDocument ( ) ;
677+ expect ( canvas . getByRole ( 'button' , { name : / 0 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
678+ expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeDisabled ( ) ;
674679 } ) ;
675680
676681 // Navigate into "An Ordered Folder"
677- const orderedFolder = await canvas . findByText ( ' An Ordered Folder' ) ;
682+ const orderedFolder = canvas . getByRole ( 'button' , { name : / A n O r d e r e d F o l d e r / i } ) ;
678683 await userEvent . dblClick ( orderedFolder ) ;
679684
680685 // Wait for folder contents to load
681686 await waitFor ( ( ) => {
687+ expect ( canvas . getByText ( 'Audio.mp3' ) ) . toBeInTheDocument ( ) ;
682688 expect ( canvas . getByText ( 'Preview Test Folder' ) ) . toBeInTheDocument ( ) ;
683689 const items = canvas . getAllByRole ( 'row' ) ;
684690 expect ( items . length ) . toBeGreaterThan ( 1 ) ;
685691 } ) ;
686692
687- const items = canvas . getAllByRole ( 'row' ) ;
688-
689693 // Focus search and enter query
690694 await userEvent . keyboard ( '/' ) ;
691695 const searchInput = canvas . getByRole ( 'textbox' ) ;
692- await userEvent . type ( searchInput , 'test ' ) ;
696+ await userEvent . type ( searchInput , 'Audio ' ) ;
693697
694698 // Verify search results
695699 await waitFor ( ( ) => {
696700 expect ( canvas . getByText ( / S e a r c h R e s u l t s / i) ) . toBeInTheDocument ( ) ;
697701 expect ( canvas . getByRole ( 'button' , { name : / C l e a r S e a r c h / i } ) ) . toBeInTheDocument ( ) ;
702+ expect ( canvas . getByText ( 'Audio.mp3' ) ) . toBeInTheDocument ( ) ;
698703 } ) ;
699704
700- // Select first search result
701- await userEvent . click ( items [ 1 ] ) ;
702- expect ( items [ 1 ] ) . toHaveClass ( 'bcp-item-row-selected' ) ;
703- expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
704- expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
705+ // Select search result
706+ const audioRow = canvas . getByRole ( 'row' , { name : / A u d i o \. m p 3 / i } ) ;
707+ await userEvent . click ( audioRow ) ;
708+
709+ // Verify selection state
710+ await waitFor ( ( ) => {
711+ expect ( audioRow ) . toHaveClass ( 'bcp-item-row-selected' ) ;
712+ expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
713+ expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
714+ } ) ;
705715
706716 // Clear search
707717 await userEvent . clear ( searchInput ) ;
708718
709- // Verify return to folder view
719+ // Verify return to folder view and selection persistence
710720 await waitFor ( ( ) => {
711721 expect ( canvas . queryByText ( / S e a r c h R e s u l t s / i) ) . not . toBeInTheDocument ( ) ;
712722 expect ( canvas . getByPlaceholderText ( / S e a r c h / i) ) . toHaveValue ( '' ) ;
723+ expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
724+ expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
713725 } ) ;
714-
715- // Verify selection persists
716- expect ( canvas . getByRole ( 'button' , { name : / 1 S e l e c t e d / i } ) ) . toBeInTheDocument ( ) ;
717- expect ( canvas . getByLabelText ( 'Choose' ) ) . toBeEnabled ( ) ;
718726 } ,
719727} ;
720728
0 commit comments