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

Replace window timer with injected timer #601

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Replace window timer with injected timer #601

wants to merge 2 commits into from

Conversation

Abban
Copy link
Member

@Abban Abban commented Oct 31, 2024

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

Copy link
Member

@gbirke gbirke left a 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.

@Abban Abban force-pushed the timer branch 2 times, most recently from 6418d97 to c27677e Compare November 7, 2024 08:46
@Abban Abban marked this pull request as ready for review November 7, 2024 08:46
@Abban Abban requested a review from gbirke November 7, 2024 08:47
@Abban Abban force-pushed the timer branch 2 times, most recently from 05af049 to 70405d7 Compare November 7, 2024 09:26
Copy link
Contributor

@moiikana moiikana left a 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

@Abban
Copy link
Member Author

Abban commented Nov 7, 2024

Good catch, thanks.

Copy link
Member

@gbirke gbirke left a 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';
Copy link
Member

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?

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 think I'd rather remove the comments, the IDE auto imports are always gonna mess this up

src/components/BannerConductor/BannerConductor.vue Outdated Show resolved Hide resolved
src/components/SoftClose/SoftClose.vue Show resolved Hide resolved
@gbirke
Copy link
Member

gbirke commented Nov 7, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants