Getting Started
- Fork the repository: https://github.com/JointSave-org/Joint_Save
- Clone your fork:
git clone https://github.com/<your-username>/Joint_Save.git
cd Joint_Save
- Create a new branch:
git checkout -b test/component-test-suite
Overview
The frontend currently has unit tests for lib/ utilities (6 files) and hooks/use-keyboard-shortcuts.test.ts, plus 5 Playwright E2E specs, but zero React component tests. ARCHITECTURE.md explicitly marks "Component Tests" as future work. The useJointSaveContracts hook (1435 lines), PoolDataProvider, TransactionRecoveryProvider, and OptimisticTransactions are all untested at the component level. This means regressions in rendering logic, state management, and user interaction handling are only caught by E2E tests (which are slow and flaky by nature) or manual testing.
This issue establishes the React Testing Library infrastructure and writes component tests for the most critical, regression-prone UI flows.
Requirements
Test Infrastructure Setup
- Install
@testing-library/react, @testing-library/user-event, @testing-library/jest-dom, msw (Mock Service Worker) for API mocking, and vitest (or configure Jest with the existing setup if Jest is preferred — check package.json for the current test runner)
- Create
frontend/test-utils.tsx with a custom render function that wraps components in the necessary providers (Theme, Web3, Toast, QueryClient)
- Create
frontend/__mocks__/ directory with mocks for:
@/hooks/useJointSaveContracts — mock all sub-hooks to return deterministic state
@/lib/supabase — mock Supabase client queries
@stellar/stellar-sdk — mock rpc and Server classes
@creit.tech/stellar-wallets-kit — mock wallet connection
Test Coverage Priorities (write tests for these components)
Critical Path Components:
components/group/group-details.tsx — renders pool data correctly, shows loading state, handles empty state, displays correct pool type badge, copy-to-clipboard works
components/group/group-actions.tsx — admin-only actions are visible/hidden correctly, pause/unpause toggle reflects contract state, deposit/withdraw buttons are disabled when appropriate
components/create-group/flexible-form.tsx (and rotational/target variants) — form validation works, submit handler is called with correct args, error states display
app/dashboard/group/[id]/page.tsx — pool not found state, loading skeleton, correct tab rendering
State Management Components:
5. components/web3-provider.tsx — wallet connection/disconnection flow, network detection
6. lib/data-layer/PoolDataProvider.tsx — background polling starts/stops, stale-while-revalidate works, error state propagation
7. hooks/useOptimisticTransactions.ts — optimistic state applied on submit, rolled back on error, cleared on success
Utility-Heavy Components:
8. components/dashboard/transactions.tsx — CSV export generates correct data, filter/sort works, empty state renders
9. components/dashboard/yield-dashboard.tsx — yield data displays correctly, harvest button enabled/disabled based on deployed amount
Test Quality Standards
- Each test file should have a descriptive name matching the component
- Use
describe blocks to group related tests by feature/behavior
- Prefer
getByRole, getByText, getByLabelText over getByTestId (test accessibility)
- Mock only external dependencies (wallet, RPC, Supabase), not internal state logic
- Include at least one integration-style test per critical path (e.g., "user clicks deposit → loading state → success toast")
CI Integration
- Add a new GitHub Actions workflow step (or extend the existing one) to run component tests on every PR
- Component tests should complete in under 60 seconds total (they run in jsdom, not a browser)
Acceptance Criteria
Getting Started
Overview
The frontend currently has unit tests for
lib/utilities (6 files) andhooks/use-keyboard-shortcuts.test.ts, plus 5 Playwright E2E specs, but zero React component tests. ARCHITECTURE.md explicitly marks "Component Tests" as future work. TheuseJointSaveContractshook (1435 lines),PoolDataProvider,TransactionRecoveryProvider, andOptimisticTransactionsare all untested at the component level. This means regressions in rendering logic, state management, and user interaction handling are only caught by E2E tests (which are slow and flaky by nature) or manual testing.This issue establishes the React Testing Library infrastructure and writes component tests for the most critical, regression-prone UI flows.
Requirements
Test Infrastructure Setup
@testing-library/react,@testing-library/user-event,@testing-library/jest-dom,msw(Mock Service Worker) for API mocking, andvitest(or configure Jest with the existing setup if Jest is preferred — checkpackage.jsonfor the current test runner)frontend/test-utils.tsxwith a customrenderfunction that wraps components in the necessary providers (Theme, Web3, Toast, QueryClient)frontend/__mocks__/directory with mocks for:@/hooks/useJointSaveContracts— mock all sub-hooks to return deterministic state@/lib/supabase— mock Supabase client queries@stellar/stellar-sdk— mockrpcandServerclasses@creit.tech/stellar-wallets-kit— mock wallet connectionTest Coverage Priorities (write tests for these components)
Critical Path Components:
components/group/group-details.tsx— renders pool data correctly, shows loading state, handles empty state, displays correct pool type badge, copy-to-clipboard workscomponents/group/group-actions.tsx— admin-only actions are visible/hidden correctly, pause/unpause toggle reflects contract state, deposit/withdraw buttons are disabled when appropriatecomponents/create-group/flexible-form.tsx(and rotational/target variants) — form validation works, submit handler is called with correct args, error states displayapp/dashboard/group/[id]/page.tsx— pool not found state, loading skeleton, correct tab renderingState Management Components:
5.
components/web3-provider.tsx— wallet connection/disconnection flow, network detection6.
lib/data-layer/PoolDataProvider.tsx— background polling starts/stops, stale-while-revalidate works, error state propagation7.
hooks/useOptimisticTransactions.ts— optimistic state applied on submit, rolled back on error, cleared on successUtility-Heavy Components:
8.
components/dashboard/transactions.tsx— CSV export generates correct data, filter/sort works, empty state renders9.
components/dashboard/yield-dashboard.tsx— yield data displays correctly, harvest button enabled/disabled based on deployed amountTest Quality Standards
describeblocks to group related tests by feature/behaviorgetByRole,getByText,getByLabelTextovergetByTestId(test accessibility)CI Integration
Acceptance Criteria
npm run test:components(or equivalent script) runs all component tests and passestest-utils.tsxprovides a reusable render wrapper with all required providers__mocks__/and shared across test files@ts-ignoreor@ts-expect-errorto suppress type errors