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

[core] Make DatePickers tests independent from other packages #13951

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

JCQuintas
Copy link
Member

Related to #13882

  • Created test/unit-date-pickers which holds all config and helpers for date pickers unit testing
  • Created test/shared for any shared functionality that should happen in most/all tests
  • Long term goal is to have no files in the root test/, only dirs
  • Also will move all treeview|data-grid|charts test configs into their own folders/scripts

@JCQuintas JCQuintas added core Infrastructure work going on behind the scenes scope: code-infra Specific to the core-infra product labels Jul 23, 2024
@JCQuintas JCQuintas self-assigned this Jul 23, 2024
@mui-bot
Copy link

mui-bot commented Jul 23, 2024

Deploy preview: https://deploy-preview-13951--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against c092a90

Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your effort! 🙏
Leaving some initial feedback.

"private": true,
"scripts": {
"typescript": "tsc -p tsconfig.json",
"test:unit": "cross-env NODE_ENV=test TZ=UTC mocha -n expose_gc --config .mocharc.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we were talking about this change, I had a slightly different picture in my head:

  1. Refactor utils if and how necessary
  2. Add package-specific test config (and mocha file) in the package itself
  3. Add the refactored packages into the root mocharc file to avoid running them via the root command
  4. Add a functioning isolated test:unit script to transitioned packages
  5. Augment the root test:unit with a pnpm run test:unit -r to also run individual package tests

WDYT about that?
Did you consider such an approach?
Do you see problems with it? 🤔

I'm not the biggest fan of this direction as we'd end up with duplicate testing packages for each product line. 🙈

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first approach was to have the config on each package. 😅
It works, but I felt it to be a bit clunky. x-date-pickers and x-date-pickers-pro use exactly the same config, so they would be duplicated or we would need a place to store them. Should they be in x-date-pickers? Felt a bit odd, as there might be necessary types/imports from -pro in some cases.

  • test/unit-date-pickers -> depends on
    • @mui/x-date-pickers
    • @mui/x-date-pickers-pro

This makes the tests dependant on the packages. Often times you will want to run the tests for them together anyways, so I felt this was fine.

The problem with utils folder is that it is a too generic name, so I would rather we move away from it in this use-case. We(as humans) tend to put anything there, so it acts as a container for everything, which is almost the same as no container at all. In general, folders that have a semantical meaning are easier to navigate, and should be preferred.

It is also important to note these changes need to be done step by step. As we need to keep CI and coverage working as we go 😅

So in short:

  • Either duplicate config, or shared, so moved all config to a single place, which made easier to just have a single config.
  • Wanted to have a specific place for the date-picker utils, moved them to same package.
  • Changes don't affect CI/coverage for now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not the biggest fan of this direction as we'd end up with duplicate testing packages for each product line. 🙈

I don't get what you mean with this. Which packages would be we duplicating?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasTy Correct me if I'm wrong, but you mean we will end up with the following internal packages

  • test/unit-date-pickers
  • test/unit-charts
  • test/unit-data-grid
  • test/unit-tree-view

About community/pro testing, if some pro types are needed to define some test, then you can test both pro and community future in the pro package

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, I forgot to reply to this one. 🙈
Yes, exactly, I was mentioning the "duplication" or introduction of test/unit-<package> packages for each component family. 👍
I'm not against it, just had a different picture in my head initially and the proposed config is somewhat unconventional. 🤔

@@ -25,6 +25,7 @@ const defaultAlias = {
),
docs: resolveAliasPath('./node_modules/@mui/monorepo/docs'),
test: resolveAliasPath('./test'),
'@unit/date-pickers': resolveAliasPath('./test/unit-date-pickers'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Do you see a problem with just sticking to the existing test alias? 🤔
I.e.: Have test/pickers/helpers or test/pickers/utils imports. 🤔

For now, the convention seems more or less clear:

  • use @mui for product packages and all external aliases
  • Use the folder name for other internal aliases (with the exception of docs 🙈 )

Copy link
Member Author

@JCQuintas JCQuintas Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind much about the naming. I just used what felt best.

  • test is generic so it didn't give much value, eg: test/date-pickers could be confusing if we have e2e-date-pickers in the future.
  • test/pickers could be confusing if we have a color-picker which is a different package.

In general (contradictorily), I find the more precise the better 😅

So I felt @unit/date-pickers to be the most concise and gives all the info necessary. We can def change it to test/unit/date-pickers or test/pickers or anything else if you don't think the considerations above are relevant.

This is quite easy to refactor, we could change at any time if we decide to go with test/pickers and later we have something else there

@LukasTy LukasTy added the test label Jul 24, 2024
@oliviertassinari oliviertassinari added the component: pickers This is the name of the generic UI component, not the React module! label Jul 24, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 26, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 7, 2024
@JCQuintas JCQuintas force-pushed the independent/pickers branch 3 times, most recently from d24b835 to e618a4e Compare August 8, 2024 21:47
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 9, 2024
Copy link

github-actions bot commented Aug 9, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 9, 2024
@JCQuintas JCQuintas marked this pull request as draft August 14, 2024 18:02
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes PR: out-of-date The pull request has merge conflicts and can't be merged scope: code-infra Specific to the core-infra product test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants