|
|
@@ -32,7 +32,7 @@ describe("CodeIndexConfigManager", () => {
|
|
|
describe("constructor", () => {
|
|
|
it("should initialize with ContextProxy", () => {
|
|
|
expect(configManager).toBeDefined()
|
|
|
- expect(configManager.isFeatureEnabled).toBe(false)
|
|
|
+ expect(configManager.isFeatureEnabled).toBe(true)
|
|
|
expect(configManager.currentEmbedderProvider).toBe("openai")
|
|
|
})
|
|
|
})
|
|
|
@@ -45,7 +45,6 @@ describe("CodeIndexConfigManager", () => {
|
|
|
const result = await configManager.loadConfiguration()
|
|
|
|
|
|
expect(result.currentConfig).toEqual({
|
|
|
- isEnabled: false,
|
|
|
isConfigured: false,
|
|
|
embedderProvider: "openai",
|
|
|
modelId: undefined,
|
|
|
@@ -77,7 +76,6 @@ describe("CodeIndexConfigManager", () => {
|
|
|
const result = await configManager.loadConfiguration()
|
|
|
|
|
|
expect(result.currentConfig).toEqual({
|
|
|
- isEnabled: true,
|
|
|
isConfigured: true,
|
|
|
embedderProvider: "openai",
|
|
|
modelId: "text-embedding-3-large",
|
|
|
@@ -111,7 +109,6 @@ describe("CodeIndexConfigManager", () => {
|
|
|
const result = await configManager.loadConfiguration()
|
|
|
|
|
|
expect(result.currentConfig).toEqual({
|
|
|
- isEnabled: true,
|
|
|
isConfigured: true,
|
|
|
embedderProvider: "openai-compatible",
|
|
|
modelId: "text-embedding-3-large",
|
|
|
@@ -149,7 +146,6 @@ describe("CodeIndexConfigManager", () => {
|
|
|
const result = await configManager.loadConfiguration()
|
|
|
|
|
|
expect(result.currentConfig).toEqual({
|
|
|
- isEnabled: true,
|
|
|
isConfigured: true,
|
|
|
embedderProvider: "openai-compatible",
|
|
|
modelId: "custom-model",
|
|
|
@@ -188,7 +184,6 @@ describe("CodeIndexConfigManager", () => {
|
|
|
const result = await configManager.loadConfiguration()
|
|
|
|
|
|
expect(result.currentConfig).toEqual({
|
|
|
- isEnabled: true,
|
|
|
isConfigured: true,
|
|
|
embedderProvider: "openai-compatible",
|
|
|
modelId: "custom-model",
|
|
|
@@ -227,7 +222,6 @@ describe("CodeIndexConfigManager", () => {
|
|
|
const result = await configManager.loadConfiguration()
|
|
|
|
|
|
expect(result.currentConfig).toEqual({
|
|
|
- isEnabled: true,
|
|
|
isConfigured: true,
|
|
|
embedderProvider: "openai-compatible",
|
|
|
modelId: "custom-model",
|
|
|
@@ -326,14 +320,14 @@ describe("CodeIndexConfigManager", () => {
|
|
|
})
|
|
|
|
|
|
it("should detect restart requirement when transitioning to enabled+configured", async () => {
|
|
|
- // Initial state - disabled
|
|
|
+ // Initial state - enabled but not configured
|
|
|
mockContextProxy.getGlobalState.mockReturnValue({
|
|
|
- codebaseIndexEnabled: false,
|
|
|
+ codebaseIndexEnabled: true,
|
|
|
})
|
|
|
|
|
|
await configManager.loadConfiguration()
|
|
|
|
|
|
- // Enable and configure
|
|
|
+ // Configure the feature
|
|
|
mockContextProxy.getGlobalState.mockReturnValue({
|
|
|
codebaseIndexEnabled: true,
|
|
|
codebaseIndexQdrantUrl: "http://qdrant.local",
|
|
|
@@ -689,29 +683,28 @@ describe("CodeIndexConfigManager", () => {
|
|
|
expect(result.requiresRestart).toBe(true)
|
|
|
})
|
|
|
|
|
|
- it("should not require restart when disabled remains disabled", async () => {
|
|
|
- // Initial state - disabled but configured
|
|
|
+ it("should require restart when enabled and provider changes even if unconfigured", async () => {
|
|
|
+ // Initial state - enabled but not configured (missing API key)
|
|
|
mockContextProxy.getGlobalState.mockReturnValue({
|
|
|
- codebaseIndexEnabled: false,
|
|
|
+ codebaseIndexEnabled: true,
|
|
|
codebaseIndexQdrantUrl: "http://qdrant.local",
|
|
|
codebaseIndexEmbedderProvider: "openai",
|
|
|
})
|
|
|
- setupSecretMocks({
|
|
|
- codeIndexOpenAiKey: "test-key",
|
|
|
- })
|
|
|
+ setupSecretMocks({})
|
|
|
|
|
|
await configManager.loadConfiguration()
|
|
|
|
|
|
- // Still disabled but change other settings
|
|
|
+ // Still enabled but change provider while remaining unconfigured
|
|
|
mockContextProxy.getGlobalState.mockReturnValue({
|
|
|
- codebaseIndexEnabled: false,
|
|
|
- codebaseIndexQdrantUrl: "http://different-qdrant.local",
|
|
|
+ codebaseIndexEnabled: true,
|
|
|
+ codebaseIndexQdrantUrl: "http://qdrant.local",
|
|
|
codebaseIndexEmbedderProvider: "ollama",
|
|
|
codebaseIndexEmbedderBaseUrl: "http://ollama.local",
|
|
|
})
|
|
|
|
|
|
const result = await configManager.loadConfiguration()
|
|
|
- expect(result.requiresRestart).toBe(false)
|
|
|
+ // Should require restart because provider changed while enabled
|
|
|
+ expect(result.requiresRestart).toBe(true)
|
|
|
})
|
|
|
|
|
|
it("should not require restart when unconfigured remains unconfigured", async () => {
|
|
|
@@ -970,7 +963,7 @@ describe("CodeIndexConfigManager", () => {
|
|
|
it("should not require restart when API keys transition from undefined to empty string", async () => {
|
|
|
// Initial state with undefined API keys
|
|
|
mockContextProxy.getGlobalState.mockReturnValue({
|
|
|
- codebaseIndexEnabled: false, // Start disabled to avoid restart due to enable+configure
|
|
|
+ codebaseIndexEnabled: true, // Always enabled now
|
|
|
codebaseIndexQdrantUrl: "http://qdrant.local",
|
|
|
codebaseIndexEmbedderProvider: "openai",
|
|
|
})
|
|
|
@@ -1208,7 +1201,6 @@ describe("CodeIndexConfigManager", () => {
|
|
|
it("should return correct configuration via getConfig", () => {
|
|
|
const config = configManager.getConfig()
|
|
|
expect(config).toEqual({
|
|
|
- isEnabled: true,
|
|
|
isConfigured: true,
|
|
|
embedderProvider: "openai",
|
|
|
modelId: "text-embedding-3-large",
|
|
|
@@ -1267,7 +1259,7 @@ describe("CodeIndexConfigManager", () => {
|
|
|
it("should properly initialize with current config to prevent false restarts", async () => {
|
|
|
// Setup configuration
|
|
|
mockContextProxy.getGlobalState.mockReturnValue({
|
|
|
- codebaseIndexEnabled: false, // Start disabled to avoid transition restart
|
|
|
+ codebaseIndexEnabled: true, // Always enabled now
|
|
|
codebaseIndexQdrantUrl: "http://qdrant.local",
|
|
|
codebaseIndexEmbedderProvider: "openai",
|
|
|
codebaseIndexEmbedderModelId: "text-embedding-3-small",
|