Skip to content

Commit 94e7402

Browse files
hannesrudolphclaude
andcommitted
Fix diagnostics tests by adding workspace.getConfiguration mock
- Add mock for vscode.workspace.getConfiguration in diagnostics test - Update all test calls to include includeDiagnostics: true option - Tests now properly handle the configuration-based approach 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 23516a3 commit 94e7402

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.claude/settings.local.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"permissions": {
3+
"allow": ["Bash(find:*)", "Bash(grep:*)", "Bash(mkdir:*)", "Bash(npm run:*)", "Bash(npx tsc:*)"],
4+
"deny": []
5+
}
6+
}

src/integrations/diagnostics/__tests__/diagnostics.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ vitest.mock("vscode", () => ({
6464
stat: vitest.fn(),
6565
},
6666
openTextDocument: vitest.fn(),
67+
getConfiguration: vitest.fn(() => ({
68+
get: vitest.fn((key, defaultValue) => {
69+
// Return default values for diagnostics configuration
70+
if (key === "includeDiagnostics") return false
71+
if (key === "maxDiagnosticsCount") return 50
72+
if (key === "diagnosticsFilter") return []
73+
return defaultValue
74+
}),
75+
})),
6776
},
6877
}))
6978

@@ -103,6 +112,7 @@ describe("diagnosticsToProblemsString", () => {
103112
[[fileUri, diagnostics]],
104113
[vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning],
105114
"/path/to",
115+
{ includeDiagnostics: true },
106116
)
107117

108118
// Verify only Error and Warning diagnostics are included
@@ -147,6 +157,7 @@ describe("diagnosticsToProblemsString", () => {
147157
[[dirUri, [diagnostic]]],
148158
[vscode.DiagnosticSeverity.Error],
149159
"/path/to",
160+
{ includeDiagnostics: true },
150161
)
151162

152163
// Verify fs.stat was called with the directory URI
@@ -204,6 +215,7 @@ describe("diagnosticsToProblemsString", () => {
204215
[[fileUri, diagnostics]],
205216
[vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning, vscode.DiagnosticSeverity.Information],
206217
"/path/to",
218+
{ includeDiagnostics: true },
207219
)
208220

209221
// Verify all diagnostics are included in the output
@@ -277,6 +289,7 @@ describe("diagnosticsToProblemsString", () => {
277289
],
278290
[vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning, vscode.DiagnosticSeverity.Information],
279291
"/path/to",
292+
{ includeDiagnostics: true },
280293
)
281294

282295
// Verify file paths are correctly shown with relative paths
@@ -333,6 +346,7 @@ describe("diagnosticsToProblemsString", () => {
333346
[[fileUri, diagnostics]],
334347
[vscode.DiagnosticSeverity.Information, vscode.DiagnosticSeverity.Hint],
335348
"/path/to",
349+
{ includeDiagnostics: true },
336350
)
337351

338352
// Verify empty string is returned
@@ -373,6 +387,7 @@ describe("diagnosticsToProblemsString", () => {
373387
[[fileUri, [diagnostic]]],
374388
[vscode.DiagnosticSeverity.Error],
375389
"/project/root",
390+
{ includeDiagnostics: true },
376391
)
377392

378393
// Verify exact output format

0 commit comments

Comments
 (0)