Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e826e66
Remove unnecessary RegExp
ciampo Dec 22, 2023
6ca3f5d
Use @ariakit/test instead of testing library
ciampo Dec 22, 2023
6b5334f
Use sleep utility instead of custom promise
ciampo Dec 22, 2023
c97a986
Remove unnecessary import
ciampo Dec 22, 2023
8292091
Add utility functions
ciampo Dec 22, 2023
32b5703
Make multiple children test actually test what it's supposed to test
ciampo Dec 22, 2023
8cd4033
Test for tooltip to hide when another element gets focus
ciampo Dec 22, 2023
3894dca
Test for tooltip to hide when hovering outside the anchor
ciampo Dec 22, 2023
a6ca61f
Improve tooltip hiding on click test
ciampo Dec 22, 2023
7674cb0
More utils refactor
ciampo Dec 22, 2023
0c47cab
Improve test with disabled anchor
ciampo Dec 22, 2023
18a228c
Wait for tooltip to be hidden in the hideOnClick={false} test
ciampo Dec 22, 2023
5e590e3
Refactor custom delay test
ciampo Dec 22, 2023
4fe91bc
Refactor "mouse leave early" test (skip as it's still not passing)
ciampo Dec 22, 2023
be278f8
Improve shortcut-related tests
ciampo Dec 22, 2023
090e22b
Improve the Modal Escape test
ciampo Dec 22, 2023
b5aaf5a
Refactor description text test
ciampo Dec 22, 2023
cf1ea1a
Add second-level describes
ciampo Dec 22, 2023
2d4692a
Improve TS expecte error message
ciampo Jan 3, 2024
536ddeb
Add missing async/await in test utils
ciampo Jan 3, 2024
636678f
Await for tooltip to appear in shortcut tests
ciampo Jan 3, 2024
0e8c5e6
Apply delay prop only when showing the tooltip
ciampo Jan 3, 2024
57b5335
Add skip timeout waiting time after each test
ciampo Jan 3, 2024
21d2c0e
CHANGELOG
ciampo Jan 3, 2024
89372ed
Apply review feedback
ciampo Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve tooltip hiding on click test
  • Loading branch information
ciampo committed Jan 3, 2024
commit a6ca61f532eed109b6d3c33bdbc73acc9310031c
50 changes: 27 additions & 23 deletions packages/components/src/tooltip/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,36 @@ describe( 'Tooltip', () => {
await waitForTooltipToHide();
} );

it( 'should not show tooltip on focus as result of mouse click', async () => {
it( 'should hide tooltip when the tooltip anchor is clicked', async () => {
render( <Tooltip { ...props } /> );

await click( screen.getByRole( 'button', { name: 'Tooltip anchor' } ) );
const anchor = screen.getByRole( 'button', { name: 'Tooltip anchor' } );

expect(
screen.queryByRole( 'tooltip', { name: 'tooltip text' } )
).not.toBeInTheDocument();
expect( anchor ).toBeVisible();

// Hover over the anchor, tooltip should show
await hover( anchor );
await waitForTooltipToShow();

// Click the anchor, tooltip should hide
await click( anchor );
await waitForTooltipToHide();
} );

it( 'should not hide tooltip when the tooltip anchor is clicked and the `hideOnClick` prop is `false', async () => {
render( <Tooltip { ...props } hideOnClick={ false } /> );

const anchor = screen.getByRole( 'button', { name: 'Tooltip anchor' } );

expect( anchor ).toBeVisible();

// Hover over the anchor, tooltip should show
await hover( anchor );
await waitForTooltipToShow();

// Click the anchor, tooltip should not hide
await click( anchor );
await waitForTooltipToShow();
} );

it( 'should respect custom delay prop when showing tooltip', async () => {
Expand Down Expand Up @@ -308,22 +330,4 @@ describe( 'Tooltip', () => {
await screen.findByRole( 'button', { description: 'tooltip text' } )
).toBeInTheDocument();
} );

it( 'should not hide tooltip when the anchor is clicked if hideOnClick is false', async () => {
render( <Tooltip { ...props } hideOnClick={ false } /> );

const button = screen.getByRole( 'button', { name: 'Tooltip anchor' } );

await hover( button );

expect(
await screen.findByRole( 'tooltip', { name: 'tooltip text' } )
).toBeVisible();

await click( button );

expect(
screen.getByRole( 'tooltip', { name: 'tooltip text' } )
).toBeVisible();
} );
} );