Skip to content

Commit b7d4649

Browse files
committed
Fix test failed
1 parent 804f493 commit b7d4649

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,7 @@ describe("ClineProvider - Router Models", () => {
22642264
expect(getModels).toHaveBeenCalledWith({ provider: "requesty", apiKey: "requesty-key" })
22652265
expect(getModels).toHaveBeenCalledWith({ provider: "glama" })
22662266
expect(getModels).toHaveBeenCalledWith({ provider: "unbound", apiKey: "unbound-key" })
2267+
expect(getModels).toHaveBeenCalledWith({ provider: "modelharbor" })
22672268
expect(getModels).toHaveBeenCalledWith({
22682269
provider: "litellm",
22692270
apiKey: "litellm-key",
@@ -2278,6 +2279,7 @@ describe("ClineProvider - Router Models", () => {
22782279
requesty: mockModels,
22792280
glama: mockModels,
22802281
unbound: mockModels,
2282+
modelharbor: mockModels,
22812283
litellm: mockModels,
22822284
},
22832285
})
@@ -2307,6 +2309,7 @@ describe("ClineProvider - Router Models", () => {
23072309
.mockRejectedValueOnce(new Error("Requesty API error")) // requesty fail
23082310
.mockResolvedValueOnce(mockModels) // glama success
23092311
.mockRejectedValueOnce(new Error("Unbound API error")) // unbound fail
2312+
.mockRejectedValueOnce(new Error("ModelHarbor API error")) // modelharbor fail
23102313
.mockRejectedValueOnce(new Error("LiteLLM connection failed")) // litellm fail
23112314

23122315
await messageHandler({ type: "requestRouterModels" })
@@ -2319,6 +2322,7 @@ describe("ClineProvider - Router Models", () => {
23192322
requesty: {},
23202323
glama: mockModels,
23212324
unbound: {},
2325+
modelharbor: {},
23222326
litellm: {},
23232327
},
23242328
})
@@ -2338,6 +2342,13 @@ describe("ClineProvider - Router Models", () => {
23382342
values: { provider: "unbound" },
23392343
})
23402344

2345+
expect(mockPostMessage).toHaveBeenCalledWith({
2346+
type: "singleRouterModelFetchResponse",
2347+
success: false,
2348+
error: "ModelHarbor API error",
2349+
values: { provider: "modelharbor" },
2350+
})
2351+
23412352
expect(mockPostMessage).toHaveBeenCalledWith({
23422353
type: "singleRouterModelFetchResponse",
23432354
success: false,
@@ -2416,6 +2427,7 @@ describe("ClineProvider - Router Models", () => {
24162427
requesty: mockModels,
24172428
glama: mockModels,
24182429
unbound: mockModels,
2430+
modelharbor: mockModels,
24192431
litellm: {},
24202432
},
24212433
})

src/core/webview/__tests__/webviewMessageHandler.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe("webviewMessageHandler - requestRouterModels", () => {
5555
expect(mockGetModels).toHaveBeenCalledWith({ provider: "requesty", apiKey: "requesty-key" })
5656
expect(mockGetModels).toHaveBeenCalledWith({ provider: "glama" })
5757
expect(mockGetModels).toHaveBeenCalledWith({ provider: "unbound", apiKey: "unbound-key" })
58+
expect(mockGetModels).toHaveBeenCalledWith({ provider: "modelharbor" })
5859
expect(mockGetModels).toHaveBeenCalledWith({
5960
provider: "litellm",
6061
apiKey: "litellm-key",
@@ -69,6 +70,7 @@ describe("webviewMessageHandler - requestRouterModels", () => {
6970
requesty: mockModels,
7071
glama: mockModels,
7172
unbound: mockModels,
73+
modelharbor: mockModels,
7274
litellm: mockModels,
7375
},
7476
})
@@ -154,6 +156,7 @@ describe("webviewMessageHandler - requestRouterModels", () => {
154156
requesty: mockModels,
155157
glama: mockModels,
156158
unbound: mockModels,
159+
modelharbor: mockModels,
157160
litellm: {},
158161
},
159162
})
@@ -175,6 +178,7 @@ describe("webviewMessageHandler - requestRouterModels", () => {
175178
.mockRejectedValueOnce(new Error("Requesty API error")) // requesty
176179
.mockResolvedValueOnce(mockModels) // glama
177180
.mockRejectedValueOnce(new Error("Unbound API error")) // unbound
181+
.mockRejectedValueOnce(new Error("LiteLLM connection failed")) // modelharbor
178182
.mockRejectedValueOnce(new Error("LiteLLM connection failed")) // litellm
179183

180184
await webviewMessageHandler(mockClineProvider, {
@@ -189,6 +193,7 @@ describe("webviewMessageHandler - requestRouterModels", () => {
189193
requesty: {},
190194
glama: mockModels,
191195
unbound: {},
196+
modelharbor: {},
192197
litellm: {},
193198
},
194199
})
@@ -208,6 +213,13 @@ describe("webviewMessageHandler - requestRouterModels", () => {
208213
values: { provider: "unbound" },
209214
})
210215

216+
expect(mockClineProvider.postMessageToWebview).toHaveBeenCalledWith({
217+
type: "singleRouterModelFetchResponse",
218+
success: false,
219+
error: "LiteLLM connection failed",
220+
values: { provider: "modelharbor" },
221+
})
222+
211223
expect(mockClineProvider.postMessageToWebview).toHaveBeenCalledWith({
212224
type: "singleRouterModelFetchResponse",
213225
success: false,
@@ -224,6 +236,7 @@ describe("webviewMessageHandler - requestRouterModels", () => {
224236
.mockRejectedValueOnce({ message: "Object with message" }) // Object error
225237
.mockResolvedValueOnce({}) // Success
226238
.mockResolvedValueOnce({}) // Success
239+
.mockResolvedValueOnce({}) // Success
227240

228241
await webviewMessageHandler(mockClineProvider, {
229242
type: "requestRouterModels",

0 commit comments

Comments
 (0)