Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 0 additions & 41 deletions packages/@react-spectrum/checkbox/docs/CheckboxGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {Layout} from '@react-spectrum/docs';
export default Layout;

import docs from 'docs:@react-spectrum/checkbox';
import checkboxgroupUtil from 'docs:@react-aria/test-utils/src/checkboxgroup.ts';
import packageData from '@react-spectrum/checkbox/package.json';
import {HeaderInfo, PropTable, PageDescription, VersionBadge, ClassAPI} from '@react-spectrum/docs';

Expand Down Expand Up @@ -333,43 +332,3 @@ See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/
<Checkbox value="basketball">Basketball</Checkbox>
</CheckboxGroup>
```

## Testing

### Test utils <VersionBadge version="beta" style={{marginLeft: 4, verticalAlign: 'bottom'}} />

`@react-spectrum/test-utils` offers common checkbox group interaction utilities which you may find helpful when writing tests. See [here](./testing.html#react-spectrum-test-utils) for more information on how to setup these utilities
in your tests. Below is the full definition of the checkbox group tester and a sample of how you could use it in your test suite.

```ts
// CheckboxGroup.test.ts
import {render} from '@testing-library/react';
import {theme} from '@react-spectrum/theme-default';
import {User} from '@react-spectrum/test-utils';

let testUtilUser = new User({interactionType: 'mouse', advanceTimer: jest.advanceTimersByTime});
// ...

it('CheckboxGroup can select multiple checkboxes', async function () {
// Render your test component/app and initialize the checkbox group tester
let {getByTestId} = render(
<Provider theme={defaultTheme}>
<CheckboxGroup data-testid="test-checkboxgroup">
...
</CheckboxGroup>
</Provider>
);
let checkboxGroupTester = testUtilUser.createTester('CheckboxGroup', {root: getByTestId('test-checkboxgroup')});
expect(checkboxGroupTester.selectedCheckboxes).toHaveLength(0);

await checkboxGroupTester.toggleCheckbox({checkbox: 0});
expect(checkboxGroupTester.checkboxes[0]).toBeChecked();
expect(checkboxGroupTester.selectedCheckboxes).toHaveLength(1);

await checkboxGroupTester.toggleCheckbox({checkbox: 4});
expect(checkboxGroupTester.checkboxes[4]).toBeChecked();
expect(checkboxGroupTester.selectedCheckboxes).toHaveLength(2);
});
```

<ClassAPI links={checkboxgroupUtil.links} class={checkboxgroupUtil.exports.CheckboxGroupTester} />
41 changes: 0 additions & 41 deletions packages/@react-spectrum/dialog/docs/Dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default Layout;

import DialogAnatomy from './images/DialogAnatomy.svg';
import docs from 'docs:@react-spectrum/dialog';
import dialogUtil from 'docs:@react-aria/test-utils/src/dialog.ts';
import {Image, HeaderInfo, PropTable, PageDescription, VersionBadge, ClassAPI} from '@react-spectrum/docs';
import packageData from '@react-spectrum/dialog/package.json';
import styles from '@react-spectrum/docs/src/docs.css';
Expand Down Expand Up @@ -399,43 +398,3 @@ respectively for container sizing considerations. Modal sizes on mobile devices
)}
</DialogTrigger>
```

## Testing

### Test utils <VersionBadge version="beta" style={{marginLeft: 4, verticalAlign: 'bottom'}} />

