-
Notifications
You must be signed in to change notification settings - Fork 731
chore: add agent skills for unit and API e2e tests (CM-968) #4402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+165
−0
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aa2f5ce
chore: add agent skills for unit and API e2e tests (CM-968)
skwowet 4943ad5
chore: register testing skills in skill-guidance (CM-968)
skwowet 5443606
fix: correct ADR relative links in testing skills (CM-968)
skwowet 95b13f9
docs: extend ADR-0008 with mocking and describe grouping (CM-968)
skwowet bd353be
fix: exclude packages_worker from write-unit-tests skill (CM-968)
skwowet 9cec7a6
Merge branch 'main' into chore/CM-968-testing-agent-skills
skwowet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| name: write-api-e2e-tests | ||
| description: > | ||
| Write API end-to-end tests. Use when adding or changing API endpoints, or when | ||
| the user asks for API e2e, smoke, or contract tests. | ||
| allowed-tools: Bash, Read, Glob, Grep, Edit, Write, AskUserQuestion | ||
| --- | ||
|
|
||
| # Write API end-to-end tests | ||
|
|
||
| Write or extend API end-to-end tests. | ||
|
|
||
| ## When to use | ||
|
|
||
| - New or changed API endpoints. | ||
| - User asks for API e2e, smoke, or contract tests. | ||
| - Critical API behaviour needs regression coverage. | ||
|
|
||
| ## When not to use | ||
|
|
||
| - Domain or SQL correctness → use `write-unit-tests`. | ||
| - Temporal, OpenSearch, or other eventual side effects outside the documented API e2e scope. | ||
| - Creating a new testing framework or suite style. | ||
|
|
||
| ## Source of truth | ||
|
|
||
| Read before writing. Follow these ADRs and existing suite structure; do not | ||
| invent a parallel testing style. | ||
|
|
||
| - [ADR-0012](docs/adr/0012-api-e2e-test-architecture.md) — runtime, isolation, supported surfaces, scope, and assertions. | ||
| - [ADR-0013](docs/adr/0013-api-e2e-test-suite-design.md) — suite organisation, helpers, and conventions. | ||
|
Copilot marked this conversation as resolved.
Outdated
|
||
|
|
||
| Current default entrypoint: | ||
|
|
||
| - `.github/scripts/public-api-e2e-tests.sh` | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Identify the API surface. Default to Public API unless the user specifies otherwise. | ||
| 2. Read ADR-0012 and ADR-0013. | ||
| 3. Add or extend the appropriate suite and register it if required. | ||
| 4. Run the affected suite locally and fix failures until green. | ||
| 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. | ||
| 6. Suggest production testability improvements only when they make the API easier to test, and ask before changing production code. | ||
|
|
||
| ## Run | ||
|
|
||
| Export the environment variables required by the suite entrypoint. | ||
|
|
||
| ```bash | ||
| bash .github/scripts/public-api-e2e-tests.sh | ||
| ``` | ||
|
|
||
| Refer to ADR-0012 and the suite entrypoint for environment setup, reset behaviour, | ||
| and local development workflows. | ||
|
|
||
| ## Guardrails | ||
|
|
||
| - Keep tests focused on observable API behaviour. | ||
|
|
||
| ## Output | ||
|
|
||
| - Suites and cases added | ||
| - How to re-run | ||
| - Coverage gaps, if any | ||
| - Optional testability suggestions | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| --- | ||
| name: write-unit-tests | ||
| description: > | ||
| Write focused Vitest unit tests. Use when adding or improving unit tests for | ||
| business logic, data access, common services, or other server modules. | ||
|
skwowet marked this conversation as resolved.
|
||
| allowed-tools: Bash, Read, Glob, Grep, Edit, Write, AskUserQuestion | ||
| --- | ||
|
|
||
| # Write unit tests | ||
|
|
||
| Write focused unit tests that follow the project's testing conventions. | ||
|
|
||
| ## When to use | ||
|
|
||
| - User asks to add or improve unit tests. | ||
| - A change touches high-blast-radius logic (affiliations, merges, identity resolution, timelines, inference). | ||
| - A PR needs confidence in a pure or Postgres-backed function. | ||
|
|
||
| ## When not to use | ||
|
|
||
| - Public or HTTP contract coverage → use `write-api-e2e-tests`. | ||
| - Temporal, Redis, or OpenSearch fixtures (not available yet). | ||
| - Broad "increase coverage %" requests without a clear unit under test. | ||
|
|
||
| ## Source of truth | ||
|
|
||
| Read before writing. Follow these ADRs; do not invent a parallel testing style. | ||
|
|
||
| - [ADR-0008](docs/adr/0008-how-we-write-unit-tests.md) — scenarios, `describe` grouping, assertions, mocking, and shared setup. | ||
| - [ADR-0007](docs/adr/0007-test-factory-primitives-and-defaults.md) — factories and defaults. | ||
|
skwowet marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Identify the unit under test (one function or decision path). Colocate tests as `<file>.test.ts`. | ||
| 2. Read ADR-0007 and ADR-0008. Skim the nearest existing test in the same area if one exists. | ||
| 3. Compose fixtures using `@crowd/test-kit` (`withQx` for Postgres-backed tests; factories and opt-in defaults per ADR-0007). | ||
|
skwowet marked this conversation as resolved.
|
||
| 4. Write focused scenarios following ADR-0008 (grouping, naming, assertions, and mocking). | ||
| 5. Run the affected tests and fix failures until green. | ||
| 6. If production code is difficult to test, suggest a small testability seam and ask before changing production code. | ||
|
|
||
| ## Run | ||
|
|
||
| Start the test database when needed: | ||
|
|
||
| ```bash | ||
| ./scripts/cli scaffold up-test | ||
| ``` | ||
|
|
||
| Run a focused test file: | ||
|
|
||
| ```bash | ||
| pnpm test:server -- path/to/file.test.ts | ||
| ``` | ||
|
skwowet marked this conversation as resolved.
|
||
|
|
||
| Optional: | ||
|
|
||
| ```bash | ||
| pnpm test:changed | ||
| pnpm test:watch -- path/to/file.test.ts | ||
| ``` | ||
|
|
||
| ## Guardrails | ||
|
|
||
| - Prefer critical behaviours over trivial getters, setters, and thin wrappers. | ||
| - Keep production behaviour unchanged unless the user explicitly asks for a testability improvement. | ||
|
|
||
| ## Output | ||
|
|
||
| - Scenarios covered | ||
| - How to re-run | ||
| - Optional testability suggestions | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.