Skip to content

test: add 12 unit tests for lib/config.ts - #262

Open
TerminalGravity wants to merge 4 commits into
mainfrom
test/config-unit-tests-mar16
Open

test: add 12 unit tests for lib/config.ts#262
TerminalGravity wants to merge 4 commits into
mainfrom
test/config-unit-tests-mar16

Conversation

@TerminalGravity

Copy link
Copy Markdown
Collaborator

Adds comprehensive test coverage for the config system (src/lib/config.ts).

12 tests covering:

  • Default config fallback when no .preflight/ directory
  • Env var overrides: profile, embedding provider, API key, related projects
  • Invalid env values gracefully ignored
  • config.yml + triage.yml loading and deep-merging with defaults
  • Env vars correctly skipped when .preflight/ directory exists
  • Singleton caching (same reference on repeated calls)
  • Malformed YAML handled gracefully (falls back to defaults)
  • hasPreflightConfig() and getRelatedProjects() helpers

All 55 tests passing (43 existing + 12 new).

Shows 4 concrete scenarios: vague prompt clarification, multi-step
scoping, correction pattern matching, and cross-service awareness.
Each example includes the prompt, triage classification, and the
actual output users can expect.
The README and examples/README.md referenced examples/.preflight/
but the actual config files didn't exist. Added:

- config.yml — profile, related projects, thresholds, embeddings
- triage.yml — keyword rules and strictness settings
- contracts/api.yml — manual contract definition examples

All files are heavily commented so users can copy them into their
project root and customize without needing to reference the docs.
The init wizard resolved the templates directory relative to dist/cli/,
which pointed to dist/templates/ — a path that doesn't exist. Templates
live in src/templates/ and ship in the npm tarball via the 'files' field.

Fixed by going up three levels (dist/cli/init.js → package root) instead
of two, then into src/templates/.
Tests cover:
- Default config when no .preflight/ directory
- Env var overrides (profile, embedding provider, API key, related projects)
- Invalid env var values ignored
- config.yml loading and merging with defaults
- triage.yml loading and merging
- Env vars ignored when .preflight/ exists
- Singleton caching behavior
- Graceful handling of malformed YAML
- hasPreflightConfig() behavior
- getRelatedProjects() backward compat helper
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.

1 participant