feat: add CLI Apps settings MVP

This commit is contained in:
Xubin Ren
2026-05-23 00:33:31 +08:00
parent a5a956d9af
commit e2d00ffc8f
44 changed files with 4338 additions and 77 deletions
+29
View File
@@ -2,10 +2,12 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import {
deleteSession,
fetchCliApps,
fetchSidebarState,
fetchWebuiThread,
listSessions,
listSlashCommands,
runCliAppAction,
updateSidebarState,
updateImageGenerationSettings,
updateProviderSettings,
@@ -116,6 +118,33 @@ describe("webui API helpers", () => {
);
});
it("reads CLI Apps catalog and serializes actions", async () => {
vi.mocked(fetch).mockResolvedValueOnce({
ok: true,
json: async () => ({
apps: [],
installed_count: 0,
catalog_updated_at: "2026-04-18",
}),
} as Response);
await expect(fetchCliApps("tok")).resolves.toMatchObject({ apps: [] });
expect(fetch).toHaveBeenCalledWith(
"/api/settings/cli-apps",
expect.objectContaining({
headers: { Authorization: "Bearer tok" },
}),
);
await runCliAppAction("tok", "install", "gimp");
expect(fetch).toHaveBeenCalledWith(
"/api/settings/cli-apps/install?name=gimp",
expect.objectContaining({
headers: { Authorization: "Bearer tok" },
}),
);
});
it("reads and writes persisted sidebar state", async () => {
const state = {
schema_version: 1,