-
Notifications
You must be signed in to change notification settings - Fork 121
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
Make transition durations dynamic Part 1 #2482
Make transition durations dynamic Part 1 #2482
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.
Looks good! I can confirm the animations are still working.
Just one type suggestion then ready to merge.
NOTE: I wanted to be able to test the helper under testing conditions so I had to add some provisions to allow for overriding the state and force it to operate as if it was in tests. We could make this a bit simpler if we brought back the
isE2E
helper (in it's functional form) now that we're checking this in multiple places; thenisE2E
could be easily mocked so we can test both paths.
I think the benefit we get from this additional testing is probably not worth the additional complexity. It turns what is essentially an if-statement that zeros out the duration into an object-oriented class with its own interface and set of tests. The duration logic is not likely to change in the future and not likely to develop regressions.
I would generally reserve testing for 1) high-level integration testing of user behavior, or 2) low-level unit testing of nontrival functionality. Testing the test framework has diminishing returns, especially when the added test complexity exceeds the complexity of the original logic.
Maybe I'm wrong about this and the long-term benefit exceeds the additional complexity. Or perhaps I'm underestimating the possibility of regressions in the duration switch. Anyway, just wanted to share my perspective. I'm fine to leave this in since it is already done. Thanks!
672181f
to
dbc8719
Compare
@mstrofbass I resolved some merge conflicts from a PR I merged this morning, so make sure to pull the latest (dbc8719). |
It's a philosophical difference that's not a quick discussion but a few reasons I prefer it:
It's also widely considered a best practice...this is a bit of an appeal to authority that I don't care for but it's worth pointing out that there are a lot of justifications for it. My general preference is full coverage via true unit tests, as full coverage as I can get via e2e tests, and integration tests for really complex portions that are difficult to test via e2e tests. Most of my testing is in backend stuff, so this paradigm gets a bit iffy in UI land but the general philosophy is still applicable. I'm fine either way, I just default to writing low-level tests unless someone tells me not to since it's easier to write them when writing the code than it is to come back later and write them. I will also modify my style to your preferences; it will just take some probing here and there to figure out what they are! |
Will get to the requested changes later this evening! |
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.
token()
is for using inside the style
prop. For cva
and css
, you can use '...{durations.tokenName} ...'
directly, and if the property only consists of '{duration.tokenName}'
, you can put in 'tokenName'
directly.
@yangchristina Thanks for adding your PandaCSS expertise! @mstrofbass Thank you for expanding on that! Well said. I should definitely soften my position. Unit tests are essential for preventing regressions, and I think we should strive for as much coverage as possible. The existing unit tests have been indispensable for several major refactors, and I've never found myself wanting fewer. Integration tests should not be thought of as a replacement for unit tests, but rather as complementary. All the reasons you provided I am in deep agreement with. To narrow it down, I guess what was most relevant here was mocking, and how it can add complexity if we're not careful. The When mocking and/or testing the test coverage comes up again, let's discuss so we can consider the tradeoffs. Otherwise, I'm all for full test coverage, especially for |
This is great info @yangchristina. I didn't quite get the last part there about putting |
I tend to avoid mocking global or language stuff like that because it's frequently significantly more work than just wrapping it. I went ahead and tried to mock |
let inTest: boolean = !!navigator.webdriver | ||
|
||
/** Returns the duration for a particular key or undefined if it doesn't exist. */ | ||
const get = (key: keyof typeof durationsConfig): number => { |
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.
Exactly!
This replaces PR #2464 and makes progress on #2110
The changes here are:
0
instead of the duration when we're in the e2e tests.NOTE: I wanted to be able to test the helper under testing conditions so I had to add some provisions to allow for overriding the state and force it to operate as if it was in tests. We could make this a bit simpler if we brought back the
isE2E
helper (in it's functional form) now that we're checking this in multiple places; thenisE2E
could be easily mocked so we can test both paths.