@terreno/ai 0.11.7 → 0.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/routes/routes.test.ts +21 -0
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@types/multer": "^1.4.12",
|
|
23
23
|
"@types/passport-local-mongoose": "^6.1.5",
|
|
24
24
|
"@types/supertest": "^6.0.2",
|
|
25
|
-
"@terreno/api": "0.11.
|
|
25
|
+
"@terreno/api": "0.11.8",
|
|
26
26
|
"mongoose": "8.23.0",
|
|
27
27
|
"passport-local-mongoose": "^9.0.1",
|
|
28
28
|
"supertest": "^7.0.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@terreno/api": "0.11.
|
|
66
|
+
"@terreno/api": "0.11.8",
|
|
67
67
|
"mongoose": "^8.0.0"
|
|
68
68
|
},
|
|
69
69
|
"repository": {
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"test:coverage": "bun run ../scripts/check-coverage.ts"
|
|
83
83
|
},
|
|
84
84
|
"types": "dist/index.d.ts",
|
|
85
|
-
"version": "0.11.
|
|
85
|
+
"version": "0.11.8"
|
|
86
86
|
}
|
|
@@ -321,6 +321,27 @@ describe("AI Routes", () => {
|
|
|
321
321
|
expect(createServerModelFn).toHaveBeenCalledWith("gemini-2.5-pro");
|
|
322
322
|
});
|
|
323
323
|
|
|
324
|
+
it("falls back to default aiService when createServerModelFn returns null", async () => {
|
|
325
|
+
const createServerModelFn = mock((_modelId?: string) => null);
|
|
326
|
+
const customApp = setupServer({
|
|
327
|
+
addRoutes: (router, options) => {
|
|
328
|
+
addGptRoutes(router, {aiService, createServerModelFn, openApiOptions: options});
|
|
329
|
+
},
|
|
330
|
+
skipListen: true,
|
|
331
|
+
userModel: UserModel,
|
|
332
|
+
});
|
|
333
|
+
const agent = await authAsUser(customApp, "notAdmin");
|
|
334
|
+
const res = await agent
|
|
335
|
+
.post("/gpt/prompt")
|
|
336
|
+
.send({model: "unsupported-model", prompt: "Hi"})
|
|
337
|
+
.buffer(true)
|
|
338
|
+
.parse(sseCollect);
|
|
339
|
+
expect(res.status).toBe(200);
|
|
340
|
+
expect(createServerModelFn).toHaveBeenCalledWith("unsupported-model");
|
|
341
|
+
const body = (res as SseResponse).body;
|
|
342
|
+
expect(body).toContain("done");
|
|
343
|
+
});
|
|
344
|
+
|
|
324
345
|
it("rejects history from another user", async () => {
|
|
325
346
|
const otherUserId = new mongoose.Types.ObjectId();
|
|
326
347
|
const other = await GptHistory.create({
|