-
Notifications
You must be signed in to change notification settings - Fork 0
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
Replace window timer with injected timer #601
base: main
Are you sure you want to change the base?
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 is a great change! Moving global functions with side effects to dependencies is looking very good.
test/components/BannerConductor/StateMachine/states/PendingState.spec.ts
Outdated
Show resolved
Hide resolved
6418d97
to
c27677e
Compare
05af049
to
70405d7
Compare
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.
WPDE desktop and mobile seem broken for me here,
as they use the BannerConductor they probably need to provide
the Timer in their entrypoints too
Good catch, thanks. |
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.
Wow, this update uncovered some flaws in our banner code, thanks again for doing this improvement! It'll benefit us and the donors in the future
@@ -27,6 +27,7 @@ import { LocaleFactoryDe } from '@src/utils/LocaleFactory/LocaleFactoryDe'; | |||
import { createFormItems } from './form_items'; | |||
import { createFormActions } from '@src/createFormActions'; | |||
import { currentCampaignTimePercentage } from './currentCampaignTimePercentage'; | |||
import { WindowTimer } from '@src/utils/Timer'; |
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.
Could you move these imports up in all banners (both WindowTimer
and currentCampaignTimePercentage
, to avoid misleading comments?
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 think I'd rather remove the comments, the IDE auto imports are always gonna mess this up
I just discovered that there is one more change needed - injecting the timer in the WPDE banners |
Components that use timers are hard to test. This removed the window timers and replaces them with an interface that we can mock. Updates all tests and banners to use the new timer. Ticket: https://phabricator.wikimedia.org/T378589
We previously tried to separate the imports in the banner entry points into logical sections. This didn't work well with IDE auto adding them at the bottom each time a new object was added. It was also a little confusing as to what should go where. This removes the comments and embraces js import chaos. Ticket: https://phabricator.wikimedia.org/T378589
Components that use timers are hard to test. This
removed the window timers and replaces them with
an interface that we can mock.
Ticket: https://phabricator.wikimedia.org/T378589