Files
oh-my-pi/packages/coding-agent/test/tools/web-search-code-context.test.ts
T
can1357 bc2b99f9b0 feat(coding-agent): removed grep.app provider, consolidated code search to Exa
- Removed grep.app code search provider support; code search now uses Exa exclusively.
- Removed `providers.codeSearch` configuration setting and related UI options from settings schema.
- Removed `setPreferredCodeSearchProvider` and `isCodeSearchProviderId` exports from public API.
- Simplified code search implementation by eliminating provider selection logic and grep-specific parsing.
2026-03-30 13:44:52 +02:00

40 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { hookFetch } from "@oh-my-pi/pi-utils";
import { executeCodeSearch } from "../../src/web/search/code-search";
function getFirstTextContent(result: { content: Array<{ type: string; text?: string }> }): string {
const firstContent = result.content[0];
if (firstContent?.type === "text") return firstContent.text ?? "";
return "";
}
describe("code_search", () => {
it("normalizes Exa response and surfaces it as code search result", async () => {
using _hook = hookFetch(
() =>
new Response(
JSON.stringify({
result: {
content: [
{
type: "text",
text: "Need the official or source-backed way to silence direnv loading output.",
},
],
},
}),
{ status: 200, headers: { "Content-Type": "application/json" } },
),
);
const result = await executeCodeSearch({ query: "DIRENV_LOG_FORMAT direnv loading silence" });
const output = getFirstTextContent(result);
expect(output).toContain("Code search via exa");
expect(output).toContain("Need the official or source-backed way to silence direnv loading output.");
expect(result.details?.provider).toBe("exa");
expect(result.details?.response?.sources[0]?.snippet).toContain(
"Need the official or source-backed way to silence direnv loading output.",
);
});
});