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
[styles] Fix resolution of default props #24253
[styles] Fix resolution of default props #24253
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed with a test.
Would it work if we add the test case for only one component, as a meant to validate that the whole integration is working? We could rely on the fact that the other components should all implement the same template. This was the approach used since v1 for withStyles, the Button component was serving this purpose (as far as I remember). The solution seems simple enough to make me think that adding a new entry into describe conformance won't be efficient (spending more time writing test cases than saving us time and trust with regressions). |
A test should be added for the behavior that was broken. |
Changes looks good. The only reason the |
6eeb23d
to
03aca94
Compare
|
if (!testStateOverrides) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When should this not be tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you ask me, I would say most of the time we don't need to test it. We don't even fully test it right now, we take an arbitrary case. I would personally prefer we use the Button or Slider as a stress test template. It should be enough.
Badge is still untested.
The badge doesn't have state on its root element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved away from the API in #24095 with this patch https://gist.github.com/oliviertassinari/60614c8c37d4ba10adc2a3b1aba1277e. The fix is meant for backward compatibility with v4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Badge is still untested.
The badge doesn't have state on its root element.
Then why did we need to change the implementation?
If you ask me, I would say most of the time we don't need to test it.
It already broke once.
The fix is meant for backward compatibility with v4.
describeConformanceV5
is not meant for v4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It already broke once.
Exactly why I suggest the current tradeoff. If it breaks a second time, it will be a signal that it isn't enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument I have tried to defend is that it doesn't matter.
It does matter. Every implementation needs a test unless it isn't testable at which point one needs to make an argument why it isn't testable.
We don't decide by who writes the code if it needs to be tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every implementation needs a test unless it isn't testable
I respectfully disagree. I think that we should also add "unless it's not worth it".
I think that it's like the 100% code coverage I have tried to push in the past and we gave up on. It's not always worth the time, once the opportunity cost is high, best to defer and be lazy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I respectfully disagree. I think that we should also add "unless it's not worth it".
Impossible to collaborate on that premise since this argument applies anytime. Also: please stop cutting the quote. This is not what I said.
I think that it's like the 100% code coverage I have tried to push in the past and we gave up on.
At some point there comes a time where you should educate yourself more on the topic. I can only bring nudge you so far but if you believe that line coverage has anything to do with behavior testing I don't think you put any thought into verifying your work.
It becomes evident to me that you don't know at all why you made this change. I'm asking you a third time now: Why was the Badge changed but no test added? If you don't know what the code does then please revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impossible to collaborate on that premise since this argument applies anytime.
I think that we can default to testing less when we have a doubt. We have done this many times e.g. bugs in IE11, not worth it, it has been more efficient to have regressions and handle them. I think that it's best to wait for the pain to grow before doing something about it, we already have so many problems we know are important and need care.
Why was the Badge changed but no test added?
I have tried to answer it in #24253 (comment), the new generic test inside describeConformanceV5 doesn't support it. It's one rounding error compared to all the other components (144). Best to ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry but you have the responsibility to explain the code you write. We have this expectation for any other contribution. What you did, expected behavior, actual behavior applies to everyone.
I have found this bug trying to customize the small and large variant of the button in #24095 for this spec:
See this reproduction for the issue: https://codesandbox.io/s/globalthemevariants-material-demo-forked-rexjl?file=/demo.tsx
Once we apply the patch of this pull request: https://codesandbox.io/s/globalthemevariants-material-demo-forked-13dfi?file=/package.json
Regarding the tests, I'm not sure we need any, it seems to be simply about using the same approach as we use for writing the CSS but for the overrides.
Closes #24262