From 94e74027ab81cf169cdca88564440aba6467f863 Mon Sep 17 00:00:00 2001 From: hannesrudolph Date: Mon, 16 Jun 2025 11:29:44 -0600 Subject: [PATCH] Fix diagnostics tests by adding workspace.getConfiguration mock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .claude/settings.local.json | 6 ++++++ .../diagnostics/__tests__/diagnostics.spec.ts | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000000..f43e8eedeb --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,6 @@ +{ + "permissions": { + "allow": ["Bash(find:*)", "Bash(grep:*)", "Bash(mkdir:*)", "Bash(npm run:*)", "Bash(npx tsc:*)"], + "deny": [] + } +} diff --git a/src/integrations/diagnostics/__tests__/diagnostics.spec.ts b/src/integrations/diagnostics/__tests__/diagnostics.spec.ts index 0df472a75f..c91925d171 100644 --- a/src/integrations/diagnostics/__tests__/diagnostics.spec.ts +++ b/src/integrations/diagnostics/__tests__/diagnostics.spec.ts @@ -64,6 +64,15 @@ vitest.mock("vscode", () => ({ stat: vitest.fn(), }, openTextDocument: vitest.fn(), + getConfiguration: vitest.fn(() => ({ + get: vitest.fn((key, defaultValue) => { + // Return default values for diagnostics configuration + if (key === "includeDiagnostics") return false + if (key === "maxDiagnosticsCount") return 50 + if (key === "diagnosticsFilter") return [] + return defaultValue + }), + })), }, })) @@ -103,6 +112,7 @@ describe("diagnosticsToProblemsString", () => { [[fileUri, diagnostics]], [vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning], "/path/to", + { includeDiagnostics: true }, ) // Verify only Error and Warning diagnostics are included @@ -147,6 +157,7 @@ describe("diagnosticsToProblemsString", () => { [[dirUri, [diagnostic]]], [vscode.DiagnosticSeverity.Error], "/path/to", + { includeDiagnostics: true }, ) // Verify fs.stat was called with the directory URI @@ -204,6 +215,7 @@ describe("diagnosticsToProblemsString", () => { [[fileUri, diagnostics]], [vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning, vscode.DiagnosticSeverity.Information], "/path/to", + { includeDiagnostics: true }, ) // Verify all diagnostics are included in the output @@ -277,6 +289,7 @@ describe("diagnosticsToProblemsString", () => { ], [vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning, vscode.DiagnosticSeverity.Information], "/path/to", + { includeDiagnostics: true }, ) // Verify file paths are correctly shown with relative paths @@ -333,6 +346,7 @@ describe("diagnosticsToProblemsString", () => { [[fileUri, diagnostics]], [vscode.DiagnosticSeverity.Information, vscode.DiagnosticSeverity.Hint], "/path/to", + { includeDiagnostics: true }, ) // Verify empty string is returned @@ -373,6 +387,7 @@ describe("diagnosticsToProblemsString", () => { [[fileUri, [diagnostic]]], [vscode.DiagnosticSeverity.Error], "/project/root", + { includeDiagnostics: true }, ) // Verify exact output format