- Implements `toLightweightVideo` helper in `js/services/exploreDataService.js` to strip large fields (content, signatures, etc.) from video objects before sending to the worker.
- Updates `buildWatchHistoryTagCounts` and `buildTagIdf` to use lightweight objects.
- Adds `tests/services/exploreDataService.optimization.test.mjs` to verify correctness.
- Adds `benchmarks/worker_transfer_lightweight_bench.js` demonstrating ~40% improvement in transfer time.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Refactor `S3UploadService` to accept dependencies in constructor
- Move `resolveUploadIdentifier` to class method for mocking
- Add comprehensive unit tests for `S3UploadService` covering event emitter, validation, and upload logic
- Ensure `WebTorrent` dependency is mocked or polyfilled in test environment
Co-authored-by: PR0M3TH3AN <[email protected]>
Adds a new test file `tests/services/trustBootstrap.test.mjs` to cover the functionality of `bootstrapTrustedSeeds` in `js/services/trustBootstrap.js`.
The test suite covers:
- Feature flag validation
- Successful seed application when access control is ready
- Subscription to access control changes
- Fallback/timeout handling for access control readiness
- Retry logic for relay readiness
Uses `node:test` and mocks dependencies `accessControl`, `moderationService`, `nostrService` via dynamic imports to handle singleton instantiation side effects.
Co-authored-by: PR0M3TH3AN <[email protected]>
Added focused unit tests for three core modules to improve coverage:
- `js/services/authUtils.js`: Tested `normalizeProviderId` and `normalizeAuthType`.
- `js/nostr/decryptionSchemeCache.js`: Tested caching logic, TTL expiration, and cache clearing.
- `js/nostr/videoPayloadBuilder.js`: Tested payload extraction and event preparation, including NIP-71 metadata handling.
Tests use `node:test` and `node:assert/strict` and are integrated into the existing test suite.
Co-authored-by: PR0M3TH3AN <[email protected]>
- 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]>
- 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]>
This update aligns `tests/services/relay-health-service.test.mjs` with the actual state object structure used in `RelayHealthService`, which now includes `consecutiveFailures` and `lastUserLogAt` properties. This fixes a CI failure in the `agent-review` job.
The previous fix for `tests/app-batch-fetch-profiles.test.mjs` (duplicate variable) is also included in this branch history.
Co-authored-by: PR0M3TH3AN <[email protected]>
Wraps the `respects TTL` test body in a `try...finally` block to ensure `expiredService.db` is closed even if assertions fail, preventing `fake-indexeddb` from hanging during cleanup.
Adds a small delay to the same test to ensure time advances beyond the 0ms TTL (caused by negative TTL clamping), fixing a flaky assertion failure.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Explicitly nullify `service.db` after closing to prevent reuse or stale references.
- Add `setImmediate` yield in `t.afterEach` to allow `fake-indexeddb` connection close events to propagate before `deleteDatabase`.
- Fixes `[LinkPreviewService Test] Database deletion blocked` causing test timeouts.
Co-authored-by: PR0M3TH3AN <[email protected]>
Restores globalThis.fetch after each test in LinkPreviewService test suite to prevent pollution of other tests with mocked implementations.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Added `DEFAULT_PLAYBACK_SOURCE` to `config/instance-config.js` to allow choosing between "url" (default) and "torrent" priority.
- Updated `js/constants.js` to derive `URL_FIRST_ENABLED` flag from the configuration.
- Refactored `PlaybackService.execute()` in `js/services/playbackService.js` to robustly support "Torrent First" logic with fallback to URL, while maintaining "URL First" with fallback to Torrent.
- Added unit tests in `tests/services/playbackService_order.test.mjs` to verify playback order and fallback mechanics.
- Format `css/tailwind.source.css` with Prettier.
- Add allowlist entry for `VideoCard.js` media query pixel value in `scripts/check-design-tokens.mjs`.
- Remove accidental artifact `js/ui/dm/jules_session_4520373547615093905.zip`.
- Fix bug in `js/app.js` and `js/services/moderationActionController.js` where blocked users' videos were not correctly hidden in the UI immediately after blocking.
- Fix bug in `tests/app/moderation-overrides.test.mjs` where `userBlocks` mocks were insufficient to reflect state changes.
- Add `tests/services/link-preview-service.test.mjs`: Tests for caching, fetching, and TTL logic using `fake-indexeddb` and `jsdom`.
- Add `tests/nostr/session-actor.test.mjs`: Tests for encryption/decryption and persistence of session actor.
- Refactor `tests/app/similar-content.test.mjs`: Update to test `SimilarContentController` directly, fixing regression caused by architectural changes.
- Ensure tests are self-contained with necessary polyfills (IndexedDB, LocalStorage).
- Added `tests/state/cache.test.mjs` to test profile persistence and URL health caching.
- Added `tests/nostr/sessionActor.test.mjs` to test session key encryption/decryption and storage.
- Added `tests/services/r2Service.test.mjs` to test R2 settings management and bucket configuration.
- Exposed `__testExports` in `js/nostr/sessionActor.js` to allow testing of private helper functions.
- Used `tests/test-helpers/setup-localstorage.mjs` to mock browser environments in all new tests.