Skip to content

Pr/testing#3433

Open
sarontebebe7 wants to merge 11 commits intocode-charity:masterfrom
sarontebebe7:pr/testing
Open

Pr/testing#3433
sarontebebe7 wants to merge 11 commits intocode-charity:masterfrom
sarontebebe7:pr/testing

Conversation

@sarontebebe7
Copy link

Unit tests for lazy loading system

sarontebebe7 and others added 11 commits November 3, 2025 20:21
- Toggle between original and translated video titles on watch pages
- Ctrl+click thumbnails to see original titles throughout YouTube
- Uses multiple APIs (oEmbed, microformat, meta tags) for reliability
- Smart translation detection only shows toggle when needed
- Visual indicators and state management per video
- Comprehensive test suite with 249 lines of tests
- Settings integration in appearance menu (default: enabled)

Fixes issues with translated titles obscuring original content.
- Separate enable/disable functions for each feature
- Auto-initialization based on storage values
- User cohort detection (multilingual, countries, subtitle users)
- Feature eligibility checking for gradual rollout
- Debug logging system (toggleable)
- Smart storage listener with auto enable/disable
- Add page detection to identify current YouTube page (home, watch, feed, etc.)
- Implement loadFeatureModule() for dynamic script injection
- Add loadAndEnableFeature() to check page eligibility before loading
- Track loaded modules to prevent duplicate loads
- Update storage listener to use lazy loading
- Refactor init.js to load only enabled features dynamically
- Remove static feature imports from manifest content_scripts
- Add feature modules to web_accessible_resources for dynamic loading
- Features now load on-demand based on user settings and current page
- Add comprehensive status report comparing implementation vs author requirements
- Remove unnecessary typeof checks in init.js (as per author's comment)
- Trust lazy loading to handle feature availability
- Document remaining work: sidebar.js refactoring needed
- Add 27 new test methods for lazy loading features
- Test detectUserCohort with various user scenarios
- Test isFeatureEligibleForUser with cohorts and rollout
- Test getUserHash for consistent A/B testing
- Test getCurrentPage for URL path detection
- Test loadAndEnableFeature with module loading
- Use test doubles (mocks, stubs, fakes) extensively
- Doubled total test count from 25 to 52 tests
- 39 tests passing (75% pass rate)

Coverage remains low (0.39%) due to browser-dependent code
Tests focus on testable business logic in core.js
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.

2 participants