Skip to content

[core] Setup testing to work with CSS imports #17214

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

Merged
merged 68 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
6f2c84a
build: setup vite for e2e & regressions
romgrk Apr 1, 2025
d09b7ec
build: package.json
romgrk Apr 1, 2025
a5e5081
lint
romgrk Apr 1, 2025
fa3f160
build: copy CSS files to output folders
romgrk Apr 1, 2025
559dea0
build: mocha css import
romgrk Apr 1, 2025
0a09c74
build: make test:karma work
romgrk Apr 2, 2025
05ec5e4
lint
romgrk Apr 2, 2025
4054d9a
build: lint
romgrk Apr 2, 2025
69254d8
Update packages/x-internals/package.json
romgrk Apr 2, 2025
4fd43c5
lint
romgrk Apr 2, 2025
508ca16
build: x-internals
romgrk Apr 2, 2025
529b675
build: fix regressions isReady()
romgrk Apr 2, 2025
c0036e6
build: fix code replace
romgrk Apr 2, 2025
8c96681
lint
romgrk Apr 2, 2025
ae2e125
build: fix e2e timeout
romgrk Apr 3, 2025
c278a72
Merge branch 'master' into refactor-css-breaking-change
romgrk Apr 3, 2025
7ef99cb
build: fix again
romgrk Apr 4, 2025
ec3f068
Merge branch 'master' into refactor-css-breaking-change
romgrk Apr 4, 2025
0c609a4
test(regressions): move stuff around, fix fakeNow
romgrk Apr 4, 2025
929ede7
lint
romgrk Apr 4, 2025
d575778
test(regressions): fix license issues [thanks to Lukas]
romgrk Apr 4, 2025
9ac5267
refactor: remove proptypes
romgrk Apr 7, 2025
a27a497
lint
romgrk Apr 7, 2025
1b41158
lint
romgrk Apr 7, 2025
6387861
test(regressions): fix fake clocks [take 2]
romgrk Apr 8, 2025
96b0769
lint: e2e_build => test_build
romgrk Apr 8, 2025
eaa8d11
lint
romgrk Apr 8, 2025
86a8216
lint: @mui/system dev dependency
romgrk Apr 8, 2025
daf5a5f
lint
romgrk Apr 8, 2025
97a6c94
lint
romgrk Apr 8, 2025
a22b2b6
lint
romgrk Apr 8, 2025
0517866
Merge branch 'master' into refactor-css-breaking-change
romgrk Apr 8, 2025
9a88d48
test(regressions): fix location/route
romgrk Apr 8, 2025
f608345
Merge branch 'master' into refactor-css-breaking-change
romgrk Apr 8, 2025
f91d64d
ci: run (empty commit)
romgrk Apr 8, 2025
2ba9ac8
lint
romgrk Apr 8, 2025
022817b
lint: move import index.css
romgrk Apr 8, 2025
7208494
Update test/regressions/TestViewer.tsx
romgrk Apr 8, 2025
0b9e5dd
Update test/regressions/index.test.ts
romgrk Apr 8, 2025
a75b461
lint
romgrk Apr 8, 2025
f6c4c9e
lint: currentDirectory => import.meta.dirname
romgrk Apr 8, 2025
3ed3144
refactor: blacklist patterns to import.meta.glob
romgrk Apr 8, 2025
c0b8e46
lint
romgrk Apr 8, 2025
171ccb2
ci: run (empty commit)
romgrk Apr 8, 2025
ccacbc6
Merge branch 'master' into refactor-css-breaking-change
romgrk Apr 8, 2025
4c41181
Update test/regressions/TestViewer.tsx
romgrk Apr 8, 2025
19e6d71
fix: revert import.meta.dirname in next.js config
romgrk Apr 9, 2025
8921294
build: images
romgrk Apr 9, 2025
d52ae87
revert: "build: images" (circleci outage)
romgrk Apr 9, 2025
590e171
ci: run (empty commit)
romgrk Apr 9, 2025
4545d50
ci: run (empty commit)
romgrk Apr 9, 2025
1bb53db
revert: "revert: "build: images" (circleci outage)"
romgrk Apr 9, 2025
5a331c4
lint
romgrk Apr 9, 2025
f52a7eb
lint
romgrk Apr 9, 2025
d95a061
lint
romgrk Apr 9, 2025
6662434
lint
romgrk Apr 9, 2025
b0bbd52
Merge branch 'master' into refactor-css-breaking-change
romgrk Apr 9, 2025
aa7a171
ci: run (empty commit)
romgrk Apr 9, 2025
cf0ae07
lint
romgrk Apr 10, 2025
e04c802
lint
romgrk Apr 10, 2025
40e4483
build: remove pnpm caching
romgrk Apr 10, 2025
bb54095
deps: node types & netlify to 23.11.0
romgrk Apr 10, 2025
fb67673
lint
romgrk Apr 10, 2025
13f59d5
lint
romgrk Apr 10, 2025
6f7e7fd
ci: run (empty commit)
romgrk Apr 10, 2025
5ce75c5
Merge branch 'master' into refactor-css-breaking-change
cherniavskii Apr 10, 2025
03cbf92
pass isDataGridPivotTest
cherniavskii Apr 10, 2025
f72a797
Merge branch 'master' into refactor-css-breaking-change
LukasTy Apr 10, 2025
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
51 changes: 20 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ default-job: &default-job
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'
working_directory: /tmp/mui
docker:
- image: cimg/node:20.19
- image: cimg/node:23.11
# CircleCI has disabled the cache across forks for security reasons.
# Following their official statement, it was a quick solution, they
# are working on providing this feature back with appropriate security measures.
Expand All @@ -60,36 +60,27 @@ default-context: &default-context
commands:
install_js:
parameters:
browsers:
playwright:
description: If playwright should be installed.
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 use.
type: string
default: << pipeline.parameters.react-version >>
description: The version of React to use.

