@@ -94,9 +94,11 @@ describe('PopularEvents Component', () => {
9494 test ( 'dark mode applies proper class' , ( ) => {
9595 renderWithStore ( true ) ;
9696
97- const heading = screen . getByText ( 'Most Popular Event' ) ;
97+ // specifically select ONLY the main header, not the summary box
98+ const heading = screen . getByRole ( 'heading' , {
99+ name : 'Most Popular Event' ,
100+ } ) ;
98101
99- // text-light is applied when dark mode is true
100102 expect ( heading . className . includes ( 'text-light' ) ) . toBe ( true ) ;
101103 } ) ;
102104
@@ -110,9 +112,9 @@ describe('PopularEvents Component', () => {
110112 fireEvent . change ( timeSelect , { target : { value : 'NonExistent' } } ) ;
111113
112114 // Header stays
113- expect ( screen . getByText ( ' Most Popular Event') ) . toBeInTheDocument ( ) ;
115+ expect ( screen . getByRole ( 'heading' , { name : ' Most Popular Event' } ) ) . toBeInTheDocument ( ) ;
114116
115- // These MUST disappear because filteredData is empty
117+ // These disappear because filteredData is empty
116118 expect ( screen . queryByTestId ( 'summary-most' ) ) . not . toBeInTheDocument ( ) ;
117119 expect ( screen . queryByTestId ( 'summary-least' ) ) . not . toBeInTheDocument ( ) ;
118120 } ) ;
@@ -123,9 +125,9 @@ describe('PopularEvents Component', () => {
123125 test ( 'bars have inline width style' , ( ) => {
124126 renderWithStore ( ) ;
125127
126- const innerBars = screen . getAllByTestId ( 'stat-bar-inner' ) ;
128+ const bars = screen . getAllByTestId ( 'stat-bar-inner' ) ;
127129
128- innerBars . forEach ( inner => {
130+ bars . forEach ( inner => {
129131 expect ( inner . style . width ) . toMatch ( / % / ) ;
130132 } ) ;
131133 } ) ;
0 commit comments