Skip to content

test: add comprehensive test coverage for untested modules#225

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/analyze-test-coverage-and-add-tests
Draft

test: add comprehensive test coverage for untested modules#225
Copilot wants to merge 1 commit intomainfrom
copilot/analyze-test-coverage-and-add-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

Summary

This PR significantly improves test coverage by adding new test files for previously untested modules and extending existing test files with additional edge cases.

Before: 84 passing tests across 5 files
After: 218 passing tests across 10 files

New Test Files

  • src/backend/networking/utils.test.tsisAllowedPeer, isPeerLocalHostname, and PEER_PORT_MIN/MAX constants (port range policy, localhost exemption)
  • src/backend/StatsPulseHistory.test.ts — Pulse recording, DL/UL totals, timestamp validity, partial connection data, immutable getHistory() copy
  • src/backend/RequestManager.test.ts — Register/resolve/close lifecycle, nonce sequencing, timeout behavior, average latency tracking, double-resolve protection
  • src/backend/storage/FSMap.test.ts — CRUD operations, disk persistence, iteration (keys, values, entries, forEach), getOrInsert, getOrInsertComputed, cross-instance persistence
  • src/backend/networking/udp/helpers.test.tshandleAwaiter (matching, non-matching, done/not-done), handleInvalidUsernameError (various malformed inputs), tryDecodeMessage, tryParseError

Extended Test Files

  • src/utils/log.test.ts — Added formatBytes, formatUptime, truncateAddress, exceptionFromContext, logContext tests
  • src/backend/protocol/DHT.test.ts — Added BinaryString, BinaryHex, BaseMessage, ErrorMessage, QueryMessage schema validation tests
  • src/backend/versioning.test.ts — Added edge cases: empty string, separator at boundaries, whitespace trimming, deep branch names, v-prefix on both sides

Validation

  • ✅ 218 tests pass, 0 fail (5 pre-existing skips unchanged)
  • ✅ ESLint clean
  • ✅ TypeScript type check clean
  • ✅ CodeQL: 0 alerts

- Add networking/utils.test.ts: isAllowedPeer, isPeerLocalHostname, port constants
- Add StatsPulseHistory.test.ts: pulse recording, totals, timestamps, immutability
- Add RequestManager.test.ts: register/resolve/close, timeouts, nonce sequencing
- Add storage/FSMap.test.ts: CRUD, persistence, iteration, getOrInsert variants
- Add networking/udp/helpers.test.ts: handleAwaiter, handleInvalidUsernameError, tryDecodeMessage, tryParseError
- Extend log.test.ts: formatBytes, formatUptime, truncateAddress, exceptionFromContext, logContext
- Extend DHT.test.ts: BinaryString, BinaryHex, BaseMessage, ErrorMessage, QueryMessage schemas
- Extend versioning.test.ts: parseHydrabaseUserAgent and compareVersions edge cases

Total: 218 tests pass (up from 84)

Agent-Logs-Url: https://github.com/QuixThe2nd/Hydrabase/sessions/e7003268-2ac4-468e-b4ae-dc4fbca36f8d
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