Skip to content

CLI-507 Add e2e tests for sonar-context-augmentation#317

Draft
mpaladin wants to merge 3 commits into
masterfrom
mp/CLI-507
Draft

CLI-507 Add e2e tests for sonar-context-augmentation#317
mpaladin wants to merge 3 commits into
masterfrom
mp/CLI-507

Conversation

@mpaladin
Copy link
Copy Markdown
Contributor

@mpaladin mpaladin commented May 22, 2026

Summary

Adds an offline e2e suite under tests/e2e/context/ that exercises the real sonar-context-augmentation binary — download, PGP signature verification, tar extraction, skill rendering, post-update refresh, and passthrough — without touching SonarQube/Cloud. The only network reach is binaries.sonarsource.com for the archive and detached signature.

The trigger path uses pre-seeded state.json (stale config.cliVersion + stale-version skill record) so runPostUpdateActions() fires and walks the real install chain, bypassing the entitlement check and cag init that would otherwise require a live SQ Cloud connection.

Coverage

File Tests What it proves
cag-offline.test.ts 11 Initial install (binary path, signature, --version, state bump, SKILL.md written, sonar context --help passthrough) + simulated self-update reinstall
cag-edge-cases.test.ts 5 Deleted projectRoot is skipped, global skill is skipped, multi-skill refresh in one pass, no-op when cliVersion is current, stale-version binary cleanup
cag-passthrough.test.ts 3 Unauthenticated non-help action emits the CLI's "Not authenticated" error, bare `sonar context` falls through to CAG's help, child non-zero exit propagates to the parent
cag-copilot.test.ts 2 Post-update renders .github/skills/sonar-context-augmentation/SKILL.md for a copilot-cli skill record
_helpers.ts Shared buildSkillExtension / seedState / findRecordedCagSkill scaffolding

Total: 21 tests in ~6.3s locally.

Not in scope

The two `integrate` guard rails I considered (CAG skipped on SonarQube Server, CAG skipped with `--global`) are already covered by integration tests at tests/integration/specs/integrate/context-augmentation.test.ts:454,570. Since those paths return before the binary would be downloaded, an e2e variant exercises no real-binary code that integration doesn't already cover.

Live SonarQube Cloud coverage (entitlement check, `cag init`, real `sonar context `) is deferred — those require Vault secrets and a CAG-entitled test org.

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 22, 2026

CLI-507

@mpaladin mpaladin changed the base branch from master to mp/CAG-418 May 22, 2026 16:01
@mpaladin mpaladin changed the title CLI-507 Add CAG e2e tests CLI-507 Add offline e2e tests for sonar-context-augmentation May 22, 2026
@mpaladin
Copy link
Copy Markdown
Contributor Author

@sonar-review-alpha review

Base automatically changed from mp/CAG-418 to master May 22, 2026 16:40
mpaladin added 3 commits May 22, 2026 18:42
Seeds a stale-version CAG skill plus a stale config.cliVersion in state.json
so runPostUpdateActions() re-downloads the real binary from
binaries.sonarsource.com, verifies its pinned PGP signature, extracts the
tarball, and reruns `tool install-skill` — covering the real-binary surface
that does not need SonarQube/Cloud project access. Asserts on the on-disk
binary, refreshed skill version, and `sonar context --help` forwarding.
Adds a SKILL.md assertion to the initial post-update path and a nested
describe that simulates a second self-update by rewinding state versions
and deleting the rendered skill. The rerun must recreate SKILL.md with
identical content and re-bump both cliVersion and the recorded skill
version, proving `tool install-skill` actually runs (not just a state
write).
Adds three new offline e2e files plus a shared helpers module:

- cag-edge-cases.test.ts: deleted projectRoot, global skill, multi-skill
  refresh in one pass, no-op when cliVersion is current, stale-version
  binary cleanup in <binDir>.
- cag-passthrough.test.ts: unauthenticated action surfaces the CLI's
  "Not authenticated" error, bare `sonar context` falls through to CAG's
  help, child non-zero exit propagates to the parent.
- cag-copilot.test.ts: post-update refreshes a recorded copilot-cli skill
  and writes .github/skills/sonar-context-augmentation/SKILL.md.

The integrate guard rails (CAG skipped on SonarQube Server, skipped with
--global) are intentionally left to the existing integration tests at
tests/integration/specs/integrate/context-augmentation.test.ts since the
real binary never runs in those paths — nothing new for e2e to cover.
@sonarqubecloud
Copy link
Copy Markdown

@mpaladin mpaladin changed the title CLI-507 Add offline e2e tests for sonar-context-augmentation CLI-507 Add e2e tests for sonar-context-augmentation May 22, 2026
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