mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Document the testing strategy and e2e conventions
An ADR records how we decide what to test and where, and a checklist lets people and agents check a change against it.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# 1. Testing strategy
|
||||
|
||||
Date: 2026-09-30
|
||||
|
||||
## Status
|
||||
|
||||
Accepted
|
||||
|
||||
## Context
|
||||
|
||||
The app has many features and few tests. We need a way to decide what to
|
||||
test, at which layer, and in what order, without trying to reach full
|
||||
coverage.
|
||||
|
||||
## Decision
|
||||
|
||||
Prioritise by risk: how bad a failure is (corrupt COB writes are worse than
|
||||
wrong display), how likely it is (complex logic, churn, crossing the Rust/TS
|
||||
boundary) and how hard it is to notice manually (multi-peer, caching,
|
||||
timing).
|
||||
|
||||
Test each behaviour at the cheapest layer that can catch its failure:
|
||||
|
||||
| Layer | Tool | Scope |
|
||||
| -------- | ----------------------------- | ------------------------------------------------------------------------ |
|
||||
| TS unit | Vitest, `tests/unit/` | Pure logic: parsing, routing, formatting, filters, diff and review logic |
|
||||
| Rust | `cargo test` | Trait default implementations, type conversions, error codes |
|
||||
| E2E | Playwright + `test-http-api` | User journeys and every write path against a real Radicle profile |
|
||||
| Manual | Tauri build | Native-only features: dialogs, clipboard images, drag and drop, badges |
|
||||
|
||||
Rules:
|
||||
|
||||
- Unit tests come first because they are the cheapest.
|
||||
- Every bug fix adds a regression test, at the cheapest layer that
|
||||
reproduces the bug, and the test fails without the fix.
|
||||
- Non-trivial logic inside a component (branching, ordering, grouping,
|
||||
deduplication, parsing) is extracted into a module in `src/lib/` and
|
||||
tested there. A one-line helper with a single caller stays in the
|
||||
component. Comments that explain why the code is the way it is move with
|
||||
it.
|
||||
- Tests assert behaviour: an outcome, a property or a relationship between
|
||||
inputs. They don't restate UI copy, CSS classes, selector strings or
|
||||
constant tables, since such tests only ever change in lockstep with the
|
||||
code.
|
||||
- A test earns its place by failing when the logic it covers breaks. New
|
||||
tests are checked by mutating that logic (flip a comparison, drop a
|
||||
filter, shift a boundary), and a test that never fails is removed.
|
||||
- Extracted logic is tested in isolation, so the component flow that wires
|
||||
it into a write path still needs its E2E test.
|
||||
- Every mutating command gets at least one E2E happy path and one
|
||||
permission or error case. Reads are covered by unit tests plus one E2E
|
||||
test showing the data renders.
|
||||
- Combinations such as filters and sort orders are covered in unit tests,
|
||||
not in E2E.
|
||||
- State persisted in `localStorage` gets one reload test in E2E.
|
||||
- Sanitisation is asserted in E2E only, since DOMPurify is a no-op under
|
||||
happy-dom.
|
||||
- `test-http-api` mirrors every Tauri command. Logic lives in
|
||||
`radicle-types` so that both drivers stay thin wrappers, and a parity test
|
||||
fails when a command, route or frontend `invoke` has no counterpart.
|
||||
|
||||
New features follow [the testing checklist](../testing-checklist.md).
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# Testing checklist
|
||||
|
||||
Go through this list for every feature or bug fix. Tick an item when it's
|
||||
covered, or say in the commit or patch description why it doesn't apply.
|
||||
The strategy behind it is in [ADR 1](adr/0001-testing-strategy.md).
|
||||
|
||||
## Bug fixes
|
||||
|
||||
- [ ] The fix comes with a regression test that fails without it, written
|
||||
at the cheapest layer that reproduces the bug.
|
||||
|
||||
## Unit (`tests/unit/`)
|
||||
|
||||
- [ ] New or changed pure logic in `src/lib/` has unit tests.
|
||||
- [ ] Non-trivial logic that was added inside a component (filtering,
|
||||
grouping, sorting, parsing) has been moved into `src/lib/` and tested.
|
||||
One-line helpers with a single caller stay where they are.
|
||||
- [ ] Tests assert behaviour, not UI copy, CSS, selector strings or copies
|
||||
of constant tables.
|
||||
- [ ] Each new test was seen to fail when the logic it covers was broken.
|
||||
- [ ] Edge cases are covered: empty input, a single item, invalid input,
|
||||
boundaries.
|
||||
- [ ] New routes or URL parameters are covered by the router round-trip
|
||||
tests.
|
||||
- [ ] New `localStorage` schemas have tests for their defaults and for
|
||||
invalid stored values.
|
||||
|
||||
## Rust (`crates/`)
|
||||
|
||||
- [ ] New logic in trait default implementations or type conversions has a
|
||||
`#[test]`.
|
||||
- [ ] New error variants are tested, as the frontend matches on error codes.
|
||||
|
||||
## E2E (`tests/e2e/`)
|
||||
|
||||
- [ ] A new Tauri command has a matching route in `crates/test-http-api`
|
||||
(enforced by `cargo test -p test-http-api --test parity`).
|
||||
- [ ] A new write path, meaning any command that changes a COB, a repo or
|
||||
the node's state, has a happy-path E2E test, even when its logic is
|
||||
unit-tested in `src/lib/`.
|
||||
- [ ] Actions limited to authors or delegates have a test for the user who
|
||||
isn't allowed.
|
||||
- [ ] New persisted UI state survives a reload.
|
||||
- [ ] New keyboard shortcuts are exercised at least once.
|
||||
|
||||
## Manual
|
||||
|
||||
- [ ] Native-only behaviour (dialogs, clipboard, drag and drop, dock badge,
|
||||
ssh-agent) has been checked in a real `npm run tauri dev` build.
|
||||
Reference in New Issue
Block a user