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

Internal: Revert "Internal: Fix error in React 19 with fetchpriority (#3976)" #3982

Merged
merged 1 commit into from
Feb 6, 2025
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
6 changes: 0 additions & 6 deletions packages/gestalt/src/Avatar.jsdom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ import { fireEvent, render, screen } from '@testing-library/react';
import Avatar from './Avatar';

test('Avatar handles Image error by rendering the default avatar', () => {
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
render(<Avatar name="Name" src="example.com" />);
// This error is expected because of a change in React 19 that now only accepts fetchPriority in camel case while in react 18 it only accepts it in lowercase
expect(error.mock.calls[0]![0]).toEqual(
expect.stringContaining('Warning: React does not recognize the `%s` prop on a DOM element'),
);
expect(error.mock.calls[0]![1]).toEqual(expect.stringContaining('fetchPriority'));
fireEvent.error(screen.getByAltText('Name'));

expect(screen.getByText('N')).toBeTruthy();
Expand Down
6 changes: 0 additions & 6 deletions packages/gestalt/src/AvatarGroup.jsdom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ describe('AvatarGroup', () => {
);

it('renders xs display-only AvatarGroup with image', () => {
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
const { baseElement } = renderCmp({
collaborators: [
{
Expand All @@ -64,11 +63,6 @@ describe('AvatarGroup', () => {
],
size: 'xs',
});
// This error is expected because of a change in React 19 that now only accepts fetchPriority in camel case while in react 18 it only accepts it in lowercase
expect(error.mock.calls[0]![0]).toEqual(
expect.stringContaining('Warning: React does not recognize the `%s` prop on a DOM element'),
);
expect(error.mock.calls[0]![1]).toEqual(expect.stringContaining('fetchPriority'));
expect(baseElement).toMatchSnapshot();
});

Expand Down
6 changes: 0 additions & 6 deletions packages/gestalt/src/DropdownItem.jsdom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('Dropdown.Item', () => {
});

test('adds avatar', () => {
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
render(
<Dropdown.Item
avatar={{
Expand All @@ -56,11 +55,6 @@ describe('Dropdown.Item', () => {
option={{ value: 'item 4', label: 'Item 4' }}
/>,
);
// This error is expected because of a change in React 19 that now only accepts fetchPriority in camel case while in react 18 it only accepts it in lowercase
expect(error.mock.calls[0]![0]).toEqual(
expect.stringContaining('Warning: React does not recognize the `%s` prop on a DOM element'),
);
expect(error.mock.calls[0]![1]).toEqual(expect.stringContaining('fetchPriority'));
expect(screen.getByAltText('Ayesha avatar')).toBeInTheDocument();
});

Expand Down
6 changes: 0 additions & 6 deletions packages/gestalt/src/DropdownLink.jsdom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('Dropdown.Link', () => {
});

test('adds avatar', () => {
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
render(
<Dropdown.Link
avatar={{
Expand All @@ -79,11 +78,6 @@ describe('Dropdown.Link', () => {
option={{ value: 'item 4', label: 'Item 4' }}
/>,
);
// This error is expected because of a change in React 19 that now only accepts fetchPriority in camel case while in react 18 it only accepts it in lowercase
expect(error.mock.calls[0]![0]).toEqual(
expect.stringContaining('Warning: React does not recognize the `%s` prop on a DOM element'),
);
expect(error.mock.calls[0]![1]).toEqual(expect.stringContaining('fetchPriority'));
expect(screen.getByAltText('Ayesha avatar')).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion packages/gestalt/src/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default class Image extends PureComponent<Props> {
className={imageStyles}
crossOrigin={crossOrigin}
decoding={decoding}
fetchPriority={fetchPriority}
fetchpriority={fetchPriority}
// @ts-expect-error - TS2322 - Type '"auto" | "lazy" | "eager" | undefined' is not assignable to type '"lazy" | "eager" | undefined'.
loading={loading}
onError={this.handleError}
Expand Down
14 changes: 7 additions & 7 deletions packages/gestalt/src/__snapshots__/Avatar.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ exports[`Avatar renders the checkmark on verified default 1`] = `
<img
alt="Strava"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -221,7 +221,7 @@ exports[`Avatar renders the correct size - lg 1`] = `
<img
alt="Strava"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -271,7 +271,7 @@ exports[`Avatar renders the correct size - md 1`] = `
<img
alt="Strava"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -321,7 +321,7 @@ exports[`Avatar renders the correct size - sm 1`] = `
<img
alt="Strava"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -371,7 +371,7 @@ exports[`Avatar renders the correct size - xl 1`] = `
<img
alt="Strava"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -421,7 +421,7 @@ exports[`Avatar renders the correct size - xs 1`] = `
<img
alt="Strava"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -471,7 +471,7 @@ exports[`Avatar renders the correct src 1`] = `
<img
alt="Strava"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Array [
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -170,7 +170,7 @@ Array [
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -295,7 +295,7 @@ Array [
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -410,7 +410,7 @@ Array [
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ exports[`Checkbox with an image 1`] = `
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down
16 changes: 8 additions & 8 deletions packages/gestalt/src/__snapshots__/Image.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`Image matches snapshot 1`] = `
<img
alt="foo"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand All @@ -36,7 +36,7 @@ exports[`Image with crossorigin specified matches snapshot 1`] = `
alt="foo"
className="img"
crossOrigin="anonymous"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand All @@ -59,7 +59,7 @@ exports[`Image with decoding specified matches snapshot 1`] = `
alt="foo"
className="img"
decoding="sync"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand All @@ -81,7 +81,7 @@ exports[`Image with fetchPriority specified matches snapshot 1`] = `
<img
alt="foo"
className="img"
fetchPriority="high"
fetchpriority="high"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand All @@ -104,7 +104,7 @@ exports[`Image with fit: contain and role matches snapshot 1`] = `
<img
alt="foo"
className="img scaledImg"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -138,7 +138,7 @@ exports[`Image with fit: contain matches snapshot 1`] = `
<img
alt="foo"
className="img scaledImg"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -171,7 +171,7 @@ exports[`Image with fit: cover matches snapshot 1`] = `
<img
alt="foo"
className="img scaledImg"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -203,7 +203,7 @@ exports[`Image with overlay matches snapshot 1`] = `
<img
alt="foo"
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ exports[`RadioButton with image 1`] = `
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down
4 changes: 2 additions & 2 deletions packages/gestalt/src/__snapshots__/Toast.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ exports[`<Toast /> Text + Image + Button 1`] = `
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -312,7 +312,7 @@ exports[`<Toast /> Text + Image 1`] = `
<img
alt=""
className="img"
fetchPriority="auto"
fetchpriority="auto"
loading="auto"
onError={[Function]}
onLoad={[Function]}
Expand Down
Loading