Repository navigation
test(code-index,tools): cover lines left uncovered by #1297 #1317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
edelauna
merged 6 commits into
Zoo-Code-Org:main
from
easonLiangWorldedtech:fix/coverage-1297-code-index
Sep 11, 2026
+499
−0
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
63dd593
test(code-index,tools): cover remaining lines left uncovered by #1297
easonLiangWorldedtech a36cf86
Merge branch 'main' into fix/coverage-1297-code-index
easonLiangWorldedtech 10e9997
Merge branch 'main' into fix/coverage-1297-code-index
easonLiangWorldedtech 2a4634a
test(code-index): cover missing-Qdrant path and unset modelId forwarding
easonliang28 c17050f
Merge remote-tracking branch 'upstream/main' into fix/coverage-1297-c…
easonliang28 28d3db9
test(code-index): cover missing OpenRouter API key and simplify defen…
easonliang28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2035,4 +2035,132 @@ describe("CodeIndexConfigManager", () => { | |||||||||||
| }) | ||||||||||||
| }) | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| describe("mistral, vercel-ai-gateway and bedrock provider configuration", () => { | ||||||||||||
| it("should load Mistral provider configuration and mark it configured", async () => { | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| codebaseIndexQdrantUrl: "http://qdrant.local", | ||||||||||||
| codebaseIndexEmbedderProvider: providerIdentifiers.mistral, | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockImplementation((key: string) => { | ||||||||||||
| if (key === "codebaseIndexMistralApiKey") return "test-mistral-key" | ||||||||||||
| return undefined | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| const result = await configManager.loadConfiguration() | ||||||||||||
|
|
||||||||||||
| expect(result.currentConfig.embedderProvider).toBe(providerIdentifiers.mistral) | ||||||||||||
| expect(result.currentConfig.mistralOptions).toEqual({ apiKey: "test-mistral-key" }) | ||||||||||||
| expect(result.currentConfig.isConfigured).toBe(true) | ||||||||||||
| expect(configManager.currentEmbedderProvider).toBe("mistral") | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| it("should return false from isConfigured for Mistral when the API key is missing", () => { | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| codebaseIndexQdrantUrl: "http://qdrant.local", | ||||||||||||
| codebaseIndexEmbedderProvider: providerIdentifiers.mistral, | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockReturnValue(undefined) | ||||||||||||
|
|
||||||||||||
| configManager = new CodeIndexConfigManager(mockContextProxy) | ||||||||||||
| expect(configManager.isConfigured()).toBe(false) | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| it("should load Vercel AI Gateway provider configuration and mark it configured", async () => { | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| codebaseIndexQdrantUrl: "http://qdrant.local", | ||||||||||||
| codebaseIndexEmbedderProvider: providerIdentifiers.vercelAiGateway, | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockImplementation((key: string) => { | ||||||||||||
| if (key === "codebaseIndexVercelAiGatewayApiKey") return "test-vercel-key" | ||||||||||||
| return undefined | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| const result = await configManager.loadConfiguration() | ||||||||||||
|
|
||||||||||||
| expect(result.currentConfig.embedderProvider).toBe(providerIdentifiers.vercelAiGateway) | ||||||||||||
| expect(result.currentConfig.vercelAiGatewayOptions).toEqual({ apiKey: "test-vercel-key" }) | ||||||||||||
| expect(result.currentConfig.isConfigured).toBe(true) | ||||||||||||
| expect(configManager.currentEmbedderProvider).toBe("vercel-ai-gateway") | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| it("should return false from isConfigured for Vercel AI Gateway when the API key is missing", () => { | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| codebaseIndexQdrantUrl: "http://qdrant.local", | ||||||||||||
| codebaseIndexEmbedderProvider: providerIdentifiers.vercelAiGateway, | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockReturnValue(undefined) | ||||||||||||
|
|
||||||||||||
| configManager = new CodeIndexConfigManager(mockContextProxy) | ||||||||||||
| expect(configManager.isConfigured()).toBe(false) | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| it("should load Bedrock provider configuration with region and profile and mark it configured", async () => { | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| codebaseIndexQdrantUrl: "http://qdrant.local", | ||||||||||||
| codebaseIndexEmbedderProvider: providerIdentifiers.bedrock, | ||||||||||||
| codebaseIndexBedrockRegion: "eu-west-1", | ||||||||||||
| codebaseIndexBedrockProfile: "test-profile", | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockReturnValue(undefined) | ||||||||||||
|
|
||||||||||||
| const result = await configManager.loadConfiguration() | ||||||||||||
|
|
||||||||||||
| expect(result.currentConfig.embedderProvider).toBe(providerIdentifiers.bedrock) | ||||||||||||
| expect(result.currentConfig.bedrockOptions).toEqual({ region: "eu-west-1", profile: "test-profile" }) | ||||||||||||
| expect(result.currentConfig.isConfigured).toBe(true) | ||||||||||||
| expect(configManager.currentEmbedderProvider).toBe("bedrock") | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| it("should default Bedrock region to us-east-1 when no region is configured", async () => { | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| codebaseIndexQdrantUrl: "http://qdrant.local", | ||||||||||||
| codebaseIndexEmbedderProvider: providerIdentifiers.bedrock, | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockReturnValue(undefined) | ||||||||||||
|
|
||||||||||||
| const result = await configManager.loadConfiguration() | ||||||||||||
|
|
||||||||||||
| expect(result.currentConfig.bedrockOptions).toEqual({ region: "us-east-1", profile: undefined }) | ||||||||||||
| expect(result.currentConfig.isConfigured).toBe(true) | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| it("should return false from isConfigured for Bedrock when the Qdrant URL is missing", () => { | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| codebaseIndexEmbedderProvider: providerIdentifiers.bedrock, | ||||||||||||
| codebaseIndexBedrockRegion: "us-east-1", | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockReturnValue(undefined) | ||||||||||||
|
|
||||||||||||
| configManager = new CodeIndexConfigManager(mockContextProxy) | ||||||||||||
| expect(configManager.isConfigured()).toBe(false) | ||||||||||||
| }) | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| describe("isConfigured defensive fallback", () => { | ||||||||||||
| it("should return false when the provider is not a recognized embedder provider", () => { | ||||||||||||
| // The isConfigured() switch lists every EmbedderProvider member explicitly and | ||||||||||||
| // ends in a defensive `return false` ("Should not happen if embedderProvider is | ||||||||||||
| // always set correctly"). That fallback is unreachable through the public API | ||||||||||||
| // because EmbedderProvider is a closed union, so exercise it by forcing the | ||||||||||||
| // private field to a value outside the union. | ||||||||||||
| mockContextProxy.getGlobalState.mockReturnValue({ | ||||||||||||
| codebaseIndexEnabled: true, | ||||||||||||
| }) | ||||||||||||
| mockContextProxy.getSecret.mockReturnValue(undefined) | ||||||||||||
|
|
||||||||||||
| configManager = new CodeIndexConfigManager(mockContextProxy) | ||||||||||||
| // The private `embedderProvider` field has no public setter; the cast is the | ||||||||||||
| // only way to reach the defensive branch without changing source logic. | ||||||||||||
| Object.defineProperty(configManager, "embedderProvider", { value: "not-a-provider" }) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AGENTS.md prefers bracket notation for TypeScript
Suggested change
|
||||||||||||
| expect(configManager.isConfigured()).toBe(false) | ||||||||||||
| }) | ||||||||||||
| }) | ||||||||||||
| }) | ||||||||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.