Skip to content

fix(mock-client): unify mock client implementation and add pagination support (#588) - #620

Open
ravendevhub wants to merge 2 commits into
Sorokit:mainfrom
ravendevhub:fix/mock-client-pagination-588
Open

fix(mock-client): unify mock client implementation and add pagination support (#588)#620
ravendevhub wants to merge 2 commits into
Sorokit:mainfrom
ravendevhub:fix/mock-client-pagination-588

Conversation

@ravendevhub

Copy link
Copy Markdown

Summary

Resolves #588 by consolidating the mock client implementation in src/lib/mock-client.ts, adding proper pagination slicing to getHistory, isolating instance state, and ensuring main.tsx uses the canonical createMockClient factory.

Changes

  1. Pagination Support in getHistory:
    • Updated MOCK_HISTORY generation to 25 items so multi-page pagination can be exercised.
    • Sliced transactions in getHistory using page (1-indexed) and limit.
    • Returned accurate total count (MOCK_HISTORY.length) to enable page calculations in TransactionHistory.
  2. State Isolation:
    • Enclosed mutable variables (activeNetwork, connectedAddress) within the createMockClient() closure, eliminating module-level state cross-contamination between test cases.
  3. Documentation:
    • Added JSDoc explaining the canonical mock client architecture and strategy.
  4. Unit Tests:
    • Added unit tests in src/lib/mock-client.test.ts and src/lib/__tests__/mock-client.test.ts covering multi-page pagination slicing, distinct page datasets, and instance state isolation.

Acceptance Criteria

  • There is exactly one source of mock client data (mock-client.ts)
  • mock-client.ts is actively imported and used by main.tsx
  • getHistory respects page and limit (page 2 returns different results than page 1)
  • TransactionHistory Prev/Next pagination buttons navigate through distinct pages of data
  • The chosen approach is documented with a comment explaining the mock strategy

… support (Sorokit#588)

- Update MOCK_HISTORY to generate 25 deterministic transaction records for multi-page pagination testing
- Implement page and limit slicing in getHistory to support TransactionHistory page navigation
- Scope mutable state (activeNetwork, connectedAddress) to instance closures within createMockClient to prevent cross-test contamination
- Document mock strategy clearly in mock-client.ts
- Add unit tests verifying pagination slicing across multiple pages and instance isolation
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.

mock-client.ts is dead code — inline adapter in main.tsx duplicates it without pagination support

1 participant