`@react-spectrum/test-utils` offers common dialog interaction utilities which you may find helpful when writing tests. See [here](./testing.html#react-spectrum-test-utils) for more information on how to setup these utilities
in your tests. Below is the full definition of the dialog tester and a sample of how you could use it in your test suite.

```ts
// Dialog.test.ts
import {render} from '@testing-library/react';
import {theme} from '@react-spectrum/theme-default';
import {User} from '@react-spectrum/test-utils';

let testUtilUser = new User({interactionType: 'mouse', advanceTimer: jest.advanceTimersByTime});
// ...

it('Dialog can be opened and closed', async function () {
// Render your test component/app and initialize the dialog tester
let {getByTestId, getByRole} = render(
<Provider theme={defaultTheme}>
<DialogTrigger>
<ActionButton>Trigger</ActionButton>
<Dialog>
...
</Dialog>
</DialogTrigger>
</Provider>
);
let button = getByRole('button');
let dialogTester = testUtilUser.createTester('Dialog', {root: button, overlayType: 'modal'});
await dialogTester.open();
let dialog = dialogTester.dialog;
expect(dialog).toBeVisible();
await dialogTester.close();
expect(dialog).not.toBeInTheDocument();
});
```

<ClassAPI links={dialogUtil.links} class={dialogUtil.exports.DialogTester} />
41 changes: 0 additions & 41 deletions packages/@react-spectrum/radio/docs/RadioGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {Layout} from '@react-spectrum/docs';
export default Layout;

import docs from 'docs:@react-spectrum/radio';
import radiogroupUtil from 'docs:@react-aria/test-utils/src/radiogroup.ts';
import packageData from '@react-spectrum/radio/package.json';
import {HeaderInfo, PropTable, PageDescription, VersionBadge, ClassAPI} from '@react-spectrum/docs';

Expand Down Expand Up @@ -307,43 +306,3 @@ See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/
<Radio value="dragon">Dragon</Radio>
</RadioGroup>
```

## Testing

### Test utils <VersionBadge version="beta" style={{marginLeft: 4, verticalAlign: 'bottom'}} />

`@react-spectrum/test-utils` offers common radio group interaction utilities which you may find helpful when writing tests. See [here](./testing.html#react-spectrum-test-utils) for more information on how to setup these utilities
in your tests. Below is the full definition of the radio group tester and a sample of how you could use it in your test suite.

```ts
// RadioGroup.test.ts
import {render} from '@testing-library/react';
import {theme} from '@react-spectrum/theme-default';
import {User} from '@react-spectrum/test-utils';

let testUtilUser = new User({interactionType: 'mouse', advanceTimer: jest.advanceTimersByTime});
// ...

it('RadioGroup can switch the selected radio', async function () {
// Render your test component/app and initialize the radiogroup tester
let {getByRole} = render(
<Provider theme={defaultTheme}>
<RadioGroup>
...
</RadioGroup>
</Provider>
);

let radioGroupTester = testUtilUser.createTester('RadioGroup', {root: getByRole('radiogroup')});
let radios = radioGroupTester.radios;
expect(radioGroupTester.selectedRadio).toBeFalsy();

await radioGroupTester.triggerRadio({radio: radios[0]});
expect(radioGroupTester.selectedRadio).toBe(radios[0]);

await radioGroupTester.triggerRadio({radio: radios[1]});
expect(radioGroupTester.selectedRadio).toBe(radios[1]);
});
```

<ClassAPI links={radiogroupUtil.links} class={radiogroupUtil.exports.RadioGroupTester} />
5 changes: 4 additions & 1 deletion packages/@react-spectrum/s2/src/TableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,10 @@ const commonCellStyles = {

const cell = style<CellRenderProps & S2TableProps & {isDivider: boolean}>({
...commonCellStyles,
color: baseColor('neutral'),
color: {
default: baseColor('neutral-subdued'),
isSelected: baseColor('neutral')
},
paddingY: centerPadding(),
minHeight: {
default: 40,
Expand Down
7 changes: 5 additions & 2 deletions packages/@react-spectrum/s2/src/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import {ActionButtonGroupContext} from './ActionButtonGroup';
import {ActionMenuContext} from './ActionMenu';
import {baseColor, colorMix, focusRing, fontRelative, style} from '../style' with {type: 'macro'};
import {
Button,
ButtonContext,
Expand All @@ -31,7 +32,6 @@ import {
import {centerBaseline} from './CenterBaseline';
import {Checkbox} from './Checkbox';
import Chevron from '../ui-icons/Chevron';
import {colorMix, focusRing, fontRelative, style} from '../style' with {type: 'macro'};
import {DOMRef, forwardRefType, GlobalDOMAttributes, Key, LoadingState} from '@react-types/shared';
import {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};
import {IconContext} from './Icon';
Expand Down Expand Up @@ -153,7 +153,10 @@ const treeRow = style({
width: 'full',
boxSizing: 'border-box',
font: 'ui',
color: 'body',
color: {
default: baseColor('neutral-subdued'),
isSelected: baseColor('neutral')
},
outlineStyle: 'none',
cursor: {
default: 'default',
Expand Down
6 changes: 0 additions & 6 deletions packages/dev/docs/pages/react-aria/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,14 @@ See below for the full definition of the `User` object.
Below is a list of the ARIA patterns testers currently supported by `createTester`. See the accompanying component testing docs pages for a sample of how to use
the testers in your test suite.

- [CheckboxGroup](CheckboxGroup.html#test-utils)

- [ComboBox](ComboBox.html#test-utils)

- [Dialog](Dialog.html#test-utils)

- [GridList](GridList.html#test-utils)

- [ListBox](ListBox.html#test-utils)

- [Menu](Menu.html#test-utils)

- [RadioGroup](RadioGroup.html#test-utils)

- [Select](Select.html#test-utils)

- [Table](Table.html#test-utils)
Expand Down
6 changes: 0 additions & 6 deletions packages/dev/docs/pages/react-spectrum/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -395,20 +395,14 @@ See below for the full definition of the `User` object.
Below is a list of the ARIA patterns testers currently supported by `createTester`. See the accompanying component testing docs pages for a sample of how to use
the testers in your test suite.

- [CheckboxGroup](CheckboxGroup.html#test-utils)

- [ComboBox](ComboBox.html#test-utils)

- [Dialog](Dialog.html#test-utils)

- [ListView](ListView.html#test-utils)

- [ListBox](ListBox.html#test-utils)

- [MenuTrigger](MenuTrigger.html#test-utils)

- [RadioGroup](RadioGroup.html#test-utils)

- [Picker](Picker.html#test-utils)

- [TableView](TableView.html#test-utils)
Expand Down
38 changes: 0 additions & 38 deletions packages/react-aria-components/docs/CheckboxGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default Layout;
import docs from 'docs:react-aria-components';
import statelyDocs from 'docs:@react-stately/checkbox';
import typesDocs from 'docs:@react-types/shared/src/events.d.ts';
import checkboxgroupUtil from 'docs:@react-aria/test-utils/src/checkboxgroup.ts';
import {PropTable, HeaderInfo, TypeLink, PageDescription, StateTable, ContextTable, VersionBadge, ClassAPI} from '@react-spectrum/docs';
import styles from '@react-spectrum/docs/src/docs.css';
import packageData from 'react-aria-components/package.json';
Expand Down Expand Up @@ -610,40 +609,3 @@ function SelectionCount() {
### Hooks

If you need to customize things further, such as accessing internal state or customizing DOM structure, you can drop down to the lower level Hook-based API. See [useCheckboxGroup](useCheckboxGroup.html) for more details.

## Testing

### Test utils <VersionBadge version="beta" style={{marginLeft: 4, verticalAlign: 'bottom'}} />

`@react-aria/test-utils` offers common checkbox group interaction utilities which you may find helpful when writing tests. See [here](./testing.html#react-aria-test-utils) for more information on how to setup these utilities
in your tests. Below is the full definition of the checkbox group tester and a sample of how you could use it in your test suite.

```ts
// CheckboxGroup.test.ts
import {render} from '@testing-library/react';
import {User} from '@react-aria/test-utils';

let testUtilUser = new User({interactionType: 'mouse', advanceTimer: jest.advanceTimersByTime});
// ...

it('CheckboxGroup can select multiple checkboxes', async function () {
// Render your test component/app and initialize the checkbox group tester
let {getByTestId} = render(
<CheckboxGroup data-testid="test-checkboxgroup">
...
</CheckboxGroup>
);
let checkboxGroupTester = testUtilUser.createTester('CheckboxGroup', {root: getByTestId('test-checkboxgroup')});
expect(checkboxGroupTester.selectedCheckboxes).toHaveLength(0);

await checkboxGroupTester.toggleCheckbox({checkbox: 0});
expect(checkboxGroupTester.checkboxes[0]).toBeChecked();
expect(checkboxGroupTester.selectedCheckboxes).toHaveLength(1);

await checkboxGroupTester.toggleCheckbox({checkbox: 4});
expect(checkboxGroupTester.checkboxes[4]).toBeChecked();
expect(checkboxGroupTester.selectedCheckboxes).toHaveLength(2);
});
```

<ClassAPI links={checkboxgroupUtil.links} class={checkboxgroupUtil.exports.CheckboxGroupTester} />
40 changes: 0 additions & 40 deletions packages/react-aria-components/docs/Dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default Layout;

import docs from 'docs:react-aria-components';
import typesDocs from 'docs:@react-types/overlays';
import dialogUtil from 'docs:@react-aria/test-utils/src/dialog.ts';
import overlayStatelyDocs from 'docs:@react-stately/overlays';
import {PropTable, HeaderInfo, TypeLink, PageDescription, StateTable, ContextTable, VersionBadge, ClassAPI} from '@react-spectrum/docs';
import styles from '@react-spectrum/docs/src/docs.css';
Expand Down Expand Up @@ -350,42 +349,3 @@ function CloseButton() {
### Hooks

If you need to customize things further, such as accessing internal state or customizing DOM structure, you can drop down to the lower level Hook-based API. See [useDialog](useDialog.html) for more details.

## Testing

### Test utils <VersionBadge version="beta" style={{marginLeft: 4, verticalAlign: 'bottom'}} />

`@react-aria/test-utils` offers common dialog interaction utilities which you may find helpful when writing tests. See [here](./testing.html#react-aria-test-utils) for more information on how to setup these utilities
in your tests. Below is the full definition of the dialog tester and a sample of how you could use it in your test suite.

```ts
// Dialog.test.ts
import {render} from '@testing-library/react';
import {User} from '@react-aria/test-utils';

let testUtilUser = new User({interactionType: 'mouse', advanceTimer: jest.advanceTimersByTime});
// ...

it('Dialog can be opened and closed', async function () {
// Render your test component/app and initialize the dialog tester
let {getByTestId, getByRole} = render(
<DialogTrigger>
<Button>Trigger</Button>
<Modal>
<Dialog role="alertdialog" data-testid="test-dialog">
...
</Dialog>
</Modal>
</DialogTrigger>
);
let button = getByRole('button');
let dialogTester = testUtilUser.createTester('Dialog', {root: button, overlayType: 'modal'});
await dialogTester.open();
let dialog = dialogTester.dialog;
expect(dialog).toHaveAttribute('role', 'alertdialog');
await dialogTester.close();
expect(dialog).not.toBeInTheDocument();
});
```

<ClassAPI links={dialogUtil.links} class={dialogUtil.exports.DialogTester} />
38 changes: 0 additions & 38 deletions packages/react-aria-components/docs/RadioGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default Layout;
import docs from 'docs:react-aria-components';
import statelyDocs from 'docs:@react-stately/radio';
import typesDocs from 'docs:@react-types/shared/src/events.d.ts';
import radiogroupUtil from 'docs:@react-aria/test-utils/src/radiogroup.ts';
import {PropTable, HeaderInfo, TypeLink, PageDescription, StateTable, ContextTable, VersionBadge, ClassAPI} from '@react-spectrum/docs';
import styles from '@react-spectrum/docs/src/docs.css';
import packageData from 'react-aria-components/package.json';
Expand Down Expand Up @@ -631,40 +630,3 @@ RadioGroup provides a <TypeLink links={statelyDocs.links} type={statelyDocs.expo
### Hooks

If you need to customize things further, such as accessing internal state or customizing DOM structure, you can drop down to the lower level Hook-based API. See [useRadioGroup](useRadioGroup.html) for more details.

## Testing

### Test utils <VersionBadge version="beta" style={{marginLeft: 4, verticalAlign: 'bottom'}} />

`@react-aria/test-utils` offers common radio group interaction utilities which you may find helpful when writing tests. See [here](./testing.html#react-aria-test-utils) for more information on how to setup these utilities
in your tests. Below is the full definition of the radio group tester and a sample of how you could use it in your test suite.

```ts
// RadioGroup.test.ts
import {render} from '@testing-library/react';
import {User} from '@react-aria/test-utils';

let testUtilUser = new User({interactionType: 'mouse', advanceTimer: jest.advanceTimersByTime});
// ...

it('RadioGroup can switch the selected radio', async function () {
// Render your test component/app and initialize the radiogroup tester
let {getByRole} = render(
<RadioGroup>
...
</RadioGroup>
);

let radioGroupTester = testUtilUser.createTester('RadioGroup', {root: getByRole('radiogroup')});
let radios = radioGroupTester.radios;
expect(radioGroupTester.selectedRadio).toBeFalsy();

await radioGroupTester.triggerRadio({radio: radios[0]});
expect(radioGroupTester.selectedRadio).toBe(radios[0]);

await radioGroupTester.triggerRadio({radio: radios[1]});
expect(radioGroupTester.selectedRadio).toBe(radios[1]);
});
```

<ClassAPI links={radiogroupUtil.links} class={radiogroupUtil.exports.RadioGroupTester} />
Loading
Loading