Fix bug 1: Only fetch Anthropic models when API key exists
getAnthropicModels() was called unconditionally on mount, causing a console error when no API key was set. Now chains the call after getAnthropicApiKeyExists() confirms a key is present. Includes regression test added before the fix per bug workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -592,4 +592,17 @@ describe("Chat review panel", () => {
|
||||
|
||||
expect(await screen.findByText("Cannot read stories")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not fetch Anthropic models when no API key exists", async () => {
|
||||
mockedApi.getAnthropicApiKeyExists.mockResolvedValue(false);
|
||||
mockedApi.getAnthropicModels.mockClear();
|
||||
|
||||
render(<Chat projectPath="/tmp/project" onCloseProject={vi.fn()} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockedApi.getAnthropicApiKeyExists).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
expect(mockedApi.getAnthropicModels).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user