Skip to content

Commit f7b031b

Browse files
committed
fix test
1 parent f072e8f commit f7b031b

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

‎frontend/src/components/ai/__tests__/ai-utils.test.ts‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ describe("ai-utils", () => {
6161
describe("getConfiguredProvider", () => {
6262
it("should return undefined when no AI config", () => {
6363
const config: UserConfig = {} as UserConfig;
64-
expect(getConfiguredProvider(config)).toBeUndefined();
64+
expect(getConfiguredProvider(config.ai)).toBeUndefined();
6565
});
6666

6767
it("should return undefined when AI config has no credentials", () => {
6868
const config: UserConfig = {
6969
ai: {},
7070
} as UserConfig;
71-
expect(getConfiguredProvider(config)).toBeUndefined();
71+
expect(getConfiguredProvider(config.ai)).toBeUndefined();
7272
});
7373

7474
it("should return openai when OpenAI API key is set", () => {
@@ -77,7 +77,7 @@ describe("ai-utils", () => {
7777
open_ai: { api_key: "sk-test" },
7878
},
7979
} as UserConfig;
80-
expect(getConfiguredProvider(config)).toBe("openai");
80+
expect(getConfiguredProvider(config.ai)).toBe("openai");
8181
});
8282

8383
it("should return anthropic when Anthropic API key is set", () => {
@@ -86,7 +86,7 @@ describe("ai-utils", () => {
8686
anthropic: { api_key: "sk-ant-test" },
8787
},
8888
} as UserConfig;
89-
expect(getConfiguredProvider(config)).toBe("anthropic");
89+
expect(getConfiguredProvider(config.ai)).toBe("anthropic");
9090
});
9191

9292
it("should return google when Google API key is set", () => {
@@ -95,7 +95,7 @@ describe("ai-utils", () => {
9595
google: { api_key: "google-key" },
9696
},
9797
} as UserConfig;
98-
expect(getConfiguredProvider(config)).toBe("google");
98+
expect(getConfiguredProvider(config.ai)).toBe("google");
9999
});
100100

101101
it("should return ollama when Ollama base URL is set", () => {
@@ -104,7 +104,7 @@ describe("ai-utils", () => {
104104
ollama: { base_url: "http://localhost:11434" },
105105
},
106106
} as UserConfig;
107-
expect(getConfiguredProvider(config)).toBe("ollama");
107+
expect(getConfiguredProvider(config.ai)).toBe("ollama");
108108
});
109109

110110
it("should return azure only when both API key and base URL are set", () => {
@@ -113,7 +113,7 @@ describe("ai-utils", () => {
113113
azure: { api_key: "azure-key", base_url: "https://azure.com" },
114114
},
115115
} as UserConfig;
116-
expect(getConfiguredProvider(config)).toBe("azure");
116+
expect(getConfiguredProvider(config.ai)).toBe("azure");
117117
});
118118

119119
it("should return undefined for azure with only API key", () => {
@@ -122,7 +122,7 @@ describe("ai-utils", () => {
122122
azure: { api_key: "azure-key" },
123123
},
124124
} as UserConfig;
125-
expect(getConfiguredProvider(config)).toBeUndefined();
125+
expect(getConfiguredProvider(config.ai)).toBeUndefined();
126126
});
127127

128128
it("should return custom provider when configured", () => {
@@ -133,14 +133,14 @@ describe("ai-utils", () => {
133133
},
134134
},
135135
} as unknown as UserConfig;
136-
expect(getConfiguredProvider(config)).toBe("my_provider");
136+
expect(getConfiguredProvider(config.ai)).toBe("my_provider");
137137
});
138138
});
139139

140140
describe("getRecommendedModel", () => {
141141
it("should return undefined when no provider is configured", () => {
142142
const config: UserConfig = {} as UserConfig;
143-
expect(getRecommendedModel(config)).toBeUndefined();
143+
expect(getRecommendedModel(config.ai)).toBeUndefined();
144144
});
145145

146146
it("should return openai model when OpenAI is configured", () => {
@@ -149,7 +149,7 @@ describe("ai-utils", () => {
149149
open_ai: { api_key: "sk-test" },
150150
},
151151
} as UserConfig;
152-
expect(getRecommendedModel(config)).toBe("openai/gpt-4");
152+
expect(getRecommendedModel(config.ai)).toBe("openai/gpt-4");
153153
});
154154

155155
it("should return anthropic model when Anthropic is configured", () => {
@@ -158,7 +158,7 @@ describe("ai-utils", () => {
158158
anthropic: { api_key: "sk-ant-test" },
159159
},
160160
} as UserConfig;
161-
expect(getRecommendedModel(config)).toBe("anthropic/claude-3-sonnet");
161+
expect(getRecommendedModel(config.ai)).toBe("anthropic/claude-3-sonnet");
162162
});
163163

164164
it("should return google model when Google is configured", () => {
@@ -167,7 +167,7 @@ describe("ai-utils", () => {
167167
google: { api_key: "google-key" },
168168
},
169169
} as UserConfig;
170-
expect(getRecommendedModel(config)).toBe("google/gemini-pro");
170+
expect(getRecommendedModel(config.ai)).toBe("google/gemini-pro");
171171
});
172172

173173
it("should return ollama model when Ollama is configured", () => {
@@ -176,7 +176,7 @@ describe("ai-utils", () => {
176176
ollama: { base_url: "http://localhost:11434" },
177177
},
178178
} as UserConfig;
179-
expect(getRecommendedModel(config)).toBe("ollama/llama2");
179+
expect(getRecommendedModel(config.ai)).toBe("ollama/llama2");
180180
});
181181
});
182182

@@ -194,7 +194,7 @@ describe("ai-utils", () => {
194194
},
195195
} as unknown as UserConfig;
196196

197-
const result = autoPopulateModels(values);
197+
const result = autoPopulateModels(values.ai);
198198

199199
expect(result.chatModel).toBeUndefined();
200200
expect(result.editModel).toBeUndefined();
@@ -205,7 +205,7 @@ describe("ai-utils", () => {
205205
ai: {},
206206
} as UserConfig;
207207

208-
const result = autoPopulateModels(values);
208+
const result = autoPopulateModels(values.ai);
209209

210210
expect(result.chatModel).toBeUndefined();
211211
expect(result.editModel).toBeUndefined();
@@ -218,7 +218,7 @@ describe("ai-utils", () => {
218218
},
219219
} as UserConfig;
220220

221-
const result = autoPopulateModels(values);
221+
const result = autoPopulateModels(values.ai);
222222

223223
expect(result.chatModel).toBe("openai/gpt-4");
224224
expect(result.editModel).toBe("openai/gpt-4");
@@ -236,7 +236,7 @@ describe("ai-utils", () => {
236236
},
237237
} as unknown as UserConfig;
238238

239-
const result = autoPopulateModels(values);
239+
const result = autoPopulateModels(values.ai);
240240

241241
expect(result.chatModel).toBe("openai/gpt-4");
242242
expect(result.editModel).toBeUndefined();
@@ -254,7 +254,7 @@ describe("ai-utils", () => {
254254
},
255255
} as unknown as UserConfig;
256256

257-
const result = autoPopulateModels(values);
257+
const result = autoPopulateModels(values.ai);
258258

259259
expect(result.chatModel).toBeUndefined();
260260
expect(result.editModel).toBe("openai/gpt-4");
@@ -267,7 +267,7 @@ describe("ai-utils", () => {
267267
},
268268
} as UserConfig;
269269

270-
const result = autoPopulateModels(values);
270+
const result = autoPopulateModels(values.ai);
271271

272272
expect(result.chatModel).toBe("anthropic/claude-3-sonnet");
273273
expect(result.editModel).toBe("anthropic/claude-3-sonnet");

0 commit comments

Comments
 (0)