Commit Graph
5095 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN 555df62529 fix: resolve SyntaxError in js/app.js due to duplicate code block
Removed a duplicate/malformed code block in `js/app.js` that was causing `SyntaxError: Unexpected token '.'` during module loading. This error was breaking tests in `tests/app/channel-profile-moderation.test.mjs` and others.

Also restored `_initNostr` and `_initSessionActor` methods which were partially clobbered or malformed in the file structure.

Verified by running the affected unit tests locally.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:50:26 +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
thePR0M3TH3AN cc2e29c185 Merge pull request #2202 from PR0M3TH3AN/chore/code-health/remove-unused-promises-app-init-18262315909809877684
chore: remove dead code and unused promises in Application.init
2026-02-07 20:07:29 -05:00
thePR0M3TH3AN ae5174600d Merge branch 'unstable' into chore/code-health/remove-unused-promises-app-init-18262315909809877684 2026-02-07 20:07:22 -05: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
thePR0M3TH3AN d65b26e892 Merge pull request #2219 from PR0M3TH3AN/refactor-app-init-2582209971545822131
🧹 Refactor Application.init for improved readability
2026-02-07 19:40:25 -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 23b9e36958 Refactor Application.init method to improve readability and maintainability.
- Extracted logic into `_init*` private helper methods.
- Preserved execution order and async behavior.
- Cleaned up the main `init` method to act as an orchestrator.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:36:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN bcacf46f8b Refactor Application to delegate state management to services
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:36:05 +00: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
thePR0M3TH3AN a1d6ef31b9 Merge pull request #2210 from PR0M3TH3AN/refactor-build-comment-event-3814978219549166211
Refactor buildCommentEvent logic
2026-02-07 19:34:04 -05:00
thePR0M3TH3AN 15648a5cae Merge pull request #2212 from PR0M3TH3AN/nip46-logging-refactor-8970006357846081703
🧹 Extract NIP-46 logging helpers to utility module
2026-02-07 19:33:49 -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 c32e95f372 Refactor NIP-46 logging helpers to dedicated utility module
Moved logging helpers (`summarizeHexForLog`, `summarizeSecretForLog`, etc.) from `js/nostr/nip46Client.js` to `js/nostr/nip46LoggingUtils.js` to reduce clutter and improve reuse. Updated `js/nostr/client.js` and `js/services/authProviders/nip46.js` to import from the new module, removing duplicate definitions in the latter. Verified with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:27:45 +00: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 75753b92fd Refactor buildCommentEvent to use helper functions
Extracted parameter normalization, context resolution, and tag building into dedicated helper functions (`normalizeCommentInputs`, `resolveCommentContext`, `buildCommentTags`) to improve readability and maintainability of `buildCommentEvent`. This simplifies the main function logic and makes it easier to test individual components in the future if exported.

No functional changes intended. Verified with existing unit and integration tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:26:53 +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 8108e3dcb7 Merge pull request #2198 from PR0M3TH3AN/unify-hashtag-preferences-key-9274648867585622352
Unify profile cache keys for hashtag preferences
2026-02-07 19:11:11 -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
thePR0M3TH3AN 55986e8dd2 Merge pull request #2199 from PR0M3TH3AN/test-explore-data-service-16099170843852410119
Add unit tests for exploreDataService.js
2026-02-07 19:08:03 -05: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
thePR0M3TH3AN aabf59ffe9 Merge pull request #2201 from PR0M3TH3AN/fix-load-feed-videos-crash-18410919809900626137
Fix crash in feed loading by delegating loadFeedVideos
2026-02-07 19:05:04 -05: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 12ba9f07e6 chore: remove dead code and unused promises in Application.init
Removes commented-out `await Promise.all` and refactors the associated
`accessControlPromise` and `adminPanePromise` variables in `js/app.js`.

The promises were only assigned for use in the commented-out line.
This change:
- Converts `accessControl.refresh()` to a direct expression statement.
- Simplifies `adminPanePromise` logic into a direct `if` block, removing
  the unnecessary `else { Promise.resolve(null) }` branch.
- Preserves the existing fire-and-forget behavior for these initialization tasks.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:56:45 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9571e3aedb Fix crash in feed loading by delegating loadFeedVideos
The `loadFeedVideos` method was missing from the `Application` class in `js/app.js`, but was being called by `loadVideos` inside the feed coordinator (which is bound to the application instance). This caused a `TypeError: this.loadFeedVideos is not a function` at runtime.

This change adds the missing delegation method to `Application` in `js/app.js`, forwarding the call to `this._feed.loadFeedVideos`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:55:17 +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