Skip to content

Commit

Permalink
Merge pull request #20653 from Yoast/feature/upgrade-react-and-tests
Browse files Browse the repository at this point in the history
Feature/upgrade react and tests
  • Loading branch information
vraja-pro authored Dec 13, 2023
2 parents a290368 + d3fb4b3 commit feee6b2
Show file tree
Hide file tree
Showing 73 changed files with 3,822 additions and 1,907 deletions.
15 changes: 1 addition & 14 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ parserOptions:

settings:
react:
version: "16.8"
version: "18.2"

rules:
no-prototype-builtins: 0
Expand Down Expand Up @@ -36,19 +36,6 @@ overrides:
react/default-props-match-prop-types: 1
react/no-unused-prop-types: 1
require-jsdoc: 1
- files:
- "packages/replacement-variable-editor/**/*.js"
rules:
react/jsx-no-bind: 1
react/require-default-props: 1
- files:
- "packages/search-metadata-previews/**/*.js"
rules:
react/jsx-no-bind: 1
react/no-unused-state: 1
react/no-access-state-in-setstate: 1
react/require-default-props: 1
react/default-props-match-prop-types: 1
- files:
- "packages/yoastseo/**/*.js"
settings:
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"prestart": "grunt build:css && grunt copy:js-dependencies",
"start": "wp-scripts start --config config/webpack/webpack.config.js"
},
"dependencies": {},
"dependencies": {
"@draft-js-plugins/mention": "^5.0.0",
"draft-js": "^0.11.7"
},
"devDependencies": {
"@babel/core": "^7.18.5",
"@slack/webhook": "^5.0.2",
Expand All @@ -56,9 +59,6 @@
"core-js": "^2.6.12",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.6.1",
"eslint": "^7.32.0",
"eslint-config-yoast": "^6.0.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
Expand All @@ -74,9 +74,6 @@
"node-fetch": "^2.6.1",
"postcss": "^8.4.14",
"postcss-cli": "^9.1.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-test-renderer": "^16.14.0",
"readline-sync": "^1.4.9",
"shusher": "^0.1.1",
"tmp": "^0.1.0",
Expand Down
10 changes: 4 additions & 6 deletions packages/analysis-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"@yoast/style-guide": "^0.13.0",
"lodash": "^4.17.11",
"prop-types": "^15.6.0",
"styled-components": "^5.3.6"
"styled-components": "^5.3.6",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/core": "^7.17.10",
Expand All @@ -39,11 +41,7 @@
"eslint-plugin-react": "^7.29.4",
"jest": "^27.5.1",
"jest-styled-components": "^7.0.8",
"react-test-renderer": "^16.14.0"
},
"peerDependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0"
"react-test-renderer": "^18.2.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 0 additions & 4 deletions packages/components/jest/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
import "raf/polyfill";
import "jest-styled-components";
import Enzyme from "enzyme";
import EnzymeAdapter from "enzyme-adapter-react-16";

Enzyme.configure( { adapter: new EnzymeAdapter() } );
10 changes: 3 additions & 7 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"interpolate-components": "^1.1.1",
"lodash": "^4.17.11",
"prop-types": "^15.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-modal": "^3.8.1",
"react-select": "^3.1.0",
"react-tabs": "^2.3.0",
Expand All @@ -44,15 +46,9 @@
"devDependencies": {
"@yoast/browserslist-config": "^1.2.2",
"browserslist": "^4.7.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"jest-styled-components": "^7.0.3",
"raf": "^3.4.0",
"react-test-renderer": "^16.14.0"
},
"peerDependencies": {
"react": "^16.14.0",
"react-dom": "^16.14.0"
"react-test-renderer": "^18.2.0"
},
"publishConfig": {
"access": "public"
Expand Down
70 changes: 0 additions & 70 deletions packages/components/tests/ScreenReaderShortcutTest.js

This file was deleted.

12 changes: 8 additions & 4 deletions packages/components/tests/ScreenReaderTextTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ describe( "ScreenReaderText", () => {
renderer.render( <ScreenReaderText><div /></ScreenReaderText> );

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type: Invalid prop `children` of type `object` supplied to `ScreenReaderText`, expected `string`." );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] )
.toBe( "Invalid prop `children` of type `object` supplied to `ScreenReaderText`, expected `string`." );
} );

it( "generates a warning when no children are passed in.", () => {
console.error = jest.fn();
renderer.render( <ScreenReaderText /> );

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type" );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] )
.toBe( "The prop `children` is marked as required in `ScreenReaderText`, but its value is `undefined`." );
} );
} );
77 changes: 0 additions & 77 deletions packages/components/tests/YoastModalTest.js

This file was deleted.

4 changes: 0 additions & 4 deletions packages/components/tests/__snapshots__/WordListTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ exports[`WordList renders correctly without items 1`] = `
Wordlist
</strong>
</p>
<ol
className="__list"
/>
</div>
`;

Expand All @@ -26,7 +24,6 @@ exports[`WordList renders wordlist as list items 1`] = `
Wordlist
</strong>
</p>
<ol
className="__list"
>
Expand All @@ -46,6 +43,5 @@ exports[`WordList renders wordlist as list items 1`] = `
word3
</li>
</ol>
</div>
`;
5 changes: 3 additions & 2 deletions packages/components/tests/button/ButtonsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ describe( "Button", () => {
);

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type: Invalid prop `variant` of value `[object Object]` supplied to `Button`" );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] ).toContain( "Invalid prop `variant` of value `[object Object]` supplied to `Button`" );
} );
} );

Expand Down
10 changes: 6 additions & 4 deletions packages/components/tests/inputTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ describe( "Input", () => {
renderer.render( <Input type="invalidType" /> );

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type: Invalid prop `type` of value `invalidType` supplied to `Input`" );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] ).toContain( "Invalid prop `type` of value `invalidType` supplied to `Input`" );
} );

it( "generates an input based on the defaults and additional, optional attributes", () => {
Expand Down Expand Up @@ -72,7 +73,8 @@ describe( "Input", () => {
renderer.render( <Input name="textInput" onChange={ 0 } /> );

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type: Invalid prop `onChange` of type `number` supplied to `Input`, expected `function`." );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] ).toBe( "Invalid prop `onChange` of type `number` supplied to `Input`, expected `function`." );
} );
} );
5 changes: 3 additions & 2 deletions packages/components/tests/inputs/TextAreaTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ describe( "TextArea", () => {
);

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type: Invalid prop `id` of type `boolean` supplied to `TextArea`, expected `string`." );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] ).toBe( "Invalid prop `id` of type `boolean` supplied to `TextArea`, expected `string`." );
} );
} );
11 changes: 7 additions & 4 deletions packages/components/tests/inputs/TextInputTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ describe( "TextInput", () => {
renderer.render( <TextInput label="hey" type="invalidType" /> );

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type: Invalid prop `type` of value `invalidType` supplied to `TextInput`" );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] ).toContain( "Invalid prop `type` of value `invalidType` supplied to `TextInput`" );
} );

it( "generates an input based on the defaults and additional, optional attributes", () => {
Expand Down Expand Up @@ -88,7 +89,9 @@ describe( "TextInput", () => {
renderer.render( <TextInput label="hi" name="textInput" onChange={ 0 } /> );

expect( console.error ).toBeCalled();
expect( console.error.mock.calls[ 0 ][ 0 ] )
.toContain( "Warning: Failed prop type: Invalid prop `onChange` of type `number` supplied to `TextInput`, expected `function`." );
expect( console.error.mock.calls[ 0 ][ 0 ] ).toBe( "Warning: Failed %s type: %s%s" );
expect( console.error.mock.calls[ 0 ][ 1 ] ).toBe( "prop" );
expect( console.error.mock.calls[ 0 ][ 2 ] )
.toBe( "Invalid prop `onChange` of type `number` supplied to `TextInput`, expected `function`." );
} );
} );
Loading

0 comments on commit feee6b2

Please sign in to comment.