feat(0.2): finish Track 3 centerpiece — integration / e2e / unified PR comment#145
Open
feat(0.2): finish Track 3 centerpiece — integration / e2e / unified PR comment#145
Conversation
…R comment The three Track 3 deliverables that close the pitch's "maps how your unit, integration, e2e, and AI tests actually relate to your code" promise. Together they make the recommended workflow (`terrain analyze && terrain report pr`) defensible against the launch-readiness review's "this is uneven across test types" critique. Track 3.3 — integration-test classification rigor Adds explicit content-based detection of HTTP-testing libraries (supertest, httptest, MockMvc, supertest, requests, etc.) so integration tests living alongside unit tests in flat directories are correctly classified. New `internal/testtype/integration_imports.go` with a curated allowlist of 30+ patterns spanning JS/TS, Go, Python, Java, Ruby ecosystems. New `refineIntegrationClassification` step in the analyzer reads each test file once via the existing FileCache and merges the content-based signal with the path/suite/framework-based signal, with explicit conflict-handling that lets explicit imports override directory naming. 14 new tests covering positive matches, prose-mention false-positive guards, multi-library co-detection, and the merge logic. Track 3.4 — e2e-to-code attribution honest carve-out New `docs/product/e2e-attribution.md` documents the exact limit of e2e attribution in 0.2: structural-only, via path co-location + framework-config declarations + shared-fixture transitive links + convention fallback. Explicitly carves out runtime trace ingestion, URL-to-route mapping, DOM-selector-to-component mapping, and cross-language attribution as 0.3+ work. The honest carve-out is the contract — the recommended-tests stanza tags e2e selections as `[structural-only]` so adopters know to inspect rather than trust blindly. Track 3.5 — unified PR-comment rendering audit New `internal/changescope/unified_render_test.go` enforces the visual contract for `terrain report pr --format markdown`: bracketed `[LABEL]` badges across stanzas, `**\`path\`**` locator format, em-dash separator, and a single recommended-tests stanza for unit + integration + e2e (no per-type splitting). Plus a consistent-section-order test. Companion doc `docs/product/unified-pr-comment.md` documents the contract, the section-level severity-grouping exception for the AI stanza (and why), and the alternatives that were considered and rejected. Verification: all internal + cmd tests pass; `make docs-verify` green; new tests run in ~0.5s combined. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Terrain AI Risk Review
Decision: PASS — AI surfaces are covered. |
[RISK] Terrain — Merge with caution
Coverage gaps in changed code
4 pre-existing issues on changed files
Recommended tests11 test(s) with exact coverage of 4 impacted unit(s). 3 impacted unit(s) have no covering tests in the selected set.
Owners: PMCLSF Limitations
Generated by Terrain · Targeted Test ResultsTerrain selected 11 test(s) instead of the full suite.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The three Track 3 deliverables that close the pitch's "maps how
your unit, integration, e2e, and AI tests actually relate to your
code" promise. Track 3 is the centerpiece of the parity-gated
0.2.0 plan; this PR finishes the three remaining items (3.3–3.5).
Content-based detection of HTTP-testing libraries (supertest,
httptest, MockMvc, requests, etc.) so integration tests living
alongside unit tests in flat directories are correctly classified.
Documents the exact limit of e2e attribution in 0.2 — structural-
only, with the deeper coverage-instrumented path explicitly out
of scope until 0.3.
golden test enforces the visual contract: bracketed
[LABEL]badges,
**\path`**` locators, em-dash separators, and a singlerecommended-tests stanza for unit + integration + e2e.
What changed
New code (
internal/testtype/,internal/analysis/):integration_imports.go— pattern allowlist (30+ patternsacross JS/TS, Go, Python, Java, Ruby) +
InferFromContentandMergeContentInferencehelpersintegration_classification.go— analyzer wiring that reads eachtest file once via the existing FileCache and refines the
test-type classification
New tests:
integration_imports_test.go— 14 tests covering positivematches, prose-mention false-positive guards, multi-library
co-detection, and merge logic
integration_classification_test.go— 5 tests covering thepromote-to-integration path, the leave-pure-unit-alone guard,
the Go httptest case, the nil-cache path, and cancellation
unified_render_test.go— render-golden enforcing the fouruniformity gates plus consistent section ordering
New docs (
docs/product/):test-type-classification.md— what 0.2 detects, what itdoesn't, false-positive catalog, extension recipe
e2e-attribution.md— the honest carve-out (structural-only)and the 0.3 roadmap
unified-pr-comment.md— the visual contract, the alternativesconsidered, the AI section-level grouping exception
Why these three together
They're independent in code but co-located in the plan: all three
are "the pitch's promise about test types is now defensible."
Bundling minimizes review thrash on tightly-related work.
Test plan
go build ./...cleango test ./internal/...all pass (incl. 19 new tests)go test ./cmd/...all passgo test ./internal/testdata/...all passmake docs-verifypassesterrain analyzeon a repo with integrationtests in flat directories → integration classification fires
terrain report pr --format markdownon amixed unit/integration/e2e + AI PR → unified comment shape
Plan tracker
Closes Track 3.3, 3.4, 3.5 from the parity-gated 0.2.0 plan.
Track 3 (the centerpiece) is now complete: 3.1 (PR
--fail-on)and 3.2 (
--explain-selection) shipped earlier in the cycle; 3.3through 3.5 land here. Remaining: Tracks 5, 6, 7, 9, 10.2-10.8.
🤖 Generated with Claude Code