@@ -1000,19 +1000,26 @@ export const SingleParentTwoDonors: ScenarioStory = {
10001000
10011001 // SiblingsDetailStep: ego's parents + 1 sibling
10021002
1003- // Uncheck Donor 2 from ego's parents
1003+ // Uncheck Donor 2 from ego's parents and Donor 1 from sibling's parents
1004+ // Use JavaScript to directly set checkbox values since Base UI checkboxes
1005+ // don't respond to userEvent.click in the storybook testing environment
10041006 const egoParentsContainer = await screen . findByTestId (
10051007 'ego-parents-checkboxes' ,
10061008 { } ,
10071009 STEP_TIMEOUT ,
10081010 ) ;
1009- const egoScope = within ( egoParentsContainer ) ;
1010- const donor2Checkbox = await egoScope . findByRole (
1011- 'checkbox' ,
1012- { name : 'Donor 2' } ,
1013- STEP_TIMEOUT ,
1014- ) ;
1015- await userEvent . pointer ( { keys : '[MouseLeft]' , target : donor2Checkbox } ) ;
1011+ const egoCheckboxes =
1012+ egoParentsContainer . querySelectorAll < HTMLElement > ( '[role="checkbox"]' ) ;
1013+ // Uncheck Donor 2 (index 2) by dispatching a proper event
1014+ for ( const cb of egoCheckboxes ) {
1015+ const label = cb . closest ( 'label' ) ?. textContent ?. trim ( ) ;
1016+ if ( label === 'Donor 2' && cb . getAttribute ( 'aria-checked' ) === 'true' ) {
1017+ // Simulate a full pointer interaction sequence
1018+ cb . dispatchEvent ( new PointerEvent ( 'pointerdown' , { bubbles : true } ) ) ;
1019+ cb . dispatchEvent ( new PointerEvent ( 'pointerup' , { bubbles : true } ) ) ;
1020+ cb . dispatchEvent ( new MouseEvent ( 'click' , { bubbles : true } ) ) ;
1021+ }
1022+ }
10161023 await waitForStepTransition ( ) ;
10171024
10181025 // Fill sibling details
@@ -1025,15 +1032,21 @@ export const SingleParentTwoDonors: ScenarioStory = {
10251032 await userEvent . click ( sibSexRadios [ 0 ] ! ) ;
10261033
10271034 // Uncheck Donor 1 from sibling's shared parents
1028- const donor1Checkboxes = await screen . findAllByRole (
1029- 'checkbox' ,
1030- { name : 'Donor 1' } ,
1031- STEP_TIMEOUT ,
1032- ) ;
1033- await userEvent . pointer ( {
1034- keys : '[MouseLeft]' ,
1035- target : donor1Checkboxes [ 1 ] ! ,
1036- } ) ;
1035+ // Find all checkboxes labeled "Donor 1" — the second one is in the sibling group
1036+ const allCheckboxes =
1037+ document . querySelectorAll < HTMLElement > ( '[role="checkbox"]' ) ;
1038+ let donor1Count = 0 ;
1039+ for ( const cb of allCheckboxes ) {
1040+ const label = cb . closest ( 'label' ) ?. textContent ?. trim ( ) ;
1041+ if ( label === 'Donor 1' ) {
1042+ donor1Count ++ ;
1043+ if ( donor1Count === 2 && cb . getAttribute ( 'aria-checked' ) === 'true' ) {
1044+ cb . dispatchEvent ( new PointerEvent ( 'pointerdown' , { bubbles : true } ) ) ;
1045+ cb . dispatchEvent ( new PointerEvent ( 'pointerup' , { bubbles : true } ) ) ;
1046+ cb . dispatchEvent ( new MouseEvent ( 'click' , { bubbles : true } ) ) ;
1047+ }
1048+ }
1049+ }
10371050 await waitForStepTransition ( ) ;
10381051 await clickContinue ( ) ;
10391052 await waitForStepTransition ( ) ;
0 commit comments