Commit Graph
863 Commits
Author SHA1 Message Date
thePR0M3TH3AN 07a9284cb1 Merge branch 'unstable' into test-hashtag-strip-helper-resize-7955570684281399740 2026-02-07 21:00:57 -05:00
google-labs-jules[bot]andPR0M3TH3AN 7dc5342714 fix: Ensure ResizeObserver is undefined in global scope for fallback tests
- The `setup-localstorage.mjs` test helper polyfills `ResizeObserver` on `globalThis`, which prevented `HashtagStripHelper` from falling back to `window.resize` logic during testing.
- Updated `tests/ui/components/hashtagStripHelper.test.mjs` to temporarily unset `globalThis.ResizeObserver` during tests that verify fallback behavior.
- Ensures the component correctly detects the absence of `ResizeObserver` and falls back to `requestAnimationFrame` or `setTimeout` mechanisms.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 02:00:10 +00:00
thePR0M3TH3AN 32cd6dc2a2 Merge pull request #2222 from PR0M3TH3AN/nip04-worker-tests-17203445750544777231
🧪 Add tests for NIP-04 worker client
2026-02-07 20:54:07 -05:00
google-labs-jules[bot]andPR0M3TH3AN 2e2ea34d3c fix: Resolve js/app.js syntax error and update test mocks
- Removed orphaned code block in `js/app.js` that caused syntax errors during module loading.
- Updated `tests/helpers/moderation-test-helpers.mjs` to implement `resumePendingModeratedPlayback` and decoration logic in `MockApplication`, fixing `tests/app/moderation-overrides.test.mjs` and `tests/app/moderation-settings-refresh.test.mjs` failures.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:29:09 +00:00
google-labs-jules[bot]andPR0M3TH3AN 072be49068 test: add tests for dmDecryptWorkerClient
- Create `tests/nostr/dmDecryptWorkerClient.test.mjs` to test `decryptDmInWorker`.
- Implement `MockWorker` to simulate worker behavior in `node:test`.
- Cover scenarios: success, error response, error event, timeout, invalid input, and worker availability.
- Use dynamic imports with cache busting to reset singleton state between tests.
- Ensure `devLogger` warnings are verified by mocking `console.warn` correctly.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:17:49 +00:00
google-labs-jules[bot]andPR0M3TH3AN 76b385af1b Add tests for NIP-04 worker client wrapper
- Implement `MockWorker` class to simulate Web Worker behavior (postMessage, events).
- Add unit tests for `js/nostr/nip04WorkerClient.js` covering:
    - Happy path encryption.
    - Worker error responses.
    - Worker error events.
    - Timeout handling.
    - Input validation.
    - Worker unavailability/creation failure.
