Skip to content

test: improve code coverage with unit and integration tests#100

Merged
rhuanbarreto merged 2 commits into
mainfrom
test/improve-coverage
Mar 20, 2026
Merged

test: improve code coverage with unit and integration tests#100
rhuanbarreto merged 2 commits into
mainfrom
test/improve-coverage

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • Add 107 new tests (328 → 435) raising overall line coverage from 82.85% → 89.54%
  • Create a new integration test suite (tests/integration/) that exercises the real CLI end-to-end via Bun.spawn against isolated temp directories
  • Expand unit test coverage for previously untested helpers and command handlers

Unit tests added

Area What's covered
auth.ts pollForAccessToken (pending/slow_down/expired/denied/deadline), claimArchgateToken error paths, getGitHubUser missing login
signup.ts requestSignup success/failure/default-editor
session-context.ts Full read flows for Claude Code and Cursor sessions with fixture JSONL, content preview, maxEntries truncation
binary-upgrade.ts fetchLatestGitHubVersion, downloadReleaseBinary error, replaceBinary on non-Windows
git.ts installGit (already-installed path)
plugin-install.ts buildVscodeMarketplaceUrl, isCopilotCliAvailable
vscode-settings.ts getVscodeUserSettingsPath platform branches
Command handlers adr list/show/create/update, clean — actual execution with temp projects

Integration tests added (40 tests)

Test file Tests Scope
init.test.ts 7 All editors, idempotency, .gitignore, oxlint overrides
check.test.ts 9 Pass/fail rules, --json, --ci, --adr, --verbose
adr.test.ts 11 Create with all flags, list with filters
adr-show-update.test.ts 6 Show, update with frontmatter preservation
clean.test.ts 3 Clean flow with HOME isolation
review-context.test.ts 4 JSON output, --domain, --run-checks

Test plan

  • bun run validate passes (lint, typecheck, format, tests, ADR check, build)
  • All 435 tests pass with 0 failures
  • Coverage improved from 82.85% → 89.54% lines

Add 107 new tests raising overall coverage from 82.85% to 89.54% lines.

Unit tests cover: auth polling, signup requests, session-context reading,
binary-upgrade fetching, git helpers, plugin-install URLs, vscode settings,
and command handler execution for adr/clean/list/show/update.

Integration tests exercise the real CLI via Bun.spawn against isolated
temp directories, covering init (all editors, idempotency, gitignore,
linter overrides), check (pass/fail, --json, --ci, --adr, --verbose),
adr CRUD (create/list/show/update with all flags), clean, and
review-context (with git state, --domain, --run-checks).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 20, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: e89fa5c
Status: ✅  Deploy successful!
Preview URL: https://0d580a19.archgate-cli.pages.dev
Branch Preview URL: https://test-improve-coverage.archgate-cli.pages.dev

View logs

os.homedir() caches its result on Linux and doesn't pick up
runtime HOME env var changes. Use unique fixture dirs under
the actual homedir instead of overriding HOME.
@rhuanbarreto rhuanbarreto merged commit 64295ee into main Mar 20, 2026
8 checks passed
@rhuanbarreto rhuanbarreto deleted the test/improve-coverage branch March 20, 2026 23:12
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