@@ -17,15 +17,15 @@ const searchWord = 'search test';
1717const editChannel = {
1818 id : 'editchannel' ,
1919 name : searchWord ,
20- description : '' ,
20+ description : 'A curated collection of math resources ' ,
2121 edit : true ,
2222 published : true ,
2323} ;
2424
2525const editChannel2 = {
2626 id : 'editchannel2' ,
2727 name : 'Another Channel' ,
28- description : '' ,
28+ description : 'Science and nature topics for all ages ' ,
2929 edit : true ,
3030 published : true ,
3131} ;
@@ -86,9 +86,9 @@ describe('ChannelSelectionList', () => {
8686 // Specific wait avoids wrapping the whole block in waitFor
8787 expect ( await screen . findByLabelText ( 'Search for a channel' ) ) . toBeInTheDocument ( ) ;
8888
89- expect ( screen . getByText ( editChannel . name ) ) . toBeInTheDocument ( ) ;
90- expect ( screen . getByText ( editChannel2 . name ) ) . toBeInTheDocument ( ) ;
91- expect ( screen . queryByText ( publicChannel . name ) ) . not . toBeInTheDocument ( ) ;
89+ expect ( screen . getByRole ( 'heading' , { name : editChannel . name } ) ) . toBeInTheDocument ( ) ;
90+ expect ( screen . getByRole ( 'heading' , { name : editChannel2 . name } ) ) . toBeInTheDocument ( ) ;
91+ expect ( screen . queryByRole ( 'heading' , { name : publicChannel . name } ) ) . not . toBeInTheDocument ( ) ;
9292 } ) ;
9393
9494 it ( 'shows loader while the channel list is loading' , async ( ) => {
@@ -111,23 +111,23 @@ describe('ChannelSelectionList', () => {
111111 await renderComponent ( ) ;
112112
113113 // Wait for data load
114- expect ( await screen . findByText ( editChannel . name ) ) . toBeInTheDocument ( ) ;
115- expect ( screen . getByText ( editChannel2 . name ) ) . toBeInTheDocument ( ) ;
114+ expect ( await screen . findByRole ( 'heading' , { name : editChannel . name } ) ) . toBeInTheDocument ( ) ;
115+ expect ( screen . getByRole ( 'heading' , { name : editChannel2 . name } ) ) . toBeInTheDocument ( ) ;
116116
117117 const searchInput = screen . getByLabelText ( 'Search for a channel' ) ;
118118 await user . clear ( searchInput ) ;
119119 await user . type ( searchInput , editChannel . name ) ;
120120
121121 // Verify filter happened
122- expect ( await screen . findByText ( editChannel . name ) ) . toBeInTheDocument ( ) ;
123- expect ( screen . queryByText ( editChannel2 . name ) ) . not . toBeInTheDocument ( ) ;
122+ expect ( await screen . findByRole ( 'heading' , { name : editChannel . name } ) ) . toBeInTheDocument ( ) ;
123+ expect ( screen . queryByRole ( 'heading' , { name : editChannel2 . name } ) ) . not . toBeInTheDocument ( ) ;
124124 } ) ;
125125
126126 it ( 'selects a channel when the user clicks the checkbox' , async ( ) => {
127127 const user = userEvent . setup ( ) ;
128128 const { emitted } = await renderComponent ( ) ;
129129
130- await screen . findByText ( editChannel . name ) ;
130+ await screen . findByRole ( 'heading' , { name : editChannel . name } ) ;
131131
132132 // Using getByTestId because the component doesn't expose unique
133133 // accessible roles for individual channel checkboxes
@@ -149,7 +149,7 @@ describe('ChannelSelectionList', () => {
149149 // Initialize with the channel already selected
150150 const { emitted } = await renderComponent ( { value : [ editChannel . id ] } ) ;
151151
152- await screen . findByText ( editChannel . name ) ;
152+ await screen . findByRole ( 'heading' , { name : editChannel . name } ) ;
153153
154154 // Using getByTestId because the component doesn't expose unique
155155 // accessible roles for individual channel checkboxes
@@ -168,7 +168,7 @@ describe('ChannelSelectionList', () => {
168168 const user = userEvent . setup ( ) ;
169169 const { emitted } = await renderComponent ( ) ;
170170
171- await screen . findByText ( editChannel . name ) ;
171+ await screen . findByRole ( 'heading' , { name : editChannel . name } ) ;
172172
173173 // Using getByTestId because the component doesn't expose accessible
174174 // roles for channel cards
@@ -186,7 +186,7 @@ describe('ChannelSelectionList', () => {
186186 // Initialize with the channel already selected
187187 const { emitted } = await renderComponent ( { value : [ editChannel . id ] } ) ;
188188
189- await screen . findByText ( editChannel . name ) ;
189+ await screen . findByRole ( 'heading' , { name : editChannel . name } ) ;
190190
191191 // Using getByTestId because the component doesn't expose accessible
192192 // roles for channel cards
@@ -197,4 +197,13 @@ describe('ChannelSelectionList', () => {
197197 expect ( emitted ( ) . input ) . toHaveLength ( 1 ) ;
198198 expect ( emitted ( ) . input [ 0 ] [ 0 ] ) . toEqual ( [ ] ) ;
199199 } ) ;
200+
201+ it ( 'each checkbox has an accessible name matching its channel name' , async ( ) => {
202+ await renderComponent ( ) ;
203+
204+ // KCheckbox renders a visually-hidden <label for="id"> associated with the input,
205+ // so getByRole resolves the accessible name correctly for screen readers
206+ expect ( await screen . findByRole ( 'checkbox' , { name : editChannel . name } ) ) . toBeInTheDocument ( ) ;
207+ expect ( screen . getByRole ( 'checkbox' , { name : editChannel2 . name } ) ) . toBeInTheDocument ( ) ;
208+ } ) ;
200209} ) ;
0 commit comments