Skip to content

Add validation tests and coverage improvements for Send and feature flows#1222

Open
Bluuefanatic wants to merge 10 commits into
joinmarket-webui:v2from
Bluuefanatic:jam-competency-test
Open

Add validation tests and coverage improvements for Send and feature flows#1222
Bluuefanatic wants to merge 10 commits into
joinmarket-webui:v2from
Bluuefanatic:jam-competency-test

Conversation

@Bluuefanatic
Copy link
Copy Markdown

Summary

This PR improves test coverage for critical wallet flows in Jam, with a focus on Send validation logic and feature flag evaluation.

It also introduces a minimal refactor to make validation logic testable without altering existing behavior.


Key Changes

1. Validation Refactor (Minimal, Non-breaking)

  • Extracted validation schema logic from:
    src/components/send/SendForm.tsx

  • Into a dedicated module:
    src/components/send/sendValidationSchema.ts

  • Behavior remains unchanged; logic is now reusable and testable in isolation.


2. Added Validation Tests

Send Form Validation

SendForm.validation.test.ts

Covers:

  • Address validation
    (valid, malformed, null/undefined, wrong network)
  • Amount validation
    (positive, zero, negative, NaN, large values)
  • Sweep mode behavior
  • Collaborator constraints
    (boundaries and malformed inputs)

Collaborative Send Validation

collaborativeSend.validation.test.ts

Covers:

  • Request-level validation
  • Invalid inputs
    (NaN, null, malformed values)
  • Sweep behavior (amount_sats = 0)
  • Collaborator constraints and edge cases

3. Feature Flag Tests (Adapted to v2)

The file src/constants/features.ts referenced in the task is not present in the v2 branch.

Feature logic is currently implemented via:

  • src/hooks/useFeatures.ts
  • src/constants/debugFeatures.ts

Tests were added to validate:

  • Enabled/disabled feature states
  • Missing or undefined feature flags
  • Developer/debug overrides

4. Coverage Improvements

  • Added comprehensive edge-case testing for validation logic
  • Focused on safety-critical paths affecting transaction correctness

Notes

  • Referenced files (helpers.ts, features.ts) are not present in v2
  • Testing approach was adapted to match the current architecture
  • Validation logic was minimally extracted strictly for testability
  • No behavioral changes were introduced

Why This Matters

Jam handles real Bitcoin transactions, where validation errors can lead to:

  • Incorrect transaction construction
  • Invalid collaborator configurations
  • Unintended fund behavior

Improving test coverage for these flows reduces regression risk and increases overall reliability.


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.

1 participant