11import type { Meta , StoryObj } from '@storybook/nextjs-vite' ;
22import { useMemo } from 'react' ;
3- import _rawUserEvent from '@testing-library/user-event' ;
43import { expect , screen , userEvent , waitFor , within } from 'storybook/test' ;
54import SuperJSON from 'superjson' ;
65import StoryInterviewShell from '~/.storybook/StoryInterviewShell' ;
@@ -1001,20 +1000,20 @@ export const SingleParentTwoDonors: ScenarioStory = {
10011000
10021001 // SiblingsDetailStep: ego's parents + 1 sibling
10031002
1004- // Uncheck Donor 2 from ego's parents and Donor 1 from sibling's parents
1005- // Uncheck Donor 2 from ego's parents by clicking the label text.
1006- // Note: userEvent.click on the checkbox button element doesn't work
1007- // in storybook's testing environment due to Base UI + motion.button
1008- // interaction. Clicking the text label within the <label> element
1009- // triggers the native label-checkbox association.
1003+ // Uncheck Donor 2 from ego's parents
10101004 const egoParentsContainer = await screen . findByTestId (
10111005 'ego-parents-checkboxes' ,
10121006 { } ,
10131007 STEP_TIMEOUT ,
10141008 ) ;
10151009 const egoScope = within ( egoParentsContainer ) ;
1016- const donor2Text = await egoScope . findByText ( 'Donor 2' , { } , STEP_TIMEOUT ) ;
1017- await userEvent . click ( donor2Text ) ;
1010+ const donor2Cb = await egoScope . findByRole (
1011+ 'checkbox' ,
1012+ { name : 'Donor 2' } ,
1013+ STEP_TIMEOUT ,
1014+ ) ;
1015+ donor2Cb . scrollIntoView ( ) ;
1016+ await userEvent . click ( donor2Cb ) ;
10181017 await waitForStepTransition ( ) ;
10191018
10201019 // Fill sibling details
@@ -1026,11 +1025,15 @@ export const SingleParentTwoDonors: ScenarioStory = {
10261025 ) ;
10271026 await userEvent . click ( sibSexRadios [ 0 ] ! ) ;
10281027
1029- // Uncheck Donor 1 from sibling's shared parents by clicking label text.
1030- // There are 2 "Donor 1" text elements: ego group and sibling group.
1031- const donor1Texts = await screen . findAllByText ( 'Donor 1' , { } , STEP_TIMEOUT ) ;
1032- // Index 1 is the sibling group's "Donor 1" text
1033- await userEvent . click ( donor1Texts [ 1 ] ! ) ;
1028+ // Uncheck Donor 1 from sibling's shared parents
1029+ const donor1Cbs = await screen . findAllByRole (
1030+ 'checkbox' ,
1031+ { name : 'Donor 1' } ,
1032+ STEP_TIMEOUT ,
1033+ ) ;
1034+ // Index 1 is the sibling's "Donor 1" checkbox
1035+ donor1Cbs [ 1 ] ! . scrollIntoView ( ) ;
1036+ await userEvent . click ( donor1Cbs [ 1 ] ! ) ;
10341037 await waitForStepTransition ( ) ;
10351038 await clickContinue ( ) ;
10361039 await waitForStepTransition ( ) ;
0 commit comments