Skip to content

Commit 75c28a2

Browse files
committed
Tweak unit test
1 parent 816569b commit 75c28a2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/ui/src/collapsible-card/test/index.test.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ describe( 'CollapsibleCard', () => {
110110
).not.toBeInTheDocument();
111111
} );
112112

113+
// In a real browser, clicking anywhere on the header toggles the
114+
// card because `pointer-events: none` on the content layer lets
115+
// clicks pass through to the background Collapsible.Trigger. jsdom
116+
// doesn't apply CSS, so we target the background trigger directly.
113117
it( 'toggles content when clicking the header area', async () => {
114118
const user = userEvent.setup();
115119

116120
render(
117121
<CollapsibleCard.Root>
118-
<CollapsibleCard.Header>
122+
<CollapsibleCard.Header data-testid="header">
119123
<Card.Title>Header click test</Card.Title>
120124
</CollapsibleCard.Header>
121125
<CollapsibleCard.Content>
@@ -128,7 +132,9 @@ describe( 'CollapsibleCard', () => {
128132
screen.queryByText( 'Header toggled content' )
129133
).not.toBeInTheDocument();
130134

131-
await user.click( screen.getByText( 'Header click test' ) );
135+
const header = screen.getByTestId( 'header' );
136+
// eslint-disable-next-line testing-library/no-node-access -- The background trigger has no accessible role; it's a visual-only click target.
137+
await user.click( header.firstElementChild! );
132138

133139
expect(
134140
screen.getByText( 'Header toggled content' )

0 commit comments

Comments
 (0)