feat(ai): unify model discovery and effort handling
This commit is contained in:
+16
-2
@@ -29,8 +29,8 @@ test("AI composer labels an empty template selection explicitly", () => {
|
||||
});
|
||||
|
||||
test("AI composer exposes mode and action as one compact selector", () => {
|
||||
const footerStart = source.indexOf('<!-- Combined mode + action selector -->');
|
||||
const footerEnd = source.indexOf('<!-- Combined provider + model selector -->', footerStart);
|
||||
const footerStart = source.indexOf("<!-- Combined mode + action selector -->");
|
||||
const footerEnd = source.indexOf("<!-- Combined provider + model selector -->", footerStart);
|
||||
const footer = source.slice(footerStart, footerEnd);
|
||||
|
||||
assert.notEqual(footerStart, -1, "the combined mode and action selector should exist");
|
||||
@@ -45,6 +45,20 @@ test("AI composer exposes mode and action as one compact selector", () => {
|
||||
assert.match(source, /function selectModeActionItem\(action: AiAction\) \{\s*\/\/ Vector databases[\s\S]*?if \(!showActionButtons\.value\) return;/);
|
||||
});
|
||||
|
||||
test("AI effort control opens as a hoverable side submenu", () => {
|
||||
const selectorStart = source.indexOf("<!-- Combined provider + model selector -->");
|
||||
const selectorEnd = source.indexOf("</template>", source.indexOf("</Popover>", selectorStart));
|
||||
const selector = source.slice(selectorStart, selectorEnd);
|
||||
|
||||
assert.notEqual(selectorStart, -1, "the combined provider and model selector should exist");
|
||||
assert.match(selector, /<Popover v-model:open="effortMenuOpen">/);
|
||||
assert.match(selector, /<PopoverAnchor as-child>/);
|
||||
assert.match(selector, /@mouseenter="openEffortMenu"/);
|
||||
assert.match(selector, /@mouseleave="scheduleEffortMenuClose"/);
|
||||
assert.match(selector, /<PopoverContent[\s\S]*?side="left"[\s\S]*?:side-offset="6"/);
|
||||
assert.doesNotMatch(selector, /v-if="effortPanelOpen"/);
|
||||
});
|
||||
|
||||
test("AI composer template remains compilable", () => {
|
||||
const { descriptor, errors } = parse(source, { filename: aiAssistantPath });
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
+5
-10
@@ -9,6 +9,8 @@ const apiMock = vi.hoisted(() => ({
|
||||
setDefaultAiConfig: vi.fn<[string]>().mockResolvedValue(undefined),
|
||||
loadAiConfigs: vi.fn<[]>().mockResolvedValue([]),
|
||||
saveAiConfigs: vi.fn<[unknown[]]>().mockResolvedValue(undefined),
|
||||
loadAiChatSelection: vi.fn<[]>().mockResolvedValue(null),
|
||||
saveAiChatSelection: vi.fn<[unknown]>().mockResolvedValue(undefined),
|
||||
loadEditorSettings: vi.fn<[]>().mockResolvedValue(null),
|
||||
saveEditorSettings: vi.fn<[unknown]>().mockResolvedValue(undefined),
|
||||
loadDesktopSettings: vi.fn<[]>().mockResolvedValue(null),
|
||||
@@ -23,10 +25,7 @@ test("createAiConfig rejects -> state unchanged", async () => {
|
||||
apiMock.saveAiConfigItem.mockRejectedValueOnce(new Error("db error"));
|
||||
|
||||
const store = useSettingsStore();
|
||||
await assert.rejects(
|
||||
() => store.createAiConfig({ id: "c1", name: "test", isDefault: false } as any),
|
||||
/db error/,
|
||||
);
|
||||
await assert.rejects(() => store.createAiConfig({ id: "c1", name: "test", isDefault: false } as any), /db error/);
|
||||
assert.equal(store.aiConfigs.length, 0);
|
||||
});
|
||||
|
||||
@@ -103,9 +102,7 @@ test("reloadAiConfigs resets and reloads from API", async () => {
|
||||
const store = useSettingsStore();
|
||||
store.aiConfigs.push({ id: "old", name: "stale", isDefault: true } as any);
|
||||
|
||||
apiMock.loadAiConfigs.mockResolvedValueOnce([
|
||||
{ id: "fresh", name: "fresh", isDefault: true } as any,
|
||||
]);
|
||||
apiMock.loadAiConfigs.mockResolvedValueOnce([{ id: "fresh", name: "fresh", model: "m", isDefault: true } as any]);
|
||||
|
||||
await store.reloadAiConfigs();
|
||||
assert.equal(store.aiConfigs.length, 1);
|
||||
@@ -121,9 +118,7 @@ test("reloadAiConfigs falls back when active config was deleted", async () => {
|
||||
store.aiConfigs.push({ id: "remaining", name: "r", model: "m", isDefault: true } as any);
|
||||
store.activeModel = { configId: "deleted", modelId: "gone" };
|
||||
|
||||
apiMock.loadAiConfigs.mockResolvedValueOnce([
|
||||
{ id: "remaining", name: "r", model: "m", isDefault: true } as any,
|
||||
]);
|
||||
apiMock.loadAiConfigs.mockResolvedValueOnce([{ id: "remaining", name: "r", model: "m", isDefault: true } as any]);
|
||||
|
||||
await store.reloadAiConfigs();
|
||||
assert.equal(store.aiConfigs.length, 1);
|
||||
|
||||
Reference in New Issue
Block a user