Skip to content

Comments

feat: add automated testing infrastructure, code cleanup, and update default model #23

Open
coderashed wants to merge 13 commits intoCerebras:mainfrom
coderashed:pr/dev-tooling
Open

feat: add automated testing infrastructure, code cleanup, and update default model #23
coderashed wants to merge 13 commits intoCerebras:mainfrom
coderashed:pr/dev-tooling

Conversation

@coderashed
Copy link

Summary

  • Updated default model to zai-glm-4.7
  • Add dev tooling: Vitest for unit/integration testing, ESLint for linting, Prettier for formatting
  • Add 155 unit tests (11 test files) and 10 integration tests covering all src/ modules at 99%+ coverage
  • Fix hardcoded provider pinning in OpenRouter requests and update deprecated default model (Qwen 3 Coder)
  • Add OPENROUTER_MODEL env var support for configurable model selection
  • Add testing guide (docs/testing.md)
  • Dead code removed in places (code that could never be reached)

Test results

Metric Result
Unit tests 155/155 passed (11 files)
Integration tests 10/10 passed
Lint (ESLint) Clean
Statements 99.27%
Branches 95.37%
Functions 100%
Lines 99.26%

interactive-config.js is excluded from coverage — it handles interactive terminal prompts that are not suitable for automated testing.

Test plan

  • npm test — all 155 unit tests pass
  • npm run test:coverage — exceeds 80% target across all metrics
  • npm run test:integration — all 10 integration tests pass (Cerebras, OpenRouter, fallback, edit path, context files, error handling)
  • npm run lint — clean

All functionality has been hand tested in Claude Code.

coderashed and others added 13 commits February 5, 2026 10:17
- Add vitest for unit testing with coverage support
- Add eslint 9 with flat config for linting
- Add prettier for code formatting
- Add npm scripts: test, lint, format
- Create tests/ directory structure mirroring src/
- Add sample rate-limiter tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rewrite all principle docs from Python to JavaScript
- Add JSDoc documentation guide (replaces type hints)
- Add ESLint complexity guide (replaces radon)
- Update GoF patterns with JS-idiomatic recommendations
- Mark over-engineered patterns to avoid (Singleton, Strategy classes, etc.)
- Update TDD workflow for npm/vitest/eslint
- Add docs/testing.md with vitest usage guide
- Add .ai/intuitions/performance.md with optimization ideas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add diff-formatter.test.js for diff generation
- Add response-formatter.test.js for edit/create responses
- Add syntax-highlighter.test.js for code highlighting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix async timing in API tests with vi.waitFor() for existingContent reads
- Update constants test to match v1.3.3 debugLog behavior (always logs)
- Remove OpenRouter timeout test (not implemented in v1.3.3)
- Add caughtErrorsIgnorePattern to eslint for unused catch variables
- Exclude interactive-config.js from linting (upstream code)
- Fix minor lint issues: remove unused imports, use const where appropriate

All 125 tests passing, lint clean.
- Allow OpenRouter model to be configured via OPENROUTER_MODEL env var
- Default remains 'qwen/qwen3-coder' for backwards compatibility
- Add environment variables documentation table to README
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add integration test suite exercising Cerebras and OpenRouter providers
- Add fallback test that verifies Cerebras → OpenRouter failover path
- Add test helpers for provider isolation and fallback forcing
- Add vitest.integration.config.js with 30s timeout for API latency
- Add test:integration npm script
- Exclude integration tests from unit test runs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add integration test section covering prerequisites, test helpers,
fallback testing strategy, and vitest integration config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Exclude interactive-config.js from coverage (untestable CLI wizard)
- Add getClineRulesPath platform branch tests (win32/linux)
- Add config env var branch tests (CEREBRAS_MODEL, MAX_TOKENS, OPENROUTER_MODEL)
- Add router no-fallback path tests (OpenRouter-only provider)
- Add response-formatter IDE variant tests (cursor, crush, cline, vscode)
- Add response-formatter typescript file and truncation tests
- Add diff-formatter removal edge case test
- Add API context file error, filtering, and empty content tests
- Add tool-handlers empty file edge case test

155 tests passing, 99.27% statements, 95.37% branches, 100% functions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused imports (beforeEach, afterEach, vi, cleanCodeResponse)
and unused variable assignment in tool-handlers test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…andling

- Edit existing file (per provider): seed file, modify via API, verify diff response
- Context files: pass context_files param, verify API uses context
- Nested directory creation: file_path with non-existent parents
- Error handling: missing prompt, missing file_path, invalid API key
- All return structured responses (no uncaught throws)

10 integration tests passing (was 3).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Error tests (missing prompt, missing file_path, invalid key) don't
require real API keys. They now run even when env vars are not set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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