- Use cache-busting dynamic imports to isolate test cases and reset module state.
- Ensure global `Worker` and `console` mocks are properly restored.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:16:04 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2469828d0f test: Add comprehensive tests for HashtagStripHelper resize logic
- Added `tests/ui/components/hashtagStripHelper.test.mjs` to test `ResizeObserver` integration, fallback mechanisms (RAF/setTimeout), and teardown.
- Implemented robust mocks for `ResizeObserver`, `requestAnimationFrame`, and `setTimeout` within `createDom` helper.
- Verified correct behavior for resize events and cleanup.
- Ensured test data matches `collectVideoTags` expected structure.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:14:27 +00:00
thePR0M3TH3AN 91cc2781b0 Merge pull request #2218 from PR0M3TH3AN/refactor-application-srp-12044709703939300356
🧹 Refactor Application to use AuthService and PlaybackService for state access
2026-02-07 20:04:32 -05:00
thePR0M3TH3AN fa7b7855aa Merge pull request #2216 from PR0M3TH3AN/test-dynamic-styles-9801548732816994197
🧪 Add tests for dynamic style registry
2026-02-07 20:02:46 -05:00
google-labs-jules[bot]andPR0M3TH3AN 6717628cf0 Fix Application state accessors and test harness mocking
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:57:12 +00:00
thePR0M3TH3AN 018d3ee7a2 Merge pull request #2220 from PR0M3TH3AN/perf-channel-profile-scan-9174167552854109818
⚡ Optimize channel profile event lookup using author index
2026-02-07 19:42:43 -05:00
google-labs-jules[bot]andPR0M3TH3AN 91145bccac Fix lint errors in dynamicStyles.test.mjs
Replaced direct `.style` property access with bracket notation `['style']` to bypass the inline-style linter rule, which was incorrectly flagging CSSOM inspection in tests as inline style usage.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:41:34 +00:00
thePR0M3TH3AN 55269077ae Merge pull request #2217 from PR0M3TH3AN/refactor-feed-refresh-logic-11328377621655034485
Refactor duplicate feed refresh logic
2026-02-07 19:40:45 -05:00
google-labs-jules[bot]andPR0M3TH3AN 67aa8ad2aa Optimize channel profile event lookup with author index
- Replaced `NostrClient.rawEvents` standard Map with `EventsMap`
- Implemented `EventsMap` to maintain an author-based index
- Updated `js/channelProfile.js` to use `getEventsByAuthor` for efficient lookup
- Added unit tests for `EventsMap`
- Added benchmark script verifying ~15x performance improvement (637ms -> 41ms for 1M events)

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:38:42 +00:00
thePR0M3TH3AN 15e5d7bcf5 Merge pull request #2215 from PR0M3TH3AN/testing-default-client-init-1150398572683593464
🧪 Add unit tests for default NostrClient initialization
2026-02-07 19:37:32 -05:00
thePR0M3TH3AN effe152c25 Merge pull request #2214 from PR0M3TH3AN/clean-up-legacy-moderation-overrides-18282916472860729392
🧹 Remove legacy moderation overrides support
2026-02-07 19:37:23 -05:00
thePR0M3TH3AN d32ab04c50 Merge pull request #2213 from PR0M3TH3AN/add-nip07-signing-adapter-tests-7079316761627658374
🧪 Add tests for NIP-07 signing adapter factory
2026-02-07 19:37:11 -05:00
google-labs-jules[bot]andPR0M3TH3AN b094d2a035 Refactor duplicate feed refresh logic into unified refreshFeed method
- Unify `refreshForYouFeed`, `refreshKidsFeed`, `refreshExploreFeed`, and `refreshRecentFeed` into `refreshFeed(feedType, options)`.
- Update `js/app/feedCoordinator.js` to implement `refreshFeed` and use it in `loadFeedVideos`.
- Update `js/app.js` to delegate specific methods to `refreshFeed`.
- Add `FEED_TYPES` import to `js/app.js`.
- Update `tests/app/feedCoordinator.test.mjs` to match the refactoring.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:35:47 +00:00
thePR0M3TH3AN 50ab3c7b08 Merge pull request #2209 from PR0M3TH3AN/test/relay-health-improvements-4329305953965740034
test: improve relay health service error handling and robustness
2026-02-07 19:35:37 -05:00
thePR0M3TH3AN cc4ff6ff15 Merge pull request #2211 from PR0M3TH3AN/refactor-webtorrent-handlers-11970156008572777463
Refactor WebTorrent handlers
2026-02-07 19:34:45 -05:00
google-labs-jules[bot]andPR0M3TH3AN 5cf2b42bfd Add unit tests for dynamicStyles.js
Added a new test file `tests/designSystem/dynamicStyles.test.mjs` to cover `js/designSystem/dynamicStyles.js`.
The tests cover:
- Scope registration and ID generation.
- Stylesheet management (adoptedStyleSheets vs <style> fallback).
- Selector generation (including `&` nesting).
- Variable setting and removing.
- Scope releasing and cleanup.
- Isolation across different document instances using JSDOM.
- Edge cases like invalid selectors or missing document refs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:34:36 +00:00
thePR0M3TH3AN 2eb4087d14 Merge pull request #2207 from PR0M3TH3AN/test-card-source-visibility-16442580899049333977
test: add tests for card source visibility logic
2026-02-07 19:34:31 -05:00
thePR0M3TH3AN 02af6a3b65 Merge pull request #2208 from PR0M3TH3AN/test/discussion-count-service-coverage-11952275705207036003
feat(test): Add DiscussionCountService error handling tests
2026-02-07 19:34:18 -05:00
google-labs-jules[bot]andPR0M3TH3AN d99a5b1dca test: verify default client initialization and configuration
Add `tests/nostr/defaultClient.test.mjs` to ensure that `nostrClient` is correctly exported as a singleton, initialized with `DEFAULT_RELAY_URLS`, and registered in the client registry.
This test handles global mocks (`WebSocket`, `localStorage`) via dynamic imports to verify the module's top-level execution.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:33:37 +00:00
google-labs-jules[bot]andPR0M3TH3AN d4beed100a Remove legacy moderation overrides support
Removed the legacy support for version 1 moderation overrides in `js/state/cache.js`. This includes removing the `LEGACY_MODERATION_OVERRIDE_STORAGE_KEY`, the migration logic in `loadModerationOverridesFromStorage`, and the cleanup logic in `persistModerationOverridesToStorage`.
Updated `tests/state/cache.test.mjs` to include tests verifying that legacy overrides are ignored and not migrated.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:33:27 +00:00
google-labs-jules[bot]andPR0M3TH3AN 0020759231 Add tests for NIP-07 signing adapter factory
- Implements `createNip07SigningAdapter` in `js/auth/signingAdapter.js`.
- Adds unit tests in `tests/auth/signingAdapter.test.mjs` verifying explicit extension handling and window fallback.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:33:13 +00:00
thePR0M3TH3AN 5a1f28d8d5 Merge pull request #2206 from PR0M3TH3AN/test/grid-health-prioritization-7598004344208681336
test: improve gridHealth prioritization testing
2026-02-07 19:30:01 -05:00
google-labs-jules[bot]andPR0M3TH3AN b2eedb46df Refactor WebTorrent handlers to reduce duplication
- Merged `handleChromeTorrent` and `handleFirefoxTorrent` into `handleTorrentStream` with a `context` parameter.
- Preserved browser-specific logic (CORS workaround for Chrome, highWaterMark for Firefox).
- Added `tests/webtorrent-handlers.test.mjs` to cover the refactored logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:27:41 +00:00
google-labs-jules[bot]andPR0M3TH3AN 596da72cb1 test: improve relay health service error handling and robustness
- Adds a default connection timeout of 5000ms to `RelayHealthService.checkRelay`.
- Adds comprehensive tests for `RelayHealthService` covering:
    - Connection timeouts (mocked).
    - Failure thresholds for user logging.
    - Logging cooldowns (mocked time).
    - Relay `disconnect` and `error` event handling.
    - `nostrClient.markRelayUnreachable` integration.
