test: command hints, discover-and-add-mcps, sql.analyze success semantics#440
test: command hints, discover-and-add-mcps, sql.analyze success semantics#440anandgupta42 wants to merge 1 commit intomainfrom
Conversation
…tics Guard against AI-5975 regression (sql.analyze success:false on issues) and verify the new discover-and-add-mcps builtin command (#409) is registered. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_01BUHCukhUhWNtR82r8iedHG
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review.
Tip: disable this comment in your organization's Code Review settings.
📝 WalkthroughWalkthroughThree new test files have been added to validate SQL analyzer output shapes via Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/opencode/test/altimate/sql-analyze-format.test.ts`:
- Around line 72-83: The test "successful result has all required properties"
currently only checks the shape of SqlAnalyzeResult returned by
Dispatcher.call("sql.analyze") but doesn't assert the success path; update the
test to explicitly assert that result.success is true (e.g.,
expect(result.success).toBe(true)) after the call so the test actually enforces
a successful result rather than merely the response shape; keep the existing
shape checks for result.issues and result.confidence_factors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0f53220e-b69c-4a7f-8f1b-a9f6127aa113
📒 Files selected for processing (3)
packages/opencode/test/altimate/sql-analyze-format.test.tspackages/opencode/test/command/hints-discover-mcps.test.tspackages/opencode/test/fixture/fixture.ts
| test("successful result has all required properties", async () => { | ||
| const result = await Dispatcher.call("sql.analyze", { | ||
| sql: "SELECT 1 LIMIT 1", | ||
| }) as SqlAnalyzeResult | ||
| expect(result).toHaveProperty("success") | ||
| expect(result).toHaveProperty("issues") | ||
| expect(result).toHaveProperty("issue_count") | ||
| expect(result).toHaveProperty("confidence") | ||
| expect(result).toHaveProperty("confidence_factors") | ||
| expect(Array.isArray(result.issues)).toBe(true) | ||
| expect(Array.isArray(result.confidence_factors)).toBe(true) | ||
| }) |
There was a problem hiding this comment.
Assert success-path explicitly in the “successful result” test.
The current assertions validate shape only; the failure path also has the same top-level shape. Add an explicit success assertion so this test enforces what its name promises.
✅ Suggested patch
test("successful result has all required properties", async () => {
const result = await Dispatcher.call("sql.analyze", {
sql: "SELECT 1 LIMIT 1",
}) as SqlAnalyzeResult
+ expect(result.success).toBe(true)
+ expect(result.error).toBeUndefined()
expect(result).toHaveProperty("success")
expect(result).toHaveProperty("issues")
expect(result).toHaveProperty("issue_count")
expect(result).toHaveProperty("confidence")
expect(result).toHaveProperty("confidence_factors")
expect(Array.isArray(result.issues)).toBe(true)
expect(Array.isArray(result.confidence_factors)).toBe(true)
})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test("successful result has all required properties", async () => { | |
| const result = await Dispatcher.call("sql.analyze", { | |
| sql: "SELECT 1 LIMIT 1", | |
| }) as SqlAnalyzeResult | |
| expect(result).toHaveProperty("success") | |
| expect(result).toHaveProperty("issues") | |
| expect(result).toHaveProperty("issue_count") | |
| expect(result).toHaveProperty("confidence") | |
| expect(result).toHaveProperty("confidence_factors") | |
| expect(Array.isArray(result.issues)).toBe(true) | |
| expect(Array.isArray(result.confidence_factors)).toBe(true) | |
| }) | |
| test("successful result has all required properties", async () => { | |
| const result = await Dispatcher.call("sql.analyze", { | |
| sql: "SELECT 1 LIMIT 1", | |
| }) as SqlAnalyzeResult | |
| expect(result.success).toBe(true) | |
| expect(result.error).toBeUndefined() | |
| expect(result).toHaveProperty("success") | |
| expect(result).toHaveProperty("issues") | |
| expect(result).toHaveProperty("issue_count") | |
| expect(result).toHaveProperty("confidence") | |
| expect(result).toHaveProperty("confidence_factors") | |
| expect(Array.isArray(result.issues)).toBe(true) | |
| expect(Array.isArray(result.confidence_factors)).toBe(true) | |
| }) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/opencode/test/altimate/sql-analyze-format.test.ts` around lines 72 -
83, The test "successful result has all required properties" currently only
checks the shape of SqlAnalyzeResult returned by Dispatcher.call("sql.analyze")
but doesn't assert the success path; update the test to explicitly assert that
result.success is true (e.g., expect(result.success).toBe(true)) after the call
so the test actually enforces a successful result rather than merely the
response shape; keep the existing shape checks for result.issues and
result.confidence_factors.
Consolidates tests from PRs #440, #441, #479, #483, #484, #485, #490, #491, #492, #495, #496. Deduplicates overlapping MongoDB normalize tests (3 PRs → 1), `keybind` tests (2 PRs → 1), and `connections.test.ts` additions (4 PRs → 1 merged file). New test files: - `sql-analyze-tool.test.ts` — `SqlAnalyzeTool` formatting (6 tests) - `sql-analyze-format.test.ts` — `sql.analyze` success semantics + dispatcher (5 tests) - `builtin-commands.test.ts` — altimate builtin command registration (10 tests) - `hints-discover-mcps.test.ts` — `Command.hints()` + discover-and-add-mcps (11 tests) - `fingerprint-detect.test.ts` — file-based project detection rules (11 tests) - `dbt-lineage-helpers.test.ts` — dbt lineage helper functions (13 tests) - `registry-env-loading.test.ts` — `ALTIMATE_CODE_CONN_*` env var loading (8 tests) - `warehouse-telemetry.test.ts` — MongoDB auth detection telemetry (4 tests) - `bus-event.test.ts` — bus event registry payloads (5 tests) - `git.test.ts` — git utility functions (5 tests) - `keybind.test.ts` — keybind parsing, matching, `fromParsedKey` (22 tests) Merged into existing files: - `connections.test.ts` — `loadFromEnv` (5), `detectAuthMethod` (14), credential stripping (1), `containerToConfig` (1), dbt profiles edge cases (3) - `driver-normalize.test.ts` — MongoDB alias resolution (13 tests) Fixes: - `fixture.ts` — disable `commit.gpgsign` in test tmpdir to prevent CI failures - `hints-discover-mcps.test.ts` — corrected sort order expectation - `registry-env-loading.test.ts` — fixed flaky assertion that assumed isolated env Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Consolidated into #498. Tests deduplicated and merged into a single PR. |
Summary
What does this PR do?
1.
Command.hints()—src/command/index.ts(6 new tests)This pure function extracts
$1,$2,$ARGUMENTSplaceholders from command templates and is used by the TUI to display argument hints. Zero tests existed. New coverage includes:$10sorts before$2— the actual contract)$ARGUMENTSextraction, combined numbered +$ARGUMENTSextraction$0as a valid placeholder2.
discover-and-add-mcpsbuiltin command —src/command/index.ts(5 new tests)PR #409 shipped this as a builtin command (previously only existed as a project-level
.opencode/command/file). Zero tests verified it was registered. New coverage includes:Command.Default.DISCOVER_MCPSconstant is setCommand.list()andCommand.get()mcp_discovertool3.
sql.analyzeDispatcher method —src/altimate/native/sql/register.ts(5 new tests)The AI-5975 fix changed success semantics: finding lint/semantic/safety issues IS a successful analysis (
success: true). Previously it returnedsuccess: falsewhen issues were found, causing ~4,000 false "unknown error" telemetry entries per day. New coverage includes:success: trueissue_countmatchesissuesarray length (with non-vacuous guard)lint,semantic,safetyInfrastructure fix: Added
git config commit.gpgsign falsetotest/fixture/fixture.tstmpdir helper to prevent git signing failures in CI/Codespace environments.Type of change
Issue for this PR
N/A — proactive test coverage
How did you verify your code works?
Checklist
https://claude.ai/code/session_01BUHCukhUhWNtR82r8iedHG
Summary by CodeRabbit
Release Notes