Skip to content

Commit 34b283e

Browse files
committed
fix: minor nitpicks and agent skills
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent da647c2 commit 34b283e

6 files changed

Lines changed: 198 additions & 47 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: write-api-e2e-tests
3+
description: >
4+
Write API end-to-end tests. Use when adding or changing API endpoints, or when
5+
the user asks for API e2e, smoke, or contract tests.
6+
allowed-tools: Bash, Read, Glob, Grep, Edit, Write, AskUserQuestion
7+
---
8+
9+
# Write API end-to-end tests
10+
11+
Write or extend API end-to-end tests.
12+
13+
## When to use
14+
15+
- New or changed API endpoints.
16+
- User asks for API e2e, smoke, or contract tests.
17+
- Critical API behaviour needs regression coverage.
18+
19+
## When not to use
20+
21+
- Domain or SQL correctness → use `write-unit-tests`.
22+
- Temporal, OpenSearch, or other eventual side effects outside the documented API e2e scope.
23+
- Creating a new testing framework or suite style.
24+
25+
## Source of truth
26+
27+
Read before writing. Follow these ADRs and existing suite structure; do not
28+
invent a parallel testing style.
29+
30+
- [ADR-0012](docs/adr/0012-api-e2e-test-architecture.md) — runtime, isolation, supported surfaces, scope, and assertions.
31+
- [ADR-0013](docs/adr/0013-api-e2e-test-suite-design.md) — suite organisation, helpers, and conventions.
32+
33+
Current default entrypoint:
34+
35+
- `.github/scripts/public-api-e2e-tests.sh`
36+
37+
## Workflow
38+
39+
1. Identify the API surface. Default to Public API unless the user specifies otherwise.
40+
2. Read ADR-0012 and ADR-0013.
41+
3. Add or extend the appropriate suite and register it if required.
42+
4. Run the affected suite locally and fix failures until green.
43+
5. If required fixtures cannot be created through the API, prefer testing supported scenarios and explain any coverage gaps instead of seeding the database directly.
44+
6. Suggest production testability improvements only when they make the API easier to test, and ask before changing production code.
45+
46+
## Run
47+
48+
Export the environment variables required by the suite entrypoint.
49+
50+
```bash
51+
bash .github/scripts/public-api-e2e-tests.sh
52+
```
53+
54+
Refer to ADR-0012 and the suite entrypoint for environment setup, reset behaviour,
55+
and local development workflows.
56+
57+
## Guardrails
58+
59+
- Keep tests focused on observable API behaviour.
60+
61+
## Output
62+
63+
- Suites and cases added
64+
- How to re-run
65+
- Coverage gaps, if any
66+
- Optional testability suggestions
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
name: write-unit-tests
3+
description: >
4+
Write focused Vitest unit tests. Use when adding or improving unit tests for
5+
business logic, data access, common services, or other server modules.
6+
allowed-tools: Bash, Read, Glob, Grep, Edit, Write, AskUserQuestion
7+
---
8+
9+
# Write unit tests
10+
11+
Write focused unit tests that follow the project's testing conventions.
12+
13+
## When to use
14+
15+
- User asks to add or improve unit tests.
16+
- A change touches high-blast-radius logic (affiliations, merges, identity resolution, timelines, inference).
17+
- A PR needs confidence in a pure or Postgres-backed function.
18+
19+
## When not to use
20+
21+
- Public or HTTP contract coverage → use `write-api-e2e-tests`.
22+
- Temporal, Redis, or OpenSearch fixtures (not available yet).
23+
- Broad "increase coverage %" requests without a clear unit under test.
24+
25+
## Source of truth
26+
27+
Read before writing. Follow these ADRs; do not invent a parallel testing style.
28+
29+
- [ADR-0008](docs/adr/0008-how-we-write-unit-tests.md) — scenarios, `describe` grouping, assertions, mocking, and shared setup.
30+
- [ADR-0007](docs/adr/0007-test-factory-primitives-and-defaults.md) — factories and defaults.
31+
32+
## Workflow
33+
34+
1. Identify the unit under test (one function or decision path). Colocate tests as `<file>.test.ts`.
35+
2. Read ADR-0007 and ADR-0008. Skim the nearest existing test in the same area if one exists.
36+
3. Compose fixtures using `@crowd/test-kit` (`withQx` for Postgres-backed tests; factories and opt-in defaults per ADR-0007).
37+
4. Write focused scenarios following ADR-0008 (grouping, naming, assertions, and mocking).
38+
5. Run the affected tests and fix failures until green.
39+
6. If production code is difficult to test, suggest a small testability seam and ask before changing production code.
40+
41+
## Run
42+
43+
Start the test database when needed:
44+
45+
```bash
46+
./scripts/cli scaffold up-test
47+
```
48+
49+
Run a focused test file:
50+
51+
```bash
52+
pnpm test:server -- path/to/file.test.ts
53+
```
54+
55+
Optional:
56+
57+
```bash
58+
pnpm test:changed
59+
pnpm test:watch -- path/to/file.test.ts
60+
```
61+
62+
## Guardrails
63+
64+
- Prefer critical behaviours over trivial getters, setters, and thin wrappers.
65+
- Keep production behaviour unchanged unless the user explicitly asks for a testability improvement.
66+
67+
## Output
68+
69+
- Scenarios covered
70+
- How to re-run
71+
- Optional testability suggestions

0 commit comments

Comments
 (0)