Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix rest of tests from provider requirement #7418

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, fireEvent, pointerMap, render, waitFor, within} from '@react-spectrum/test-utils-internal';
import {act, fireEvent, pointerMap, renderv3 as render, waitFor, within} from '@react-spectrum/test-utils-internal';
import {DataTransfer, DragEvent} from './mocks';
import {Draggable} from './examples';
import {DroppableGridExample} from '../stories/DroppableGrid';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/landmark/test/useLandmark.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, fireEvent, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, fireEvent, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {ActionGroup, Item} from '@react-spectrum/actiongroup';
import {Button} from '@react-spectrum/button';
import {Cell, Column, Row, TableBody, TableHeader, TableView} from '@react-spectrum/table';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/accordion/test/Accordion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import {Accordion, Disclosure, DisclosurePanel, DisclosureTitle} from '../src';
import {act, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {Provider} from '@react-spectrum/provider';
import React from 'react';
import {theme} from '@react-spectrum/theme-default';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actionbar/test/ActionBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


jest.mock('@react-aria/live-announcer');
import {act, fireEvent, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, fireEvent, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {announce} from '@react-aria/live-announcer';
import {Example} from '../stories/Example';
import {getFocusableTreeWalker} from '@react-aria/focus';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/avatar/test/Avatar.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Avatar} from '../';
import React from 'react';
import {render, screen} from '@react-spectrum/test-utils-internal';
import {renderv3 as render, screen} from '@react-spectrum/test-utils-internal';

let isOldReact = parseInt(React.version, 10) < 18;

Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/badge/test/Badge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import {Badge} from '../';
import CheckmarkCircle from '@spectrum-icons/workflow/CheckmarkCircle';
import React from 'react';
import {render} from '@react-spectrum/test-utils-internal';
import {renderv3 as render} from '@react-spectrum/test-utils-internal';
import {Text} from '@react-spectrum/text';
import {within} from '@testing-library/dom';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import {BreadcrumbItem} from '../src/BreadcrumbItem';
import {pointerMap, render} from '@react-spectrum/test-utils-internal';
import {pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import React from 'react';
import userEvent from '@testing-library/user-event';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {Breadcrumbs} from '../';
import {Item} from '@react-stately/collections';
import {Provider} from '@react-spectrum/provider';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/button/test/ActionButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import {ActionButton} from '../';
import {pointerMap, render} from '@react-spectrum/test-utils-internal';
import {pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import React from 'react';
import userEvent from '@testing-library/user-event';

Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/button/test/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, pointerMap, render} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import {ActionButton, Button, ClearButton, LogicButton} from '../';
import {Checkbox, defaultTheme} from '@adobe/react-spectrum';
import {Form} from '@react-spectrum/form';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/button/test/ClearButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, pointerMap, render} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import {ClearButton} from '../';
import React from 'react';
import userEvent from '@testing-library/user-event';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/button/test/ToggleButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {pointerMap, render} from '@react-spectrum/test-utils-internal';
import {pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import React from 'react';
import {ToggleButton} from '../';
import userEvent from '@testing-library/user-event';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {Button} from '@react-spectrum/button';
import {ButtonGroup} from '../';
import {Provider} from '@react-spectrum/provider';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/calendar/test/Calendar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jest.mock('@react-aria/live-announcer');
import {announce} from '@react-aria/live-announcer';
import {Calendar} from '../';
import {CalendarDate, isWeekend} from '@internationalized/date';
import {pointerMap, render} from '@react-spectrum/test-utils-internal';
import {pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import React from 'react';
import {useLocale} from '@react-aria/i18n';
import userEvent from '@testing-library/user-event';
Expand Down
10 changes: 4 additions & 6 deletions packages/@react-spectrum/calendar/test/CalendarBase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, fireEvent, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, fireEvent, render as noProviderRender, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {Calendar, RangeCalendar} from '../';
import {CalendarDate, GregorianCalendar, today} from '@internationalized/date';
import {Provider} from '@react-spectrum/provider';
Expand Down Expand Up @@ -268,10 +268,8 @@ describe('CalendarBase', () => {
${'v3 RangeCalendar'} | ${RangeCalendar}
`('$Name should handle minimum dates in a calendar system', ({Calendar}) => {
let {getByRole, getAllByRole} = render(
<Provider theme={theme} locale="en-US-u-ca-japanese">
<Calendar defaultFocusedValue={new CalendarDate(1868, 9, 12)} />
</Provider>
);
<Calendar defaultFocusedValue={new CalendarDate(1868, 9, 12)} />
, undefined, {locale: 'en-US-u-ca-japanese'});

let grid = getByRole('grid');
let headers = within(grid).getAllByRole('columnheader', {hidden: true});
Expand Down Expand Up @@ -752,7 +750,7 @@ describe('CalendarBase', () => {
${'v3 RangeCalendar'} | ${RangeCalendar} | ${{defaultValue: {start: new CalendarDate(2019, 6, 5), end: new CalendarDate(2019, 6, 10)}}}
`('$Name should mirror arrow key movement in an RTL locale', async ({Calendar, props}) => {
// LTR
let {getByRole, getAllByRole, rerender} = render(
let {getByRole, getAllByRole, rerender} = noProviderRender(
<Provider theme={theme} locale="en-US">
<Calendar {...props} autoFocus />
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

jest.mock('@react-aria/live-announcer');
import {act, fireEvent, installPointerEvent, pointerMap, render} from '@react-spectrum/test-utils-internal';
import {act, fireEvent, installPointerEvent, pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import {announce} from '@react-aria/live-announcer';
import {CalendarDate, isWeekend} from '@internationalized/date';
import {RangeCalendar} from '../';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/card/test/Card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import {Card} from '../src';
import {composeStories} from '@storybook/react';
import * as defaultStories from '../chromatic/Card.stories';
import {pointerMap, render} from '@react-spectrum/test-utils-internal';
import {pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import * as quietStories from '../chromatic/QuietCard.stories';
import React from 'react';
import userEvent from '@testing-library/user-event';
Expand Down
86 changes: 35 additions & 51 deletions packages/@react-spectrum/card/test/CardView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@
*/

jest.mock('@react-aria/utils/src/scrollIntoView');
import {act, fireEvent, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, fireEvent, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {Card, CardView, GalleryLayout, GridLayout, WaterfallLayout} from '../';
import {composeStories} from '@storybook/react';
import {Content} from '@react-spectrum/view';
import {Heading, Text} from '@react-spectrum/text';
import {Image} from '@react-spectrum/image';
import {Provider} from '@react-spectrum/provider';
import React, {useMemo} from 'react';
import scaleMedium from '@adobe/spectrum-css-temp/vars/spectrum-medium-unique.css';
import {scrollIntoView} from '@react-aria/utils';
import * as stories from '../stories/GridCardView.stories';
import themeLight from '@adobe/spectrum-css-temp/vars/spectrum-light-unique.css';
import {useCollator} from '@react-aria/i18n';
import userEvent from '@testing-library/user-event';

Expand All @@ -31,11 +28,6 @@ let isOldReact = parseInt(React.version, 10) < 18;
let {falsyItems} = stories;
let {FalsyIds} = composeStories(stories);

let theme = {
light: themeLight,
medium: scaleMedium
};

let defaultItems = [
{width: 1001, height: 381, src: 'https://i.imgur.com/Z7AzH2c.jpg', title: 'Title 1'},
{width: 640, height: 640, src: 'https://i.imgur.com/DhygPot.jpg', title: 'Title 2'},
Expand Down Expand Up @@ -77,33 +69,30 @@ function StaticCardView(props) {
let {
layout = gridLayout,
selectionMode = 'multiple',
locale = 'en-US',
...otherProps
} = props;

return (
<Provider theme={theme} locale={locale}>
<CardView onSelectionChange={onSelectionChange} {...otherProps} selectionMode={selectionMode} layout={layout} width="100%" height="100%" aria-label="Test CardView">
<Card width={1001} height={381} textValue="Title 1">
<Image src="https://i.imgur.com/Z7AzH2c.jpg" />
<Heading>Title 1</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
<Card width={640} height={640} textValue="Title 1">
<Image src="https://i.imgur.com/DhygPot.jpg" />
<Heading>Title 1</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
<Card width={182} height={1009} textValue="Title 1">
<Image src="https://i.imgur.com/L7RTlvI.png" />
<Heading>Title 1</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
</CardView>
</Provider>
<CardView onSelectionChange={onSelectionChange} {...otherProps} selectionMode={selectionMode} layout={layout} width="100%" height="100%" aria-label="Test CardView">
<Card width={1001} height={381} textValue="Title 1">
<Image src="https://i.imgur.com/Z7AzH2c.jpg" />
<Heading>Title 1</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
<Card width={640} height={640} textValue="Title 1">
<Image src="https://i.imgur.com/DhygPot.jpg" />
<Heading>Title 1</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
<Card width={182} height={1009} textValue="Title 1">
<Image src="https://i.imgur.com/L7RTlvI.png" />
<Heading>Title 1</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
</CardView>
);
}

Expand All @@ -115,23 +104,20 @@ function DynamicCardView(props) {
layout = gridLayout,
selectionMode = 'multiple',
items = defaultItems,
locale = 'en-US',
...otherProps
} = props;

return (
<Provider theme={theme} locale={locale}>
<CardView onSelectionChange={onSelectionChange} {...otherProps} selectionMode={selectionMode} items={items} layout={layout} width="100%" height="100%" aria-label="Test CardView">
{(item) => (
<Card key={item.title} textValue={item.title} width={item.width} height={item.height}>
<Image src={item.src} />
<Heading>{item.title}</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
<CardView onSelectionChange={onSelectionChange} {...otherProps} selectionMode={selectionMode} items={items} layout={layout} width="100%" height="100%" aria-label="Test CardView">
{(item) => (
<Card key={item.title} textValue={item.title} width={item.width} height={item.height}>
<Image src={item.src} />
<Heading>{item.title}</Heading>
<Text slot="detail">PNG</Text>
<Content>Description</Content>
</Card>
)}
</CardView>
</Provider>
</CardView>
);
}

Expand Down Expand Up @@ -225,9 +211,7 @@ describe('CardView', function () {
${'Waterfall layout'} | ${WaterfallLayout}
`('$Name CardView supports falsy ids', function ({layout}) {
let tree = render(
<Provider theme={theme} locale="en-US">
<FalsyIds items={falsyItems} aria-label="test falsy" layout={layout} />
</Provider>
<FalsyIds items={falsyItems} aria-label="test falsy" layout={layout} />
);
act(() => {
jest.runAllTimers();
Expand Down Expand Up @@ -394,7 +378,7 @@ describe('CardView', function () {
${'Grid layout'} | ${GridLayout}
${'Gallery layout'} | ${GalleryLayout}
`('$Name CardView should move focus via Arrow Left (RTL)', async function ({Name, layout}) {
let tree = render(<DynamicCardView locale="ar-AE" layout={layout} />);
let tree = render(<DynamicCardView layout={layout} />, undefined, {locale: 'ar-AE'});
act(() => {
jest.runAllTimers();
});
Expand Down Expand Up @@ -460,7 +444,7 @@ describe('CardView', function () {
${'Grid layout'} | ${GridLayout}
${'Gallery layout'} | ${GalleryLayout}
`('$Name CardView should move focus via Arrow Right (RTL)', async function ({Name, layout}) {
let tree = render(<DynamicCardView locale="ar-AE" layout={layout} />);
let tree = render(<DynamicCardView layout={layout} />, undefined, {locale: 'ar-AE'});
act(() => {
jest.runAllTimers();
});
Expand Down Expand Up @@ -842,7 +826,7 @@ describe('CardView', function () {
});

it('should move focus via Arrow Left (RTL)', async function () {
let tree = render(<DynamicCardView locale="ar-AE" layout={WaterfallLayout} />);
let tree = render(<DynamicCardView layout={WaterfallLayout} />, undefined, {locale: 'ar-AE'});
act(() => {
jest.runAllTimers();
});
Expand Down Expand Up @@ -899,7 +883,7 @@ describe('CardView', function () {
});

it('should move focus via Arrow Right (RTL)', async function () {
let tree = render(<DynamicCardView locale="ar-AE" layout={WaterfallLayout} />);
let tree = render(<DynamicCardView layout={WaterfallLayout} />, undefined, {locale: 'ar-AE'});
act(() => {
jest.runAllTimers();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/checkbox/test/Checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {act} from 'react-dom/test-utils';
import {Button} from '@react-spectrum/button';
import {Checkbox} from '../';
import {Form} from '@react-spectrum/form';
import {pointerMap, render} from '@react-spectrum/test-utils-internal';
import {pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import {Provider} from '@react-spectrum/provider';
import React from 'react';
import {theme} from '@react-spectrum/theme-default';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import {Button} from '@react-spectrum/button';
import {Checkbox, CheckboxGroup} from '../';
import {Form} from '@react-spectrum/form';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/color/test/ColorField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, fireEvent, pointerMap, render} from '@react-spectrum/test-utils-internal';
import {act, fireEvent, pointerMap, renderv3 as render} from '@react-spectrum/test-utils-internal';
import {Button} from '@react-spectrum/button';
import {chain} from '@react-aria/utils';
import {ColorField} from '../';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import {ColorSwatch, ColorSwatchPicker, parseColor} from '../src';
import {pointerMap, render, within} from '@react-spectrum/test-utils-internal';
import {pointerMap, renderv3 as render, within} from '@react-spectrum/test-utils-internal';
import React from 'react';
import userEvent from '@testing-library/user-event';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, pointerMap, render, simulateDesktop} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render, simulateDesktop} from '@react-spectrum/test-utils-internal';
import {Content, Footer, Header} from '@react-spectrum/view';
import {ContextualHelp} from '../';
import {Link} from '@react-spectrum/link';
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/datepicker/test/DateField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {act, pointerMap, render as render_, within} from '@react-spectrum/test-utils-internal';
import {act, pointerMap, renderv3 as render_, within} from '@react-spectrum/test-utils-internal';
import {Button} from '@react-spectrum/button';
import {CalendarDate, CalendarDateTime, ZonedDateTime} from '@internationalized/date';
import {DateField} from '../';
Expand Down
Loading