Skip to content

Commit

Permalink
[core] Allow lockflile changes when building with React next (mui#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored Mar 25, 2024
1 parent 542f282 commit 90ea911
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 24 deletions.
47 changes: 38 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,16 @@ commands:
type: boolean
default: false
description: 'Set to true if you intend to any browser (for example with playwright).'
react-version:
description: The version of react to be used
type: string
default: stable

steps:
- run:
name: Resolve React version
command: |
echo 'Using React version: << parameters.react-version >>'
node scripts/useReactVersion.mjs
# log a patch for maintainers who want to check out this change
git --no-pager diff HEAD
Expand All @@ -98,9 +103,23 @@ commands:
command: |
node --version
pnpm --version
- run:
name: Install js dependencies
command: pnpm install
- when:
condition:
equal: [<< parameters.react-version >>, stable]
steps:
- run:
name: Install JS dependencies
command: pnpm install
- unless:
condition:
equal: [<< parameters.react-version >>, stable]
steps:
- run:
name: Install JS dependencies (without frozen lockfile)
command: pnpm install --no-frozen-lockfile
- run:
name: Restore clean working copy
command: git restore .
- when:
condition: << parameters.browsers >>
steps:
Expand All @@ -120,7 +139,8 @@ jobs:
<<: *default-job
steps:
- checkout
- install_js
- install_js:
react-version: << parameters.react-version >>
- when:
# Install can be "dirty" when running with non-default versions of React
condition:
Expand All @@ -142,7 +162,8 @@ jobs:
<<: *default-job
steps:
- checkout
- install_js
- install_js:
react-version: << parameters.react-version >>
- run:
name: Tests fake browser
command: pnpm test:coverage:ci
Expand All @@ -163,7 +184,8 @@ jobs:
<<: *default-job
steps:
- checkout
- install_js
- install_js:
react-version: << parameters.react-version >>
- run:
name: Eslint
command: pnpm eslint:ci
Expand All @@ -180,7 +202,8 @@ jobs:
<<: *default-job
steps:
- checkout
- install_js
- install_js:
react-version: << parameters.react-version >>
- run:
name: '`pnpm prettier` changes committed?'
command: pnpm prettier --check
Expand Down Expand Up @@ -217,7 +240,8 @@ jobs:
resource_class: 'medium+'
steps:
- checkout
- install_js
- install_js:
react-version: << parameters.react-version >>
- run:
name: Transpile TypeScript demos
command: pnpm docs:typescript:formatted
Expand Down Expand Up @@ -249,7 +273,8 @@ jobs:
pnpm add typescript@next -d -w
# log a patch for maintainers who want to check out this change
git --no-pager diff HEAD
- install_js
- install_js:
react-version: << parameters.react-version >>
- run:
name: Tests TypeScript definitions
command: |
Expand Down Expand Up @@ -293,6 +318,7 @@ jobs:
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
browsers: true
- run:
name: Tests real browsers
Expand Down Expand Up @@ -323,6 +349,7 @@ jobs:
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
browsers: true
- run:
name: Tests real browsers
Expand Down Expand Up @@ -350,6 +377,7 @@ jobs:
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
browsers: true
- run:
name: Run visual regression tests
Expand All @@ -366,6 +394,7 @@ jobs:
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
browsers: true
- run: pnpm benchmark:browser
- store_artifacts:
Expand Down
63 changes: 48 additions & 15 deletions packages/mui-base/src/useAutocomplete/useAutocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ describe('useAutocomplete', () => {
{groupedOptions.length > 0 ? (
<ul {...getListboxProps()}>
{groupedOptions.map((option, index) => {
return <li {...getOptionProps({ option, index })}>{option}</li>;
const { key, ...other } = getOptionProps({ option, index });
return (
<li key={key} {...other}>
{option}
</li>
);
})}
</ul>
) : null}
Expand Down Expand Up @@ -258,7 +263,12 @@ describe('useAutocomplete', () => {
{groupedOptions.length > 0 ? (
<ul {...getListboxProps()}>
{groupedOptions.map((option, index) => {
return <li {...getOptionProps({ option, index })}>{option}</li>;
const { key, ...other } = getOptionProps({ option, index });
return (
<li key={key} {...other}>
{option}
</li>
);
})}
</ul>
) : null}
Expand All @@ -267,28 +277,52 @@ describe('useAutocomplete', () => {
}

const node16ErrorMessage =
"Error: Uncaught [TypeError: Cannot read properties of null (reading 'removeAttribute')]";
const olderNodeErrorMessage =
"Error: Uncaught [TypeError: Cannot read property 'removeAttribute' of null]";
"TypeError: Cannot read properties of null (reading 'removeAttribute')";
const olderNodeErrorMessage = "TypeError: Cannot read property 'removeAttribute' of null";

const nodeVersion = Number(process.versions.node.split('.')[0]);
const errorMessage = nodeVersion >= 16 ? node16ErrorMessage : olderNodeErrorMessage;

const devErrorMessages = [
errorMessage,
const wrappedErrorMessage = `Error: Uncaught [${errorMessage}]`;

const react17ErrorMessages = [
wrappedErrorMessage,
'MUI: Unable to find the input element.',
errorMessage,
wrappedErrorMessage,
'The above error occurred in the <ul> component',
'The above error occurred in the <Test> component',
];

const react182ErrorMessages = [
wrappedErrorMessage,
'MUI: Unable to find the input element.',
wrappedErrorMessage,
// strict effects runs effects twice
React.version.startsWith('18') && 'MUI: Unable to find the input element.',
React.version.startsWith('18') && errorMessage,
'MUI: Unable to find the input element.',
wrappedErrorMessage,
'The above error occurred in the <ul> component',
React.version.startsWith('16') && 'The above error occurred in the <ul> component',
'The above error occurred in the <Test> component',
// strict effects runs effects twice
React.version.startsWith('18') && 'The above error occurred in the <Test> component',
React.version.startsWith('16') && 'The above error occurred in the <Test> component',
'The above error occurred in the <Test> component',
];

const react183ErrorMessages = [
'MUI: Unable to find the input element.',
'MUI: Unable to find the input element.',
errorMessage,
errorMessage,
errorMessage,
];

let devErrorMessages;
if (React.version.startsWith('18.3')) {
devErrorMessages = react183ErrorMessages;
} else if (React.version.startsWith('18')) {
devErrorMessages = react182ErrorMessages;
} else {
devErrorMessages = react17ErrorMessages;
}

expect(() => {
render(
<ErrorBoundary>
Expand Down Expand Up @@ -334,9 +368,8 @@ describe('useAutocomplete', () => {
});

it('should allow tuples or arrays as value when multiple=false', () => {
const defaultValue = ['bar'];
function Test() {
const defaultValue = ['bar'];

const { getClearProps, getInputProps } = useAutocomplete({
defaultValue,
disableClearable: false,
Expand Down

0 comments on commit 90ea911

Please sign in to comment.