Repository navigation
test: add the outside-in test taxonomy and its first scenarios - #187
Conversation
An audit of the suite — 187 files, 119,097 lines, 5,630 cases — found it
overwhelmingly white-box: 144 of 187 files import a deep internal module,
across 146 distinct modules, so most internal renames are breaking
changes by construction. There was no organising principle a newcomer
could navigate, and no way to tell a test that guards a user-visible
promise from one that pins an implementation detail.
Introduce `tests/`, where user-observable behaviour is tested as a black
box through the three surfaces Weave actually exposes:
- `tests/dsl/` — `.weave` source in, resolved agents and errors out
- `tests/cli/` — argv plus a virtual filesystem in, exit code and
output out
- `tests/adapters/` — `.weave` source in, generated harness files out
Each enters through a seam a real caller has and asserts only what a user
can observe, so a refactor that preserves behaviour does not touch them.
`describe(…)` names the situation and `it(…)` names one promise, so a
newcomer can read a file and learn what Weave guarantees. Module-level
unit tests stay beside their source and keep their existing style.
The CLI had no seam to test through: `CliDeps` carried no filesystem, so
any command driven via `run()` hit the real disk. Thread `fs` through to
the handlers that already accept one (`validate`, `init`). The remaining
five commands follow separately.
Also correct the category examples in AGENTS.md, which still showed
`patterns [...]` — a key dropped from CategoryConfigSchema in favour of
`triggers`. Routing is model-guided, not glob matching.
19 scenarios to start. `docs/testing-strategy.md` records the inventory,
the findings behind it, and the remaining plan.
Refs #183 (task group 9)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve
|
Warning Review limit reachedNext included review available in 11 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (12)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new seams still permit real filesystem/process access in CLI paths, and the adapter scenario fails on Windows path separators.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 4
Open (4)
What changed in this PR
Part of #183, this PR establishes Weave’s outside-in test taxonomy and adds initial DSL, CLI, and Claude Code adapter scenarios.
Changes:
- Adds 19 scenario tests and shared Given/When/Then helpers.
- Threads injectable filesystem support through CLI validation and initialization.
- Documents the taxonomy and updates category examples from
patternstotriggers.
| File | Description |
|---|---|
tsconfig.json |
Includes scenario tests in typechecking. |
tests/support/scenario.ts |
Adds shared scenario helpers. |
tests/README.md |
Defines bucket and naming conventions. |
tests/dsl/category-routing.scenario.test.ts |
Tests category materialization and conflicts. |
tests/cli/validate.scenario.test.ts |
Tests CLI validation behavior with virtual files. |
tests/adapters/claude-code.scenario.test.ts |
Tests Claude Code bundle generation. |
packages/cli/src/cli.ts |
Adds injectable filesystem dependencies. |
package.json |
Runs scenarios and lints their files. |
docs/testing-strategy.md |
Documents inventory and cleanup plan. |
docs/README.md |
Links the testing strategy. |
biome.json |
Adds tests/ to linting. |
AGENTS.md |
Corrects category routing documentation. |
.codesight/middleware.md |
Updates generated metadata. |
.codesight/graph.md |
Updates generated metadata. |
.codesight/coverage.md |
Updates generated metadata. |
.codesight/CODESIGHT.md |
Updates generated metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // this router lean and avoid circular deps during init | ||
| const { runValidate } = await import("./commands/validate.js"); | ||
| return runValidate({ terminal, theme, flags }); | ||
| return runValidate({ terminal, theme, flags, fs }); |
| case "init": { | ||
| const { runInit } = await import("./commands/init.js"); | ||
| return runInit({ terminal, theme, flags }); | ||
| return runInit({ terminal, theme, flags, fs }); |
| const flushed = await adapter.flush(); | ||
| expect(flushed.isOk()).toBe(true); | ||
|
|
||
| return written; |
| export async function whenMaterialized( | ||
| source: string, | ||
| ): Promise<MaterializationPlan> { | ||
| const result = await materializeAgents({ config: givenConfig(source) }); |

Part of #183 — task group 9.
Why
The suite is 187 files, 119,097 lines, 5,630 cases, and overwhelmingly white-box: 144 of 187 files import a deep internal module, across 146 distinct modules. Most internal renames are breaking changes by construction. There was no organising principle a newcomer could navigate, and no way to tell a test guarding a user-visible promise from one pinning an implementation detail.
The taxonomy
User-observable behaviour is tested as a black box through the three surfaces Weave actually exposes:
tests/dsl/.weavesource textparseConfig→materializeAgentstests/cli/argv+ virtual filesystemrun({ argv, terminal, fs })tests/adapters/.weavesource textinit/spawnSubagent/flushThe adapter bucket is the widest box:
.weavein at one end, the plugin files a user would find on disk at the other, with nothing in between asserted directly.Module-level unit tests stay beside their source in
packages/*/src/__tests__/and keep their existing style. The rule is about where a promise is made: if a user can observe it, it belongs intests/.Naming
describe(…)names the situation,it(…)names one promise:versus the shape that dominates today:
The second tells you which function was called. The first tells you what breaks for a user, and survives that function being renamed, inlined or replaced.
The CLI needed a seam
CliDepscarried no filesystem, so any command driven throughrun()hit the real disk — there was no way to write a hermetic black-box CLI test at all.fsis now threaded to the handlers that already accept one (validate,init). The remaining five commands follow in task group 13.Also in here
The category examples in
AGENTS.mdstill showedpatterns [...], a key dropped fromCategoryConfigSchemain favour oftriggers— routing is model-guided, not glob matching.docs/dsl-reference.mdwas already correct. That stale key is what invalidated the global config which surfaced #185, so it is fixed here rather than left to mislead the next reader.Review notes
docs/testing-strategy.mdcarries the full inventory, ten findings, and the remaining plan with per-step status.tests/cli/were written against guessed CLI wording and corrected against real output (File not found, notmissing). Worth a glance that the assertions match what the commands actually print.Verification
bun test ./tests: 19 pass, 0 failbun run test: 6,133 pass, 15 skip, 0 failbun run typecheck,bun run lint,bun run verify:test-coverage,bun run docs:check-links: pass🤖 Generated with Claude Code
https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve