Skip to content

Add comprehensive test coverage for bookmarks, crypto, and signaling#37

Merged
pheuberger merged 1 commit intomainfrom
claude/add-unit-tests-9dnoM
Feb 6, 2026
Merged

Add comprehensive test coverage for bookmarks, crypto, and signaling#37
pheuberger merged 1 commit intomainfrom
claude/add-unit-tests-9dnoM

Conversation

@pheuberger
Copy link
Copy Markdown
Owner

Summary

This PR adds extensive test coverage for three critical service modules: bookmark validation, cryptographic conversions, and WebSocket signaling. The new tests ensure data integrity across encryption pipelines, proper message routing, and robust bookmark handling.

Key Changes

Bookmarks Service Tests (bookmarks.test.js)

  • Inbox items: Added 5 tests validating that inbox items can have empty/missing titles while regular bookmarks require titles
  • Favicon and preview fields: Added 4 tests ensuring these optional fields are properly passed through or default to null
  • Tag edge cases: Added 4 tests covering non-string values, non-array inputs, trimming/lowercasing, and deduplication behavior
  • URL normalization edge cases: Added 4 tests for encoded characters, multiple query parameters, internationalized domains, and very long paths

Crypto Conversion Utilities Tests (crypto-conversions.test.js) - NEW FILE

  • Base64 conversions: 6 tests validating base64↔Uint8Array/ArrayBuffer conversions with edge cases (empty, padding, all byte values 0-255)
  • Round-trip integrity: 8 tests ensuring data survives multiple encoding/decoding cycles (critical for encrypted data)
  • Cross-function compatibility: 4 tests verifying string→buffer→base64→buffer→string pipelines work correctly
  • Random byte generation: 4 tests validating cryptographic randomness and proper Uint8Array returns
  • 284 total lines covering the exact conversion paths used in encryption operations

Signaling Service Tests (signaling.test.js) - NEW FILE

  • Utility functions: 3 tests for getPairingRoomName and getSignalingUrl helpers
  • SignalingClient initialization: 8 tests verifying proper default state (disconnected, empty subscriptions, no pending messages)
  • Subscription management: 6 tests for subscribe/unsubscribe with multiple callbacks and topics
  • Message publishing: 4 tests covering queuing behavior when disconnected and direct sending when connected
  • Message routing: 10 tests ensuring messages reach correct topic subscribers, handle malformed JSON, and prevent callback errors from crashing others
  • Connection cleanup: 7 tests validating close() properly clears state and can be called multiple times
  • WebSocket state handling: 5 tests for _send() respecting WebSocket readyState
  • Integration tests: 3 tests verifying subscribe→unsubscribe→handleMessage workflows
  • 599 total lines with deterministic, non-flaky tests avoiding real WebSocket connections

Notable Implementation Details

  • Crypto tests focus on the exact byte sequences used in AES-256 encryption (32-byte keys, 12-byte IVs) to catch silent data corruption
  • Signaling tests use mocked WebSocket instances and vi.fn() callbacks to test pure logic without timing dependencies
  • All tests are deterministic and can run in any order without side effects
  • Tests document the critical paths: encryption round-trips, message routing, and subscription lifecycle

https://claude.ai/code/session_014P4FqiX28FYRq7h2V4Dves

…ions

- bookmarks.test.js: inbox validation (title optional for inbox items),
  favicon/preview field passthrough, tag edge cases (non-string values,
  non-array input), URL normalization edge cases (encoded chars, IDN)
- signaling.test.js: SignalingClient message routing, subscription
  management, publish queueing, _send state guards, close cleanup,
  subscribe/unsubscribe/handleMessage integration, getPairingRoomName
  and getSignalingUrl utilities
- crypto-conversions.test.js: base64ToUint8Array (previously untested),
  round-trip integrity for all buffer conversion functions including
  cross-function pipelines (string->buffer->base64->Uint8Array),
  binary data with all 256 byte values, crypto-sized buffers (32B key,
  12B IV)

https://claude.ai/code/session_014P4FqiX28FYRq7h2V4Dves
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 5, 2026

Deploy Preview for hypermarkk ready!

Name Link
🔨 Latest commit 40beb02
🔍 Latest deploy log https://app.netlify.com/projects/hypermarkk/deploys/6985204adebe7400085a0ee0
😎 Deploy Preview https://deploy-preview-37--hypermarkk.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pheuberger pheuberger merged commit 473109b into main Feb 6, 2026
7 checks passed
@pheuberger pheuberger deleted the claude/add-unit-tests-9dnoM branch February 6, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants