- Refactor `tests/utils/linkPreviewSettings.test.mjs` to be self-contained and remove dependency on `jsdom` (via `test-setup.mjs`).
- Add comprehensive test cases for `getLinkPreviewSettings`, `setLinkPreviewAutoFetch`, `allowLinkPreviewDomain`, `isLinkPreviewDomainAllowed`, and `subscribeToLinkPreviewSettings`.
- Add robustness checks for missing `localStorage` (simulated) and invalid inputs.
- Polyfill `EventTarget` and `CustomEvent` (as fallback) to ensure tests run reliably in environments where `jsdom` is unavailable.
This addresses the gap in testing coverage for `js/utils/linkPreviewSettings.js` while ensuring test stability.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Creates `tests/utils/linkPreviewSettings.test.mjs` to cover `js/utils/linkPreviewSettings.js`.
- Implements comprehensive tests for default state, storage persistence, domain management, event emission, and subscription.
- Polyfills JSDOM Event constructors in the test file to support `CustomEvent` emission.
- Ensures tests are isolated using `beforeEach`/`afterEach` to clear `localStorage`.
Co-authored-by: PR0M3TH3AN <[email protected]>
Adds comprehensive unit tests for `js/utils/videoTimestamps.js` using the native Node.js test runner.
- Covers `getVideoRootIdentifier`, `applyRootTimestampToVideosMap`, and `syncActiveVideoRootTimestamp`.
- Verifies handling of invalid inputs, edge cases (e.g., missing IDs, type mismatches), and state updates.
- Ensures robust timestamp synchronization logic.
This addresses the testing gap identified in `js/utils/videoTimestamps.js`.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Add `tests/utils/profileMedia.test.mjs` with comprehensive test cases.
- Fix `sanitizeProfileMediaUrl` to correctly trim whitespace after removing quotes.
- Fix `sanitizeProfileMediaUrl` to correctly detect and normalize `ipfs/` paths (without protocol).
Co-authored-by: PR0M3TH3AN <[email protected]>
- Added `tests/utils/cardSourceVisibility.test.mjs` to test `updateVideoCardSourceVisibility`.
- Covered scenarios for owner visibility, healthy sources, pending sources, and failed sources.
- Verified that card is hidden only when both sources (URL and Stream) are failed.
- Ensured graceful handling of null/undefined inputs.
Co-authored-by: PR0M3TH3AN <[email protected]>
Adds comprehensive unit tests for `resolveVideoPointer` in `js/utils/videoPointer.js`.
The new tests cover:
- Happy paths for address (a-tag) and event (e-tag) pointers.
- Priority logic (dTag > videoRootId > fallbackEventId).
- Input normalization (trimming, lowercasing).
- Relay inclusion in pointer arrays.
- Default kind handling (fallback to 30078).
- Edge cases and invalid inputs returning null.
This improves test coverage for core video pointer resolution utility.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Added `tests/utils/domUtils.test.mjs` to test `escapeHTML` and `removeTrackingScripts`.
- Verified tests pass with `node:test` and JSDOM.
Co-authored-by: PR0M3TH3AN <[email protected]>
Removed unused exports and functions identified as dead code.
- Removed unused exports from `js/utils/storage.js`, `js/utils/storagePointer.js`, `js/utils/videoTags.js`, `js/ui/moderationCopy.js`.
- Removed unused function `updateTagPillStrip` from `js/ui/components/tagPillList.js` and associated tests.
- Updated `tests/utils/video-tags.test.mjs` to remove test for private function.
- Added `artifacts/depcheck.json` showing dependency analysis.
Co-authored-by: PR0M3TH3AN <[email protected]>