Skip to content

test(detectors): add test coverage for relay-setup's detectors module - #1

Merged
arnaudmanaranche merged 6 commits into
mainfrom
feat/detector-tests
Aug 11, 2026
Merged

test(detectors): add test coverage for relay-setup's detectors module#1
arnaudmanaranche merged 6 commits into
mainfrom
feat/detector-tests

Conversation

@arnaudmanaranche

Copy link
Copy Markdown
Owner

Summary

Adds unit test coverage for skills/relay-setup/scripts/detectors/*.mjs (previously zero coverage) — the auto-detection logic detect-stack.mjs uses to bootstrap a new project's .ai/config.json.

  • 11 new test files under test/detectors/, one per detector module (fs-helpers, project, project-type, commands, source-layout, stack, analytics, paywall, e2e, error-tracking, locales), mirroring the existing test/agent-runner.test.tsagent-runner.ts convention.
  • Widened package.json's scripts.test glob to pick up test/detectors/**/*.test.mjs.
  • Test-only change — zero files under skills/relay-setup/scripts/detectors/ or detect-stack.mjs are touched (confirmed via diff).

This was built as a dogfooding exercise, running Relay's own pipeline (PM → Dev Review → Architect → Dev → Review → QA → Retro) against Relay's own codebase, with real LLM calls throughout. Full account in .ai/artifacts/features/detector-tests/.

3 real detector bugs found while writing these tests

All three were fixed separately, directly on main (already merged, this branch is rebased on top) — not as part of this test-only change:

  1. detectLintCmd/detectFormatCmd/detectFormatWriteCmd checked the dependency key 'biome', which isn't a real npm package (the actual package is @biomejs/biome) — the Biome fallback path never fired for any real project using it.
  2. detectErrorTracking didn't recognize @sentry/node (the plain Node.js/backend Sentry SDK) — only frontend-framework-flavored Sentry packages.
  3. fs-helpers.mjs's findFiles only ever tested its predicate against files, never directories — silently breaking detectLocales's own directory-name fallback branch.

Tests assert the current (already-fixed) behavior.

Process notes

  • Dev's first pass (57/190 assertions failing, ~30%) — the agent guessed several detectors' function signatures/argument order without source-read access. Root-caused every failure against real source and corrected the test files; see dev-log.md.
  • Review: FAIL → FAIL → PASS_WITH_NOTES across 3 passes — the first two failures were actually a real bug in the pipeline itself (Review's git diff was unconditionally empty in the real flow; fixed on main along the way, see 48fccbf/bdce31b). All PASS_WITH_NOTES action items (exact-value assertions, dangling doc references, a duplicate test, two scenario-fidelity clarifications) were addressed in a follow-up commit.
  • QA: PASS (unit tests are the QA deliverable for this CLI-only, no-UI feature).

Test plan

  • npm test — 233/233 passing
  • npm run typecheck — clean
  • git diff main...feat/detector-tests -- skills/relay-setup/scripts/detectors/ — empty (test-only, confirmed)
  • Human review of the actual diff (this PR was reviewed by the pipeline's own Review/QA agents, not yet by a human)

…odule

Adds test/detectors/*.test.mjs covering every exported function across
skills/relay-setup/scripts/detectors/*.mjs (previously zero coverage —
the gap that let detectAppId, detectLintCmd/detectFormatCmd/
detectFormatWriteCmd, and detectSourceDirs bugs ship undetected).
Widens package.json's test glob to pick up the new test/detectors/
subdirectory.

Dev's first pass (Sonnet, real claude-cli calls) produced 190 tests with
57 failing — traced every failure to a real signature/argument-order
mismatch (the agent had no source-read access when guessing several
detectors' contracts) and corrected them against actual source. That
pass also surfaced 3 genuine, previously-undiscovered detector bugs
(fixed separately on main: the 'biome' dependency key not matching the
real @biomejs/biome package, @sentry/node not recognized, and
findFiles never testing its predicate against directories) — see
dev-log.md for the full account.

204/204 tests passing.
…commits, not part of this feature

Previous wording ('Fixed the key', 'Added it', 'this fix') read as if
this feature's own change touched detector source — it doesn't. This
feature's own commits have zero diff under
skills/relay-setup/scripts/detectors/ (confirmed via git diff
main...feat/detector-tests). The three bugs were reported here per AC 26
and fixed via separate, dedicated commits directly on main, which this
branch is now based on top of.
- analytics/paywall/stack/error-tracking test files: replaced generic
  hasSignal() truthy checks with exact literal-value assertions for
  every recognized dependency (confirmed against real source), matching
  this repo's stated characterization-testing convention. Removed the
  dangling "see dev-log.md (Batch 2)" comments — that section was never
  written; there's no remaining caveat to defer since exact values are
  now asserted directly.
- analytics.test.mjs: added the previously-untested firebase-analytics
  branch (requires firebase dep AND a real src/ dir), removed a
  duplicate no-signal test.
- source-layout.test.mjs: clarified the AC15 Expo-router test with an
  explicit source citation confirming the signal is the expo-router
  dependency, not an app/_layout.tsx file.
- project.test.mjs: added a negative characterization test confirming
  detectAppId does NOT read capacitor.config.ts (only .json).
- Verified .ai/config.json's commands.test ("npm test") already covers
  the widened glob via package.json delegation — no change needed.

233/233 tests passing.
@arnaudmanaranche
arnaudmanaranche merged commit f6a82ca into main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants