Skip to content

Commit 3374c26

Browse files
committed
fix: click text label instead of checkbox button to toggle Base UI checkboxes
1 parent a072ee8 commit 3374c26

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

lib/interviewer/Interfaces/FamilyPedigree/FamilyPedigree.stories.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,20 +1002,19 @@ export const SingleParentTwoDonors: ScenarioStory = {
10021002
// SiblingsDetailStep: ego's parents + 1 sibling
10031003

10041004
// Uncheck Donor 2 from ego's parents and Donor 1 from sibling's parents
1005-
// Use raw (non-instrumented) userEvent because storybook's instrumented
1006-
// userEvent doesn't properly trigger Base UI checkbox onCheckedChange
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.
10071010
const egoParentsContainer = await screen.findByTestId(
10081011
'ego-parents-checkboxes',
10091012
{},
10101013
STEP_TIMEOUT,
10111014
);
10121015
const egoScope = within(egoParentsContainer);
1013-
const donor2Checkbox = await egoScope.findByRole(
1014-
'checkbox',
1015-
{ name: 'Donor 2' },
1016-
STEP_TIMEOUT,
1017-
);
1018-
await _rawUserEvent.click(donor2Checkbox);
1016+
const donor2Text = await egoScope.findByText('Donor 2', {}, STEP_TIMEOUT);
1017+
await userEvent.click(donor2Text);
10191018
await waitForStepTransition();
10201019

10211020
// Fill sibling details
@@ -1027,14 +1026,11 @@ export const SingleParentTwoDonors: ScenarioStory = {
10271026
);
10281027
await userEvent.click(sibSexRadios[0]!);
10291028

1030-
// Uncheck Donor 1 from sibling's shared parents
1031-
const donor1Checkboxes = await screen.findAllByRole(
1032-
'checkbox',
1033-
{ name: 'Donor 1' },
1034-
STEP_TIMEOUT,
1035-
);
1036-
// Index 1 is the sibling's "Donor 1" checkbox
1037-
await _rawUserEvent.click(donor1Checkboxes[1]!);
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]!);
10381034
await waitForStepTransition();
10391035
await clickContinue();
10401036
await waitForStepTransition();

0 commit comments

Comments
 (0)