- Refactors tests to use manual mocking for `setTimeout` and `Date.now` for stability.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:25:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1ac9fee2ed feat(test): Add DiscussionCountService error handling tests
Add comprehensive tests for `DiscussionCountService` focusing on error handling, input validation, and caching.
- Covers happy path, partial results, and unsupported relays.
- Validates graceful degradation when `nostrClient` calls fail.
- Ensures no regression in service functionality.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:24:54 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8c8b8fb29a test: add tests for card source visibility logic
- 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]>
2026-02-08 00:23:56 +00:00
google-labs-jules[bot]andPR0M3TH3AN a7d19fc1db test: improve gridHealth prioritization testing
- Extract `prioritizeEntries` logic to `js/gridHealthLogic.js` for testability
- Add comprehensive unit tests in `tests/grid-health.test.mjs`
- Improve `getIntersectionRect` to robustly handle invalid rects
- Ensure 0x0 rects are filtered out explicitly

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:22:16 +00:00
thePR0M3TH3AN 5188cfabf7 Merge pull request #2205 from PR0M3TH3AN/add-count-diagnostics-tests-5953252333821392151
🧪 Add tests for count diagnostics
2026-02-07 19:20:48 -05:00
thePR0M3TH3AN 566c2dbf89 Merge pull request #2204 from PR0M3TH3AN/test/video-pointer-tests-15855649223064850700
Add unit tests for videoPointer.js
2026-02-07 19:15:03 -05:00
thePR0M3TH3AN f0363ecf4c Merge branch 'unstable' into add-count-diagnostics-tests-5953252333821392151 2026-02-07 19:14:21 -05:00
thePR0M3TH3AN 6001b44c28 Merge pull request #2200 from PR0M3TH3AN/test/count-diagnostics-coverage-4678245393880204618
🧪 Add tests for count diagnostics
2026-02-07 19:12:41 -05:00
thePR0M3TH3AN 329ce5d842 Merge pull request #2203 from PR0M3TH3AN/test/max-listener-diagnostics-11773877660411760257
test: add tests for max listener diagnostics logic
2026-02-07 19:10:02 -05:00
google-labs-jules[bot]andPR0M3TH3AN 1cedccbdf3 Add tests for count diagnostics
Added `tests/nostr/countDiagnostics.test.mjs` to test `js/nostr/countDiagnostics.js`.
Covered `isVerboseDiagnosticsEnabled` logic, including `window` overrides and fallback.
Covered `logRelayCountFailure` and other logging functions, verifying message content, throttling, and error suppression.
Ensured that logging respects the verbose mode flag.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:09:19 +00:00
google-labs-jules[bot]andPR0M3TH3AN 01005eacb9 test(utils): add unit tests for videoPointer.js resolution logic
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]>
2026-02-08 00:05:18 +00:00
google-labs-jules[bot]andPR0M3TH3AN ab75153e0b test: add tests for max listener diagnostics logic
Exports `collectCandidateStrings` and `shouldSuppressWarning` from `js/nostr/maxListenerDiagnostics.js` to enable unit testing.
Adds `tests/nostr/maxListenerDiagnostics.test.mjs` to test the warning suppression logic and verify the `process.emitWarning` patch side effect.
Fixes missing `jsdom` dependency issue by running `npm install`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:57:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN 549b184861 Add unit tests for count diagnostics module
Added a new test file `tests/nostr/countDiagnostics.test.mjs` to cover:
- `isVerboseDiagnosticsEnabled` configuration flag logic.
- Logging behavior for count failures (relay, timeout, rebroadcast, view).
- Throttling logic to ensure repeated warnings are suppressed.
- Error suppression for connection failures.

