Revert "revert tests"

This reverts commit cdc71422a9.
This commit is contained in:
uinstinct 2025-08-07 12:02:11 +05:30
parent cdc71422a9
commit 2c2db8f967

View file

@ -710,4 +710,94 @@ describe("CodebaseIndexer", () => {
});
});
});
describe("getIndexesToBuild", () => {
let indexer: CodebaseIndexer;
let mockConfig: any;
let mockEmbeddingsModel: any;
let mockIdeSettings: any;
beforeEach(() => {
indexer = new CodebaseIndexer(
testConfigHandler,
testIde,
mockMessenger as any,
false,
);
mockEmbeddingsModel = {
maxEmbeddingChunkSize: 1000,
model: "test-model",
provider: "test-provider",
};
mockIdeSettings = {
remoteConfigServerUrl: "http://test.com",
userToken: "test-token",
};
mockConfig = {
selectedModelByRole: {
embed: mockEmbeddingsModel,
},
contextProviders: [],
};
jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings);
});
afterEach(() => {
jest.clearAllMocks();
});
test("should create specific indexTypes for the requested context providers", async () => {
mockConfig.contextProviders = [
{
description: {
dependsOnIndexing: ["chunk", "codeSnippets"],
},
},
];
jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({
config: mockConfig,
errors: [],
configLoadInterrupted: false,
});
const indexes = (await (
indexer as any
).getIndexesToBuild()) as CodebaseIndex[];
expect(indexes).toHaveLength(2);
expect(indexes[0].artifactId).toBe("chunks");
expect(indexes[1].artifactId).toBe("codeSnippets");
});
test("should handle duplicate contexts", async () => {
mockConfig.contextProviders = [
{
description: {
dependsOnIndexing: ["codeSnippets"],
},
},
{
description: {
dependsOnIndexing: ["codeSnippets"],
},
},
];
jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({
config: mockConfig,
errors: [],
configLoadInterrupted: false,
});
const indexes = await (indexer as any).getIndexesToBuild();
expect(indexes).toHaveLength(1);
expect(indexes[0].artifactId).toBe("codeSnippets");
});
});
});