youtube icon indicating copy to clipboard operation
youtube copied to clipboard

🐞`tests/unit/hdr-badge.test.js` fails

Open hkzo opened this issue 1 month ago • 0 comments

Summary

When running npm test, the unit test shows no badge when the setting is off, but clears stale badges in tests/unit/hdr-badge.test.js fails.

  • Expected: appended.length to be 0 when setting: false.
  • Received: appended.length to be 1.

Background & Investigation

  1. In repo/js&css/web-accessible/functions.js, ImprovedTube.hdrBadge() is guarded by this.storage.hdr_badge === true:
    if (this.storage.hdr_badge === true && document.documentElement.dataset.pageType === 'video') { ImprovedTube.hdrBadge(); };
    
  2. However, the standalone function ImprovedTube.hdrBadge in repo/js&css/web-accessible/www.youtube.com/appearance.js does not check this.storage.hdr_badge internally.
  3. When hdrBadge() is invoked directly (as done in the unit test with context.ImprovedTube.hdrBadge()), it executes and appends the badge regardless of the storage setting value.

Notes

  • Affected Version / Commit: master branch (Commit: c560f05d74e64d208ac55c341278f0e55a84c0e0)
  • Note: Since this has not been released yet, the issue occurs on the current master commit.

hkzo avatar Oct 24 '26 11:10 hkzo