diff --git a/package-lock.json b/package-lock.json
index d2c4a65342a35..02de0a60ff4c9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -86,7 +86,7 @@
"devDependencies": {
"@actions/core": "1.9.1",
"@actions/github": "5.0.0",
- "@ariakit/test": "^0.3.5",
+ "@ariakit/test": "^0.3.7",
"@babel/core": "7.16.0",
"@babel/plugin-proposal-export-namespace-from": "7.18.9",
"@babel/plugin-syntax-jsx": "7.16.0",
@@ -1628,13 +1628,48 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/@ariakit/core": {
+ "version": "0.3.10",
+ "resolved": "https://registry.npmjs.org/@ariakit/core/-/core-0.3.10.tgz",
+ "integrity": "sha512-AcN+GSoVXuUOzKx5d3xPL3YsEHevh4PIO6QIt/mg/nRX1XQ6cvxQEiAjO/BJQm+/MVl7/VbuGBoTFjr0tPU6NQ=="
+ },
+ "node_modules/@ariakit/react": {
+ "version": "0.3.12",
+ "resolved": "https://registry.npmjs.org/@ariakit/react/-/react-0.3.12.tgz",
+ "integrity": "sha512-HxKMZZhWSkwwS/Sh9OdWyuNKQ2tjDAIQIy2KVI7IRa8ZQ6ze/4g3YLUHbfCxO7oDupXHfXaeZ4hWx8lP7l1U/g==",
+ "dependencies": {
+ "@ariakit/react-core": "0.3.12"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/ariakit"
+ },
+ "peerDependencies": {
+ "react": "^17.0.0 || ^18.0.0",
+ "react-dom": "^17.0.0 || ^18.0.0"
+ }
+ },
+ "node_modules/@ariakit/react-core": {
+ "version": "0.3.12",
+ "resolved": "https://registry.npmjs.org/@ariakit/react-core/-/react-core-0.3.12.tgz",
+ "integrity": "sha512-w6P1A7TYb1fKUe9QbwaoTOWofl13g7TEuXdV4JyefJCQL1e9HQdEw9UL67I8aXRo8/cFHH94/z0N37t8hw5Ogg==",
+ "dependencies": {
+ "@ariakit/core": "0.3.10",
+ "@floating-ui/dom": "^1.0.0",
+ "use-sync-external-store": "^1.2.0"
+ },
+ "peerDependencies": {
+ "react": "^17.0.0 || ^18.0.0",
+ "react-dom": "^17.0.0 || ^18.0.0"
+ }
+ },
"node_modules/@ariakit/test": {
- "version": "0.3.5",
- "resolved": "https://registry.npmjs.org/@ariakit/test/-/test-0.3.5.tgz",
- "integrity": "sha512-7UCQBnJZ88JptkEnAXT7iSgtxEZiFwqdkKtxLCXDssTOJNatbFsnq0Jow324y41jGfAE2n4Lf5qY2FsZUPf9XQ==",
+ "version": "0.3.7",
+ "resolved": "https://registry.npmjs.org/@ariakit/test/-/test-0.3.7.tgz",
+ "integrity": "sha512-rOa9pJA0ZfPPSI4SkDX41CsBcvxs6BmxgzFEElZWZo/uBBqtnr8ZL4oe5HySeZKEAHRH86XDqfxFISkhV76m5g==",
"dev": true,
"dependencies": {
- "@ariakit/core": "0.3.8",
+ "@ariakit/core": "0.3.10",
"@testing-library/dom": "^8.0.0 || ^9.0.0"
},
"peerDependencies": {
@@ -1650,12 +1685,6 @@
}
}
},
- "node_modules/@ariakit/test/node_modules/@ariakit/core": {
- "version": "0.3.8",
- "resolved": "https://registry.npmjs.org/@ariakit/core/-/core-0.3.8.tgz",
- "integrity": "sha512-LlSCwbyyozMX4ZEobpYGcv1LFqOdBTdTYPZw3lAVgLcFSNivsazi3NkKM9qNWNIu00MS+xTa0+RuIcuWAjlB2Q==",
- "dev": true
- },
"node_modules/@aw-web-design/x-default-browser": {
"version": "1.4.126",
"resolved": "https://registry.npmjs.org/@aw-web-design/x-default-browser/-/x-default-browser-1.4.126.tgz",
@@ -54244,7 +54273,7 @@
"version": "25.14.0",
"license": "GPL-2.0-or-later",
"dependencies": {
- "@ariakit/react": "^0.3.10",
+ "@ariakit/react": "^0.3.12",
"@babel/runtime": "^7.16.0",
"@emotion/cache": "^11.7.1",
"@emotion/css": "^11.7.1",
@@ -54303,41 +54332,6 @@
"react-dom": "^18.0.0"
}
},
- "packages/components/node_modules/@ariakit/core": {
- "version": "0.3.8",
- "resolved": "https://registry.npmjs.org/@ariakit/core/-/core-0.3.8.tgz",
- "integrity": "sha512-LlSCwbyyozMX4ZEobpYGcv1LFqOdBTdTYPZw3lAVgLcFSNivsazi3NkKM9qNWNIu00MS+xTa0+RuIcuWAjlB2Q=="
- },
- "packages/components/node_modules/@ariakit/react": {
- "version": "0.3.10",
- "resolved": "https://registry.npmjs.org/@ariakit/react/-/react-0.3.10.tgz",
- "integrity": "sha512-XRY69IOm8Oy+HSPoaspcVLAhLo3ToLhhJKSLK1voTAZtSzu5kUeUf4nUPxTzYFsvirKORZgOLAeNwuo1gPr61g==",
- "dependencies": {
- "@ariakit/react-core": "0.3.10"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/ariakit"
- },
- "peerDependencies": {
- "react": "^17.0.0 || ^18.0.0",
- "react-dom": "^17.0.0 || ^18.0.0"
- }
- },
- "packages/components/node_modules/@ariakit/react-core": {
- "version": "0.3.10",
- "resolved": "https://registry.npmjs.org/@ariakit/react-core/-/react-core-0.3.10.tgz",
- "integrity": "sha512-CzSffcNlOyS2xuy21UB6fgJXi5LriJ9JrTSJzcgJmE+P9/WfQlplJC3L75d8O2yKgaGPeFnQ0hhDA6ItsI98eQ==",
- "dependencies": {
- "@ariakit/core": "0.3.8",
- "@floating-ui/dom": "^1.0.0",
- "use-sync-external-store": "^1.2.0"
- },
- "peerDependencies": {
- "react": "^17.0.0 || ^18.0.0",
- "react-dom": "^17.0.0 || ^18.0.0"
- }
- },
"packages/components/node_modules/@floating-ui/react-dom": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz",
@@ -57392,22 +57386,37 @@
}
}
},
+ "@ariakit/core": {
+ "version": "0.3.10",
+ "resolved": "https://registry.npmjs.org/@ariakit/core/-/core-0.3.10.tgz",
+ "integrity": "sha512-AcN+GSoVXuUOzKx5d3xPL3YsEHevh4PIO6QIt/mg/nRX1XQ6cvxQEiAjO/BJQm+/MVl7/VbuGBoTFjr0tPU6NQ=="
+ },
+ "@ariakit/react": {
+ "version": "0.3.12",
+ "resolved": "https://registry.npmjs.org/@ariakit/react/-/react-0.3.12.tgz",
+ "integrity": "sha512-HxKMZZhWSkwwS/Sh9OdWyuNKQ2tjDAIQIy2KVI7IRa8ZQ6ze/4g3YLUHbfCxO7oDupXHfXaeZ4hWx8lP7l1U/g==",
+ "requires": {
+ "@ariakit/react-core": "0.3.12"
+ }
+ },
+ "@ariakit/react-core": {
+ "version": "0.3.12",
+ "resolved": "https://registry.npmjs.org/@ariakit/react-core/-/react-core-0.3.12.tgz",
+ "integrity": "sha512-w6P1A7TYb1fKUe9QbwaoTOWofl13g7TEuXdV4JyefJCQL1e9HQdEw9UL67I8aXRo8/cFHH94/z0N37t8hw5Ogg==",
+ "requires": {
+ "@ariakit/core": "0.3.10",
+ "@floating-ui/dom": "^1.0.0",
+ "use-sync-external-store": "^1.2.0"
+ }
+ },
"@ariakit/test": {
- "version": "0.3.5",
- "resolved": "https://registry.npmjs.org/@ariakit/test/-/test-0.3.5.tgz",
- "integrity": "sha512-7UCQBnJZ88JptkEnAXT7iSgtxEZiFwqdkKtxLCXDssTOJNatbFsnq0Jow324y41jGfAE2n4Lf5qY2FsZUPf9XQ==",
+ "version": "0.3.7",
+ "resolved": "https://registry.npmjs.org/@ariakit/test/-/test-0.3.7.tgz",
+ "integrity": "sha512-rOa9pJA0ZfPPSI4SkDX41CsBcvxs6BmxgzFEElZWZo/uBBqtnr8ZL4oe5HySeZKEAHRH86XDqfxFISkhV76m5g==",
"dev": true,
"requires": {
- "@ariakit/core": "0.3.8",
+ "@ariakit/core": "0.3.10",
"@testing-library/dom": "^8.0.0 || ^9.0.0"
- },
- "dependencies": {
- "@ariakit/core": {
- "version": "0.3.8",
- "resolved": "https://registry.npmjs.org/@ariakit/core/-/core-0.3.8.tgz",
- "integrity": "sha512-LlSCwbyyozMX4ZEobpYGcv1LFqOdBTdTYPZw3lAVgLcFSNivsazi3NkKM9qNWNIu00MS+xTa0+RuIcuWAjlB2Q==",
- "dev": true
- }
}
},
"@aw-web-design/x-default-browser": {
@@ -69363,7 +69372,7 @@
"@wordpress/components": {
"version": "file:packages/components",
"requires": {
- "@ariakit/react": "^0.3.10",
+ "@ariakit/react": "^0.3.12",
"@babel/runtime": "^7.16.0",
"@emotion/cache": "^11.7.1",
"@emotion/css": "^11.7.1",
@@ -69415,29 +69424,6 @@
"valtio": "1.7.0"
},
"dependencies": {
- "@ariakit/core": {
- "version": "0.3.8",
- "resolved": "https://registry.npmjs.org/@ariakit/core/-/core-0.3.8.tgz",
- "integrity": "sha512-LlSCwbyyozMX4ZEobpYGcv1LFqOdBTdTYPZw3lAVgLcFSNivsazi3NkKM9qNWNIu00MS+xTa0+RuIcuWAjlB2Q=="
- },
- "@ariakit/react": {
- "version": "0.3.10",
- "resolved": "https://registry.npmjs.org/@ariakit/react/-/react-0.3.10.tgz",
- "integrity": "sha512-XRY69IOm8Oy+HSPoaspcVLAhLo3ToLhhJKSLK1voTAZtSzu5kUeUf4nUPxTzYFsvirKORZgOLAeNwuo1gPr61g==",
- "requires": {
- "@ariakit/react-core": "0.3.10"
- }
- },
- "@ariakit/react-core": {
- "version": "0.3.10",
- "resolved": "https://registry.npmjs.org/@ariakit/react-core/-/react-core-0.3.10.tgz",
- "integrity": "sha512-CzSffcNlOyS2xuy21UB6fgJXi5LriJ9JrTSJzcgJmE+P9/WfQlplJC3L75d8O2yKgaGPeFnQ0hhDA6ItsI98eQ==",
- "requires": {
- "@ariakit/core": "0.3.8",
- "@floating-ui/dom": "^1.0.0",
- "use-sync-external-store": "^1.2.0"
- }
- },
"@floating-ui/react-dom": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz",
diff --git a/package.json b/package.json
index e98ad7cb1587f..f2f239762de97 100644
--- a/package.json
+++ b/package.json
@@ -98,7 +98,7 @@
"devDependencies": {
"@actions/core": "1.9.1",
"@actions/github": "5.0.0",
- "@ariakit/test": "^0.3.5",
+ "@ariakit/test": "^0.3.7",
"@babel/core": "7.16.0",
"@babel/plugin-proposal-export-namespace-from": "7.18.9",
"@babel/plugin-syntax-jsx": "7.16.0",
diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md
index 8805736c2e440..c7c1a515a64ce 100644
--- a/packages/components/CHANGELOG.md
+++ b/packages/components/CHANGELOG.md
@@ -24,6 +24,7 @@
### Enhancements
- Update `ariakit` to version `0.3.10` ([#57325](https://github.com/WordPress/gutenberg/pull/57325)).
+- Update `@ariakit/react` to version `0.3.12` and @ariakit/test to version `0.3.7` ([#57547](https://github.com/WordPress/gutenberg/pull/57547)).
- `DropdownMenuV2`: do not collapse suffix width ([#57238](https://github.com/WordPress/gutenberg/pull/57238)).
- `DateTimePicker`: Adjustment of the dot position on DayButton and expansion of the button area. ([#55502](https://github.com/WordPress/gutenberg/pull/55502)).
- `Modal`: Improve application of body class names ([#55430](https://github.com/WordPress/gutenberg/pull/55430)).
diff --git a/packages/components/package.json b/packages/components/package.json
index 885c1e455fea4..cd440998b9323 100644
--- a/packages/components/package.json
+++ b/packages/components/package.json
@@ -30,7 +30,7 @@
],
"types": "build-types",
"dependencies": {
- "@ariakit/react": "^0.3.10",
+ "@ariakit/react": "^0.3.12",
"@babel/runtime": "^7.16.0",
"@emotion/cache": "^11.7.1",
"@emotion/css": "^11.7.1",
diff --git a/packages/components/src/alignment-matrix-control/test/index.tsx b/packages/components/src/alignment-matrix-control/test/index.tsx
index 6836bc7e45f95..a820b69b26c8f 100644
--- a/packages/components/src/alignment-matrix-control/test/index.tsx
+++ b/packages/components/src/alignment-matrix-control/test/index.tsx
@@ -2,7 +2,7 @@
* External dependencies
*/
import { render, screen, waitFor, within } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
+import { press, click } from '@ariakit/test';
/**
* Internal dependencies
@@ -37,11 +37,9 @@ describe( 'AlignmentMatrixControl', () => {
} );
it( 'should be centered by default', async () => {
- const user = userEvent.setup();
-
await renderAndInitCompositeStore( );
- await user.tab();
+ await press.Tab();
expect( getCell( 'center center' ) ).toHaveFocus();
} );
@@ -60,7 +58,6 @@ describe( 'AlignmentMatrixControl', () => {
'bottom center',
'bottom right',
] )( '%s', async ( alignment ) => {
- const user = userEvent.setup();
const spy = jest.fn();
await renderAndInitCompositeStore(
@@ -72,14 +69,13 @@ describe( 'AlignmentMatrixControl', () => {
const cell = getCell( alignment );
- await user.click( cell );
+ await click( cell );
expect( cell ).toHaveFocus();
expect( spy ).toHaveBeenCalledWith( alignment );
} );
it( 'unless already focused', async () => {
- const user = userEvent.setup();
const spy = jest.fn();
await renderAndInitCompositeStore(
@@ -91,7 +87,7 @@ describe( 'AlignmentMatrixControl', () => {
const cell = getCell( 'center center' );
- await user.click( cell );
+ await click( cell );
expect( cell ).toHaveFocus();
expect( spy ).not.toHaveBeenCalled();
@@ -106,16 +102,15 @@ describe( 'AlignmentMatrixControl', () => {
[ 'ArrowLeft', 'center left' ],
[ 'ArrowDown', 'bottom center' ],
[ 'ArrowRight', 'center right' ],
- ] )( '%s', async ( keyRef, cellRef ) => {
- const user = userEvent.setup();
+ ] as const )( '%s', async ( keyRef, cellRef ) => {
const spy = jest.fn();
await renderAndInitCompositeStore(
);
- await user.tab();
- await user.keyboard( `[${ keyRef }]` );
+ await press.Tab();
+ await press[ keyRef ]();
expect( getCell( cellRef ) ).toHaveFocus();
expect( spy ).toHaveBeenCalledWith( cellRef );
@@ -128,8 +123,7 @@ describe( 'AlignmentMatrixControl', () => {
[ 'ArrowLeft', 'top left' ],
[ 'ArrowDown', 'bottom right' ],
[ 'ArrowRight', 'bottom right' ],
- ] )( '%s', async ( keyRef, cellRef ) => {
- const user = userEvent.setup();
+ ] as const )( '%s', async ( keyRef, cellRef ) => {
const spy = jest.fn();
await renderAndInitCompositeStore(
@@ -137,8 +131,8 @@ describe( 'AlignmentMatrixControl', () => {
);
const cell = getCell( cellRef );
- await user.click( cell );
- await user.keyboard( `[${ keyRef }]` );
+ await click( cell );
+ await press[ keyRef ]();
expect( cell ).toHaveFocus();
expect( spy ).toHaveBeenCalledWith( cellRef );
diff --git a/packages/components/src/toggle-group-control/test/index.tsx b/packages/components/src/toggle-group-control/test/index.tsx
index b54b5764d4e0f..99a2dd8a00421 100644
--- a/packages/components/src/toggle-group-control/test/index.tsx
+++ b/packages/components/src/toggle-group-control/test/index.tsx
@@ -2,7 +2,7 @@
* External dependencies
*/
import { render, screen, waitFor } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
+import { press, click, hover, sleep } from '@ariakit/test';
/**
* WordPress dependencies
@@ -19,8 +19,13 @@ import {
ToggleGroupControlOption,
ToggleGroupControlOptionIcon,
} from '../index';
+import { TOOLTIP_DELAY } from '../../tooltip';
import type { ToggleGroupControlProps } from '../types';
-import cleanupTooltip from '../../tooltip/test/utils';
+
+const hoverOutside = async () => {
+ await hover( document.body );
+ await hover( document.body, { clientX: 10, clientY: 10 } );
+};
const ControlledToggleGroupControl = ( {
value: valueProp,
@@ -113,7 +118,6 @@ describe.each( [
} );
} );
it( 'should call onChange with proper value', async () => {
- const user = userEvent.setup();
const mockOnChange = jest.fn();
render(
@@ -126,13 +130,12 @@ describe.each( [
);
- await user.click( screen.getByRole( 'radio', { name: 'R' } ) );
+ await click( screen.getByRole( 'radio', { name: 'R' } ) );
expect( mockOnChange ).toHaveBeenCalledWith( 'rigas' );
} );
it( 'should render tooltip where `showTooltip` === `true`', async () => {
- const user = userEvent.setup();
render(
{ optionsWithTooltip }
@@ -143,19 +146,26 @@ describe.each( [
'Click for Delicious Gnocchi'
);
- await user.hover( firstRadio );
+ await hover( firstRadio );
- const tooltip = await screen.findByText(
- 'Click for Delicious Gnocchi'
- );
+ const tooltip = await screen.findByRole( 'tooltip', {
+ name: 'Click for Delicious Gnocchi',
+ } );
await waitFor( () => expect( tooltip ).toBeVisible() );
- await cleanupTooltip( user );
+ // hover outside of radio
+ await hoverOutside();
+
+ // Tooltip should hide
+ expect(
+ screen.queryByRole( 'tooltip', {
+ name: 'Click for Delicious Gnocchi',
+ } )
+ ).not.toBeInTheDocument();
} );
it( 'should not render tooltip', async () => {
- const user = userEvent.setup();
render(
{ optionsWithTooltip }
@@ -166,19 +176,24 @@ describe.each( [
'Click for Sumptuous Caponata'
);
- await user.hover( secondRadio );
+ await hover( secondRadio );
- await waitFor( () =>
- expect(
- screen.queryByText( 'Click for Sumptuous Caponata' )
- ).not.toBeInTheDocument()
- );
+ // Tooltip shouldn't show
+ expect(
+ screen.queryByText( 'Click for Sumptuous Caponata' )
+ ).not.toBeInTheDocument();
+
+ // Advance time by default delay
+ await sleep( TOOLTIP_DELAY );
+
+ // Tooltip shouldn't show.
+ expect(
+ screen.queryByText( 'Click for Sumptuous Caponata' )
+ ).not.toBeInTheDocument();
} );
if ( mode === 'controlled' ) {
it( 'should reset values correctly', async () => {
- const user = userEvent.setup();
-
render(
{ options }
@@ -188,25 +203,23 @@ describe.each( [
const rigasOption = screen.getByRole( 'radio', { name: 'R' } );
const jackOption = screen.getByRole( 'radio', { name: 'J' } );
- await user.click( rigasOption );
+ await click( rigasOption );
expect( jackOption ).not.toBeChecked();
expect( rigasOption ).toBeChecked();
- await user.keyboard( '[ArrowRight]' );
+ await press.ArrowRight();
expect( rigasOption ).not.toBeChecked();
expect( jackOption ).toBeChecked();
- await user.click( screen.getByRole( 'button', { name: 'Reset' } ) );
+ await click( screen.getByRole( 'button', { name: 'Reset' } ) );
expect( rigasOption ).not.toBeChecked();
expect( jackOption ).not.toBeChecked();
} );
it( 'should update correctly when triggered by external updates', async () => {
- const user = userEvent.setup();
-
render(
{
it( 'should not be deselectable', async () => {
const mockOnChange = jest.fn();
- const user = userEvent.setup();
render(
{
- const user = userEvent.setup();
-
render(
-
- { options }
-
+ <>
+
+ { options }
+
+
+ >
);
const rigas = screen.getByRole( 'radio', {
name: 'R',
} );
- await user.tab();
+ await press.Tab();
expect( rigas ).toHaveFocus();
- await user.tab();
+ await press.Tab();
+ // When in controlled mode, there is an additional "Reset" button.
const expectedFocusTarget =
mode === 'uncontrolled'
- ? rigas.ownerDocument.body
+ ? screen.getByRole( 'button', {
+ name: 'After ToggleGroupControl',
+ } )
: screen.getByRole( 'button', { name: 'Reset' } );
expect( expectedFocusTarget ).toHaveFocus();
@@ -301,7 +317,6 @@ describe.each( [
describe( 'isDeselectable = true', () => {
it( 'should be deselectable', async () => {
const mockOnChange = jest.fn();
- const user = userEvent.setup();
render(
);
- await user.click(
+ await click(
screen.getByRole( 'button', {
name: 'R',
pressed: true,
@@ -323,7 +338,7 @@ describe.each( [
expect( mockOnChange ).toHaveBeenCalledTimes( 1 );
expect( mockOnChange ).toHaveBeenLastCalledWith( undefined );
- await user.click(
+ await click(
screen.getByRole( 'button', {
name: 'R',
pressed: false,
@@ -334,15 +349,13 @@ describe.each( [
} );
it( 'should tab to the next option button', async () => {
- const user = userEvent.setup();
-
render(
{ options }
);
- await user.tab();
+ await press.Tab();
expect(
screen.getByRole( 'button', {
name: 'R',
@@ -350,7 +363,7 @@ describe.each( [
} )
).toHaveFocus();
- await user.tab();
+ await press.Tab();
expect(
screen.getByRole( 'button', {
name: 'J',
@@ -359,7 +372,7 @@ describe.each( [
).toHaveFocus();
// Focus should not move with arrow keys
- await user.keyboard( '{ArrowLeft}' );
+ await press.ArrowLeft();
expect(
screen.getByRole( 'button', {
name: 'J',