Skip to content

test(components): add Vitest unit tests for GroupCard, ContributionFo…#945

Merged
Xoulomon merged 1 commit into
Xoulomon:mainfrom
kimanicode:issue/876-frontend-component-tests
May 30, 2026
Merged

test(components): add Vitest unit tests for GroupCard, ContributionFo…#945
Xoulomon merged 1 commit into
Xoulomon:mainfrom
kimanicode:issue/876-frontend-component-tests

Conversation

@kimanicode
Copy link
Copy Markdown
Contributor

Summary

Implements Vitest + React Testing Library unit tests for GroupCard, ContributionFlow, and TransactionHistory. 90 tests across 3 suites, all passing, with enforced coverage thresholds of ≥80% lines/functions and ≥70% branches.

Motivation

No frontend component tests existed for the three major UI components. This adds a reliable, fast test suite that mocks all external dependencies (Soroban RPC, Horizon, wallet hooks) so component logic can be verified in isolation.

Closes #876

Type of change

  • feat — new feature
  • fix — bug fix
  • docs — documentation only
  • refactor — code restructuring, no behaviour change
  • test — tests only
  • chore — build, deps, tooling
  • perf — performance improvement
  • Breaking change (existing behaviour changes)

Changes

  • frontend/src/test/GroupCard.test.tsx — 39 tests: static mode (all original tests preserved), fetch mode (loading/error/success via React Query), edge cases (description, image, className, status variants)
  • frontend/src/test/ContributionFlow.test.tsx — 35 tests: initial state, validation, quick-select chips, confirmation dialog, success flow, error/retry, disabled state, custom min/max, onError callback
  • frontend/src/test/TransactionHistory.test.tsx — 16 tests: no-wallet state, type filter, Horizon fetch success/error/empty, custom address/contractId/pageSize/network
  • frontend/vitest.config.ts — added coverage thresholds and ESM aliases for @creit.tech/stellar-wallets-kit/modules/*

Note: ContributionForm does not exist in this codebase — tests target ContributionFlow.tsx as the functional equivalent.

Testing

Smart contract:

cargo test -p stellar-save

Frontend:

cd frontend && npm run test

Coverage report:

cd frontend && npx vitest run --coverage

Expected: ≥80% lines, ≥80% functions, ≥70% branches across all three components.

Manual steps:

  1. All 90 tests pass with no failures
  2. Coverage thresholds enforced in vitest.config.ts — CI will fail if they regress

Checklist

  • cargo fmt run (Rust changes)
  • cargo clippy -- -D warnings passes (Rust changes)
  • npm run lint passes (frontend changes)
  • Tests added or updated for new/changed behaviour
  • CI is green
  • Documentation updated (if behaviour changed)
  • No secrets or .env files staged

Screenshots / recordings

N/A — test-only change, no UI modifications.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@kimanicode Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Xoulomon Xoulomon merged commit 5c084d5 into Xoulomon:main May 30, 2026
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.

[Testing] Implement frontend component tests with Vitest

2 participants