steps:
- when:
condition: << parameters.browsers >>
steps:
- run:
name: Install pnpm package manager
command: corepack enable
- when:
condition:
not: << parameters.browsers >>
steps:
- run:
name: Install pnpm package manager
# See https://stackoverflow.com/a/73411601
command: corepack enable --install-directory ~/bin
- run:
name: Install pnpm package manager
# See https://stackoverflow.com/a/73411601
command: corepack enable --install-directory ~/bin

- run:
name: View install environment
command: |
node --version
pnpm --version

- when:
condition:
equal: [stable, << parameters.react-version >>]
Expand Down Expand Up @@ -118,6 +109,12 @@ commands:
- run:
name: Install @mui/material v6
command: pnpm use-material-ui-v6
- when:
condition: << parameters.playwright >>
steps:
- run:
name: Install playwright
command: pnpx [email protected] install --with-deps

jobs:
checkout:
Expand Down Expand Up @@ -240,12 +237,10 @@ jobs:

test_browser:
<<: *default-job
docker:
- image: mcr.microsoft.com/playwright:v1.51.1-noble
steps:
- checkout
- install_js:
browsers: true
playwright: true
react-version: << parameters.react-version >>
- run:
name: Tests real browsers
Expand All @@ -272,41 +267,35 @@ jobs:
NODE_OPTIONS: --max-old-space-size=3584
test_e2e:
<<: *default-job
docker:
- image: mcr.microsoft.com/playwright:v1.51.1-noble
steps:
- checkout
- install_js:
browsers: true
playwright: true
react-version: << parameters.react-version >>
- run:
name: Run e2e tests
command: pnpm test:e2e
test_e2e_website:
<<: *default-job
docker:
- image: mcr.microsoft.com/playwright:v1.51.1-noble
steps:
- checkout
- install_js:
browsers: true
playwright: true
- run:
name: pnpm test:e2e-website
command: pnpm test:e2e-website
environment:
PLAYWRIGHT_TEST_BASE_URL: << parameters.e2e-base-url >>
test_regressions:
<<: *default-job
docker:
- image: mcr.microsoft.com/playwright:v1.51.1-noble
steps:
- checkout
- install_js:
browsers: true
playwright: true
react-version: << parameters.react-version >>
- run:
name: Install ffmpeg
command: apt update && apt upgrade -y && apt install ffmpeg -y
command: sudo apt update && sudo apt upgrade -y && sudo apt install ffmpeg -y
- run:
name: Run visual regression tests
command: xvfb-run pnpm test:regressions
Expand Down
7 changes: 5 additions & 2 deletions .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ module.exports = {
// We're leaving this to make sure.
'docs/.next/**',
],
'node-option': ['no-experimental-detect-module'],
recursive: true,
timeout: (process.env.CIRCLECI === 'true' ? 5 : 2) * 1000, // Circle CI has low-performance CPUs.
reporter: 'dot',
require: [require.resolve('./test/utils/setupBabel'), require.resolve('./test/utils/setupJSDOM')],
require: [
require.resolve('./test/utils/ignoreCSS'),
require.resolve('./test/utils/setupBabel'),
require.resolve('./test/utils/setupJSDOM'),
],
'watch-ignore': [
// default
'.git',
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ module.exports = function getBabelConfig(api) {
}

if (process.env.NODE_ENV === 'production') {
if (!process.env.E2E_BUILD) {
if (!process.env.TEST_BUILD) {
plugins.push(['babel-plugin-react-remove-properties', { properties: ['data-testid'] }]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { RichTreeView } from '@mui/x-tree-view/RichTreeView';

import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { RichTreeView } from '@mui/x-tree-view/RichTreeView';
import { TreeViewBaseItem } from '@mui/x-tree-view/models';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS: TreeViewBaseItem[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { RichTreeView } from '@mui/x-tree-view/RichTreeView';

import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { RichTreeView } from '@mui/x-tree-view/RichTreeView';
import { TreeViewBaseItem } from '@mui/x-tree-view/models';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS: TreeViewBaseItem[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';

import { RichTreeView } from '@mui/x-tree-view/RichTreeView';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { TreeViewBaseItem } from '@mui/x-tree-view/models';
import { RichTreeView } from '@mui/x-tree-view/RichTreeView';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS: TreeViewBaseItem[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';

import { RichTreeView } from '@mui/x-tree-view/RichTreeView';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { TreeViewBaseItem } from '@mui/x-tree-view/models';
import { RichTreeView } from '@mui/x-tree-view/RichTreeView';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

const MUI_X_PRODUCTS: TreeViewBaseItem[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodFocusItem() {
const apiRef = useTreeViewApiRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodFocusItem() {
const apiRef = useTreeViewApiRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodGetItemDOMElement() {
const apiRef = useTreeViewApiRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodGetItemDOMElement() {
const apiRef = useTreeViewApiRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodSetItemSelection() {
const apiRef = useTreeViewApiRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodSetItemSelection() {
const apiRef = useTreeViewApiRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodSetItemSelectionKeepExistingSelection() {
const apiRef = useTreeViewApiRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks/useTreeViewApiRef';
import { useTreeViewApiRef } from '@mui/x-tree-view/hooks';

export default function ApiMethodSetItemSelectionKeepExistingSelection() {
const apiRef = useTreeViewApiRef();
Expand Down
30 changes: 9 additions & 21 deletions docs/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import * as url from 'url';
import * as fs from 'fs';
import * as url from 'url';
import { createRequire } from 'module';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
// @ts-expect-error This expected error should be gone once we update the monorepo
Expand All @@ -10,7 +10,10 @@ import { findPages } from './src/modules/utils/find';
import { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES, LANGUAGES_IN_PROGRESS } from './config';
import { SOURCE_CODE_REPO, SOURCE_GITHUB_BRANCH } from './constants';

const IS_PRODUCTION = process.env.NODE_ENV === 'production';

const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));

const require = createRequire(import.meta.url);

const WORKSPACE_ROOT = path.resolve(currentDirectory, '../');
Expand All @@ -20,24 +23,6 @@ const MONOREPO_ALIASES = {
'@mui/internal-markdown': path.resolve(MONOREPO_PATH, './packages/markdown'),
};

const WORKSPACE_ALIASES = {
'@mui/x-data-grid': path.resolve(WORKSPACE_ROOT, './packages/x-data-grid/src'),
'@mui/x-data-grid-generator': path.resolve(
WORKSPACE_ROOT,
'./packages/x-data-grid-generator/src',
),
'@mui/x-data-grid-pro': path.resolve(WORKSPACE_ROOT, './packages/x-data-grid-pro/src'),
'@mui/x-data-grid-premium': path.resolve(WORKSPACE_ROOT, './packages/x-data-grid-premium/src'),
'@mui/x-date-pickers': path.resolve(WORKSPACE_ROOT, './packages/x-date-pickers/src'),
'@mui/x-date-pickers-pro': path.resolve(WORKSPACE_ROOT, './packages/x-date-pickers-pro/src'),
'@mui/x-charts': path.resolve(WORKSPACE_ROOT, './packages/x-charts/src'),
'@mui/x-charts-pro': path.resolve(WORKSPACE_ROOT, './packages/x-charts-pro/src'),
'@mui/x-charts-vendor': path.resolve(WORKSPACE_ROOT, './packages/x-charts-vendor'),
'@mui/x-tree-view': path.resolve(WORKSPACE_ROOT, './packages/x-tree-view/src'),
'@mui/x-tree-view-pro': path.resolve(WORKSPACE_ROOT, './packages/x-tree-view-pro/src'),
'@mui/x-license': path.resolve(WORKSPACE_ROOT, './packages/x-license/src'),
};

function loadPkg(pkgPath: string): { version: string } {
const pkgContent = fs.readFileSync(path.resolve(WORKSPACE_ROOT, pkgPath, 'package.json'), 'utf8');
return JSON.parse(pkgContent);
Expand All @@ -58,6 +43,10 @@ try {
}

export default withDocsInfra({
typescript: {
// The tsconfig also contains path aliases that are used by next.js.
tsconfigPath: IS_PRODUCTION ? '../tsconfig.prod.json' : '../tsconfig.dev.json',
},
experimental: {
esmExternals: undefined,
},
Expand Down Expand Up @@ -105,7 +94,6 @@ export default withDocsInfra({
alias: {
...config.resolve.alias,
...MONOREPO_ALIASES,
...WORKSPACE_ALIASES,
// TODO: get rid of this, replace with @mui/docs
docs: path.resolve(MONOREPO_PATH, './docs'),
docsx: path.resolve(currentDirectory, '../docs'),
Expand Down Expand Up @@ -204,7 +192,7 @@ export default withDocsInfra({
return map;
},
// Used to signal we run build
...(process.env.NODE_ENV === 'production'
...(IS_PRODUCTION
? {
output: 'export',
}
Expand Down
2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@mui/system": "^7.0.1",
"@mui/utils": "^7.0.1",
"@mui/x-charts": "workspace:*",
"@mui/x-charts-pro": "workspace:*",
"@mui/x-charts-vendor": "workspace:*",
"@mui/x-data-grid": "workspace:*",
"@mui/x-data-grid-generator": "workspace:*",
Expand All @@ -44,6 +45,7 @@
"@mui/x-date-pickers": "workspace:*",
"@mui/x-date-pickers-pro": "workspace:*",
"@mui/x-tree-view": "workspace:*",
"@mui/x-tree-view-pro": "workspace:*",
"@react-spring/web": "^9.7.5",
"@tanstack/query-core": "^5.71.10",
"@tanstack/react-query": "^5.71.10",
Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
command = "pnpm docs:build"

[build.environment]
NODE_VERSION = "20"
NODE_VERSION = "23"
NODE_OPTIONS = "--max_old_space_size=4096"

[[plugins]]
Expand Down
Loading