@@ -141,7 +141,42 @@ describe('Table', () => {
141141 expect ( screen . getByText ( 'Failed to load' ) ) . toBeInTheDocument ( ) ;
142142 } ) ;
143143
144- /* --- Row selection (keyboard + mouse) --- */
144+ it ( 'wraps error content in an error-styled container' , ( ) => {
145+ render ( < Table columns = { columns } data = { [ ] } error = "Something went wrong" /> ) ;
146+ const errorText = screen . getByText ( 'Something went wrong' ) ;
147+ expect ( errorText . closest ( '[class*="errorContent"]' ) ) . toBeInTheDocument ( ) ;
148+ } ) ;
149+
150+ it ( 'sets role="grid" on the table when selectable' , ( ) => {
151+ render ( < Table columns = { columns } data = { data } selectable /> ) ;
152+ expect ( screen . getByRole ( 'grid' ) ) . toBeInTheDocument ( ) ;
153+ } ) ;
154+
155+ it ( 'does not set role="grid" when not selectable' , ( ) => {
156+ render ( < Table columns = { columns } data = { data } /> ) ;
157+ expect ( screen . queryByRole ( 'grid' ) ) . not . toBeInTheDocument ( ) ;
158+ expect ( screen . getByRole ( 'table' ) ) . toBeInTheDocument ( ) ;
159+ } ) ;
160+
161+ /* --- Visible result count in toolbar --- */
162+
163+ it ( 'shows result count in toolbar when search is active' , async ( ) => {
164+ render ( < Table columns = { columns } data = { data } searchable /> ) ;
165+ await userEvent . type ( screen . getByRole ( 'searchbox' ) , 'Alice' ) ;
166+ expect ( screen . getByText ( '1 result' ) ) . toBeInTheDocument ( ) ;
167+ } ) ;
168+
169+ it ( 'shows plural result count for multiple matches' , async ( ) => {
170+ render ( < Table columns = { columns } data = { data } searchable /> ) ;
171+ await userEvent . type ( screen . getByRole ( 'searchbox' ) , 'a' ) ;
172+ // The visible toolbar span shows e.g. "2 results" (live region shows "2 results found")
173+ expect ( screen . getByText ( / ^ \d + r e s u l t s $ / ) ) . toBeInTheDocument ( ) ;
174+ } ) ;
175+
176+ it ( 'hides result count when search is empty' , ( ) => {
177+ render ( < Table columns = { columns } data = { data } searchable /> ) ;
178+ expect ( screen . queryByText ( / r e s u l t / ) ) . not . toBeInTheDocument ( ) ;
179+ } ) ;
145180
146181 it ( 'selects a row on click when selectable' , async ( ) => {
147182 render ( < Table columns = { columns } data = { data } selectable /> ) ;
0 commit comments