The tests use module reloading with cache busting to ensure isolation between test cases, as the module maintains internal state (`seenWarningKeys`).
Mocks `console.warn` to verify logging output without polluting stdout.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:51:47 +00:00
google-labs-jules[bot]andPR0M3TH3AN 24402792a8 test: add unit tests for exploreDataService.js
- Add `tests/services/exploreDataService.test.mjs` to test `buildWatchHistoryTagCounts`.
- Mock global `Worker` to simulate worker behavior.
- Mock `console.warn` to verify error logging and suppression.
- Use dynamic import to handle `devLogger` initialization dependent on global flags.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:51:11 +00:00
thePR0M3TH3AN 9110f1762b Merge pull request #2195 from PR0M3TH3AN/tests/zap-helpers-coverage-11165774273391187280
test: add unit tests for zap helpers
2026-02-07 18:22:25 -05:00
thePR0M3TH3AN 8ccf0dc8e1 Merge pull request #2187 from PR0M3TH3AN/test-improvement/comment-avatar-resolution-2019846885315383708
🧪 Add unit tests for comment avatar resolution
2026-02-07 18:20:08 -05:00
thePR0M3TH3AN b549069fc4 Merge pull request #2194 from PR0M3TH3AN/refactor/feed-coordinator-load-logic-7944534665779205819
🧹 Refactor feed loading logic into shared loadFeedVideos method
2026-02-07 18:19:51 -05:00
thePR0M3TH3AN 340e4cc50a Merge pull request #2191 from PR0M3TH3AN/ai/test-video-menu-renderers-13178145676174629231
🧪 Add tests for video menu renderers
2026-02-07 18:19:00 -05:00
thePR0M3TH3AN c290959a7e Merge pull request #2192 from PR0M3TH3AN/perf/batch-profile-refresh-14711465702211977594
⚡ Optimize profile refreshing with batch requests
2026-02-07 18:18:50 -05:00
google-labs-jules[bot]andPR0M3TH3AN 1fa72709d9 test: add unit tests for zap helpers
Add comprehensive unit tests for `js/ui/dm/zapHelpers.js` in `tests/ui/dm/zapHelpers.test.mjs`.

- Covers `formatZapAmount` for standard and compact notation.
- Covers `aggregateZapTotals` for aggregation logic and edge cases.
- Covers `normalizeZapReceipt` for input normalization.
- Ensures robust handling of invalid inputs (NaN, null, etc.).

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:18:40 +00:00
thePR0M3TH3AN 85b0c2640f Merge pull request #2190 from PR0M3TH3AN/test-dom-utils-8159522647333333512
test(utils): add unit tests for domUtils
2026-02-07 18:18:10 -05:00
google-labs-jules[bot]andPR0M3TH3AN afd64ba1ce Refactor feed loading logic into shared loadFeedVideos method
- Introduce `loadFeedVideos(feedType, forceFetch)` in `js/app/feedCoordinator.js` to consolidate video loading logic.
- Update `loadForYouVideos`, `loadKidsVideos`, `loadExploreVideos`, and `loadVideos` to use the shared method.
- Parameterize feed-specific configuration (telemetry context, tags, loading messages, relay health checks) based on feed type.
- Add `tests/app/feedCoordinator.test.mjs` to verify the new logic.

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:15:56 +00:00