@@ -186,12 +186,9 @@ export const ExperimentsToggleOn: AppStory = {
186186 const modal = body . getByRole ( "dialog" ) ;
187187 const modalCanvas = within ( modal ) ;
188188
189- // Find the switch by its role - experiments use role="switch"
190- const switches = await modalCanvas . findAllByRole ( "switch" ) ;
191- if ( switches . length > 0 ) {
192- // Toggle the first experiment on
193- await userEvent . click ( switches [ 0 ] ) ;
194- }
189+ // Find the experiment toggle by its aria-label (set in ExperimentsSection.tsx)
190+ const toggle = await modalCanvas . findByRole ( "switch" , { name : / P o s t - C o m p a c t i o n C o n t e x t / i } ) ;
191+ await userEvent . click ( toggle ) ;
195192 } ,
196193} ;
197194
@@ -205,13 +202,10 @@ export const ExperimentsToggleOff: AppStory = {
205202 const modal = body . getByRole ( "dialog" ) ;
206203 const modalCanvas = within ( modal ) ;
207204
208- // Find the switch
209- const switches = await modalCanvas . findAllByRole ( "switch" ) ;
210- if ( switches . length > 0 ) {
211- // Toggle on first
212- await userEvent . click ( switches [ 0 ] ) ;
213- // Then toggle off
214- await userEvent . click ( switches [ 0 ] ) ;
215- }
205+ // Find the experiment toggle by its aria-label (set in ExperimentsSection.tsx)
206+ const toggle = await modalCanvas . findByRole ( "switch" , { name : / P o s t - C o m p a c t i o n C o n t e x t / i } ) ;
207+ // Toggle on first, then toggle off
208+ await userEvent . click ( toggle ) ;
209+ await userEvent . click ( toggle ) ;
216210 } ,
217211} ;
0 commit comments