Enhance unit tests for settings service and error handling

- Add comprehensive unit tests for SettingsService, covering global and project settings management, including creation, updates, and merging with defaults.
- Implement tests for handling credentials, ensuring proper masking and merging of API keys.
- Introduce tests for migration from localStorage, validating successful data transfer and error handling.
- Enhance error handling in subprocess management tests, ensuring robust timeout and output reading scenarios.
This commit is contained in:
Cody Seibert
2025-12-20 09:03:32 -05:00
parent ace736c7c2
commit c76ba691a4
8 changed files with 1019 additions and 3 deletions

View File

@@ -234,6 +234,30 @@ describe("claude-provider.ts", () => {
}),
});
});
it("should handle errors during execution and rethrow", async () => {
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
const testError = new Error("SDK execution failed");
vi.mocked(sdk.query).mockReturnValue(
(async function* () {
throw testError;
})()
);
const generator = provider.executeQuery({
prompt: "Test",
cwd: "/test",
});
await expect(collectAsyncGenerator(generator)).rejects.toThrow("SDK execution failed");
expect(consoleErrorSpy).toHaveBeenCalledWith(
"[ClaudeProvider] executeQuery() error during execution:",
testError
);
consoleErrorSpy.mockRestore();
});
});
describe("detectInstallation", () => {