You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/TESTING_STRATEGY.md
+127-1Lines changed: 127 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,9 @@ This document defines how testing is split across unit, integration, and end-to-
16
16
| Unit | Pure logic, rendering branches, validation, math, and state reducers/hooks | The feature owner |`frontend/src/**/*.test.ts(x)`, `backend/src/__tests__/**/*.test.ts`, `contracts/vault/src/*_tests.rs`, `contracts/vault/src/test.rs`|`cd frontend && npm run test:run`, `cd backend && npm test`, `cargo test -p vault`|
17
17
| Integration | Module-to-module behavior, HTTP handlers, provider wiring, contract scenarios with real Soroban test env | The service or feature owner |`backend/src/__tests__/*.test.ts`, `frontend/src/tests/*.test.tsx`, `frontend/src/components/*.test.tsx`, `frontend/src/pages/*.test.tsx`, `contracts/vault/src/test.rs`| Same commands as unit, plus focused suite runs |
18
18
| E2E | Real browser journeys through the running app | The frontend feature owner, with backend support when the journey crosses APIs |`frontend/e2e/*.spec.ts`|`cd frontend && npm run test:e2e`|
19
+
| Smoke (Cypress) | Fast critical-path verification in CI before Playwright suite; wallet connect, deposit/withdraw access, transaction history | The frontend feature owner |`frontend/cypress/e2e/*.cy.ts`|`cd frontend && npm run test:cypress`|
20
+
| Load | API throughput, latency budgets, and degradation behavior under concurrent traffic | The platform/backend owner |`tests/load/*.test.js`|`k6 run tests/load/vault-load.test.js` (CI: `load-tests.yml`) |
21
+
| Contract Fuzz | Invariant-guided random input generation for Soroban contract math and state transitions | The contract feature owner |`contracts/vault/fuzz/`, `contracts/vault/src/fuzz_math.rs`, `contracts/vault/src/deposit_withdraw_props.rs`|`cargo test -p vault`, `cargo fuzz run share_price_math`|
19
22
20
23
## Ownership Rules
21
24
@@ -99,10 +102,14 @@ Use E2E tests only for user journeys that must prove the app works in a real bro
99
102
- Cross-layer behavior has at least one deterministic integration test.
100
103
- Browser-only flows have at least one Playwright test.
101
104
- New feature work adds coverage in the layer that owns the behavior, not just in the widest suite.
105
+
- New UI components include an `axe-core` accessibility audit in their test suite.
106
+
- Security-sensitive changes add or update tests in the relevant security test files.
107
+
- Contract math changes include proptest or fuzz coverage for the affected invariants.
108
+
- Load test thresholds are reviewed when API contracts change (endpoint shape, latency budgets).
102
109
103
110
## Repository Enforcement
104
111
105
-
This strategy is enforced with the repository validator at `npm run validate:testing-strategy`. The command checks that the strategy document still covers the required testing layers, layer-specific guidance, recommended commands, and Playwright-based E2E coverage expectations.
112
+
This strategy is enforced with the repository validator at `npm run validate:testing-strategy`. The command checks that the strategy document still covers the required testing layers, layer-specific guidance, recommended commands, Playwright-based E2E coverage expectations, accessibility testing, security testing, load testing, fuzz/property-based testing, CI pipeline integration, coverage thresholds, and the tools & frameworks overview.
106
113
107
114
## Core Playwright User Flows
108
115
@@ -119,6 +126,125 @@ Canonical browser journeys live under `frontend/e2e/` and run with `cd frontend
119
126
120
127
Shared stubs and Freighter mocking belong in `frontend/e2e/fixtures.ts` so every core flow stays deterministic without a live backend.
121
128
129
+
## Cypress Smoke Suite
130
+
131
+
Cypress smoke tests (`frontend/cypress/e2e/smoke.cy.ts`) provide a lightweight first-pass verification that critical user journeys are not broken. They run faster than the full Playwright suite and are intended as a CI gate before heavier E2E work.
132
+
133
+
| Scenario | What it proves |
134
+
| --- | --- |
135
+
| Wallet connection | The Freighter message protocol stub returns a connected state visible in the UI |
136
+
| Deposit navigation | The deposit CTA is reachable from the dashboard |
137
+
| Withdrawal navigation | The withdrawal CTA is reachable from the dashboard |
138
+
| Transaction history | The `/transactions` route renders a table, empty state, or wallet prompt |
139
+
140
+
Unlike Playwright, Cypress tests use `cy.intercept()` for API mocking and run inside the same browser event loop. Use Cypress for fast smoke-gating; use Playwright for full multi-tab, multi-origin browser journeys.
141
+
142
+
## Accessibility Testing
143
+
144
+
Accessibility tests live in `frontend/src/tests/accessibility.test.tsx` and use `axe-core` to audit rendered component trees for WCAG violations. These tests are part of the frontend unit/integration suite (`cd frontend && npm run test:run`).
145
+
146
+
- Every new UI component that renders interactive elements must include an `axe-core` audit in its test suite.
147
+
- Focus on critical violations (`critical` and `serious` impact levels).
148
+
- Use `@testing-library/react` queries that mirror real user interactions (role-based selectors, accessible names).
149
+
- The accessibility test suite covers: dashboard, deposit/withdraw forms, transaction history, settings, and navigation.
150
+
151
+
## Security Testing
152
+
153
+
Security-focused tests validate defenses against common vulnerability classes:
154
+
155
+
| Test file | Coverage |
156
+
| --- | --- |
157
+
|`frontend/src/tests/xss-prevention.test.tsx`| XSS vectors in user-supplied input, URL parameters, and rendered output |
0 commit comments