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

Fix react canary tests #6115

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix more tests
  • Loading branch information
snowystinger committed Mar 27, 2024
commit d73d49235976bd0d4625083959109c343c402b5a
17 changes: 8 additions & 9 deletions packages/@react-aria/interactions/test/useFocusVisible.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {addWindowFocusTracking, useFocusVisible, useFocusVisibleListener} from '
import {hasSetupGlobalListeners} from '../src/useFocusVisible';
import {mergeProps} from '@react-aria/utils';
import React from 'react';
import {render as ReactDOMRender} from 'react-dom';
import {useButton} from '@react-aria/button';
import {useFocusRing} from '@react-aria/focus';

Expand Down Expand Up @@ -120,7 +119,7 @@ describe('useFocusVisible', function () {
});

it('sets up focus listener in a different window', async function () {
ReactDOMRender(<Example id="iframe-example" />, iframeRoot);
render(<Example id="iframe-example" />, {container: iframeRoot});
await waitFor(() => {
expect(document.querySelector('iframe').contentWindow.document.body.querySelector('div[id="iframe-example"]')).toBeTruthy();
});
Expand Down Expand Up @@ -184,7 +183,7 @@ describe('useFocusVisible', function () {
});

it('removes the window object from the hasSetupGlobalListeners object on beforeunload', async function () {
ReactDOMRender(<Example id="iframe-example" />, iframeRoot);
render(<Example id="iframe-example" />, {container: iframeRoot});
expect(hasSetupGlobalListeners.size).toBe(1);
expect(hasSetupGlobalListeners.get(window)).toBeTruthy();
expect(hasSetupGlobalListeners.get(iframe.contentWindow)).toBeFalsy();
Expand All @@ -203,7 +202,7 @@ describe('useFocusVisible', function () {
});

it('removes the window object from the hasSetupGlobalListeners object if we preemptively tear down', async function () {
ReactDOMRender(<Example id="iframe-example" />, iframeRoot);
render(<Example id="iframe-example" />, {container: iframeRoot});
expect(hasSetupGlobalListeners.size).toBe(1);
expect(hasSetupGlobalListeners.get(window)).toBeTruthy();
expect(hasSetupGlobalListeners.get(iframe.contentWindow)).toBeFalsy();
Expand All @@ -221,7 +220,7 @@ describe('useFocusVisible', function () {
});

it('returns positive isFocusVisible result after toggling browser tabs after keyboard navigation', async function () {
ReactDOMRender(<Example id="iframe-example" />, iframeRoot);
render(<Example id="iframe-example" />, {container: iframeRoot});
addWindowFocusTracking(iframeRoot);

// Fire focus in iframe
Expand All @@ -241,7 +240,7 @@ describe('useFocusVisible', function () {
});

it('returns negative isFocusVisible result after toggling browser tabs without prior keyboard navigation', async function () {
ReactDOMRender(<Example id="iframe-example" />, iframeRoot);
render(<Example id="iframe-example" />, {container: iframeRoot});
addWindowFocusTracking(iframeRoot);

// Fire focus in iframe
Expand All @@ -259,7 +258,7 @@ describe('useFocusVisible', function () {
});

it('returns positive isFocusVisible result after toggling browser window after keyboard navigation', async function () {
ReactDOMRender(<Example id="iframe-example" />, iframeRoot);
render(<Example id="iframe-example" />, {container: iframeRoot});
addWindowFocusTracking(iframeRoot);

// Fire focus in iframe
Expand All @@ -278,7 +277,7 @@ describe('useFocusVisible', function () {
});

it('returns negative isFocusVisible result after toggling browser window without prior keyboard navigation', async function () {
ReactDOMRender(<Example id="iframe-example" />, iframeRoot);
render(<Example id="iframe-example" />, {container: iframeRoot});
addWindowFocusTracking(iframeRoot);

// Fire focus in iframe
Expand All @@ -297,7 +296,7 @@ describe('useFocusVisible', function () {
});

it('correctly shifts focus to the iframe when the iframe is focused', async function () {
ReactDOMRender(<ButtonExample id="iframe-example" />, iframeRoot);
render(<ButtonExample id="iframe-example" />, {container: iframeRoot});
addWindowFocusTracking(iframeRoot);

// Fire focus in iframe
Expand Down
1 change: 1 addition & 0 deletions scripts/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if (!process.env.LISTENING_TO_UNHANDLED_REJECTION) {
}
const ERROR_PATTERNS_WE_SHOULD_FIX_BUT_ALLOW = [
'ReactDOM.render is no longer supported in React 18',
'ReactDOM.render has not been supported since React 18',
'`ReactDOMTestUtils.act` is deprecated in favor of `React.act`'
];

Expand Down