Skip to content

Commit

Permalink
Tooltip: improve tests (#57345)
Browse files Browse the repository at this point in the history
* Remove unnecessary RegExp

* Use @ariakit/test instead of testing library

* Use sleep utility instead of custom promise

* Remove unnecessary import

* Add utility functions

* Make multiple children test actually test what it's supposed to test

* Test for tooltip to hide when another element gets focus

* Test for tooltip to hide when hovering outside the anchor

* Improve tooltip hiding on click test

* More utils refactor

* Improve test with disabled anchor

* Wait for tooltip to be hidden in the hideOnClick={false} test

* Refactor custom delay test

* Refactor "mouse leave early" test (skip as it's still not passing)

* Improve shortcut-related tests

* Improve the Modal Escape test

* Refactor description text test

* Add second-level describes

* Improve TS expecte error message

* Add missing async/await in test utils

* Await for tooltip to appear in shortcut tests

* Apply delay prop only when showing the tooltip

* Add skip timeout waiting time after each test

* CHANGELOG

* Apply review feedback
  • Loading branch information
ciampo committed Jan 4, 2024
1 parent e2bda40 commit bb2a39f
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 258 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- `BaseControl`: Connect to context system ([#57408](https://github.com/WordPress/gutenberg/pull/57408)).
- `InputControl`, `NumberControl`, `UnitControl`, `SelectControl`, `TreeSelect`: Add `compact` size variant ([#57398](https://github.com/WordPress/gutenberg/pull/57398)).
- `ToggleGroupControl`: Update button size in large variant to be 32px ([#57338](https://github.com/WordPress/gutenberg/pull/57338)).
- `Tooltip`: improve unit tests ([#57345](https://github.com/WordPress/gutenberg/pull/57345)).

### Experimental

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function UnforwardedModal(

if (
shouldCloseOnEsc &&
event.code === 'Escape' &&
( event.code === 'Escape' || event.key === 'Escape' ) &&
! event.defaultPrevented
) {
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function Tooltip( props: TooltipProps ) {

const tooltipStore = Ariakit.useTooltipStore( {
placement: computedPlacement,
timeout: delay,
showTimeout: delay,
} );

return (
Expand Down
Loading

0 comments on commit bb2a39f

Please sign in to comment.