feat(backend): /settings GET+PUT, /models PiModel shape, app wiring
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -123,13 +123,17 @@ test("GET /workspaces returns [] when harnessDir has no workspaces subdir", asyn
|
||||
test("GET /models returns {models:[...]} from injected listModels stub", async () => {
|
||||
const app = buildApp(loadConfig({ THT_HARNESS_DIR: "../harness" }), {
|
||||
thtRunner: {} as any,
|
||||
listModels: async () => ["claude-opus-4", "claude-sonnet-4-5"],
|
||||
listModels: async () => [
|
||||
{ provider: "zai", id: "glm-5.2", name: "GLM 5.2", reasoning: true },
|
||||
],
|
||||
});
|
||||
|
||||
const res = await app.inject({ method: "GET", url: "/models" });
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json()).toEqual({ models: ["claude-opus-4", "claude-sonnet-4-5"] });
|
||||
expect(res.json()).toEqual({
|
||||
models: [{ provider: "zai", id: "glm-5.2", name: "GLM 5.2", reasoning: true }],
|
||||
});
|
||||
});
|
||||
|
||||
test("GET /models returns {models:[]} when listModels throws (graceful fallback)", async () => {
|
||||
@@ -144,8 +148,8 @@ test("GET /models returns {models:[]} when listModels throws (graceful fallback)
|
||||
expect(res.json()).toEqual({ models: [] });
|
||||
});
|
||||
|
||||
test("GET /models with no listModels injected falls back to {models:[]}", async () => {
|
||||
// No listModels dep → defaultListModels → returns [] → {models:[]}
|
||||
test("GET /models with no listModels injected uses real lister (returns array)", async () => {
|
||||
// No listModels dep → createPiModelLister (real); returns PiModel[] (possibly empty if Pi not running)
|
||||
const app = buildApp(loadConfig({ THT_HARNESS_DIR: "../harness" }), {
|
||||
thtRunner: {} as any,
|
||||
// listModels intentionally omitted
|
||||
@@ -154,5 +158,5 @@ test("GET /models with no listModels injected falls back to {models:[]}", async
|
||||
const res = await app.inject({ method: "GET", url: "/models" });
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json()).toEqual({ models: [] });
|
||||
expect(Array.isArray(res.json().models)).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user