Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

test(model-hub): dismiss inherited route inspection correctly (#1899)

Call White2f7d9a21c5ef
diff --git a/ui/e2e/d-routing.spec.ts b/ui/e2e/d-routing.spec.ts
index 91983f729..d0d19d21e 100644
--- a/ui/e2e/d-routing.spec.ts
+++ b/ui/e2e/d-routing.spec.ts
@@ -23,7 +23,7 @@ test.describe('D: inherited routes, manual editing, and default routing', () =>
await expect(dialog).toBeVisible();
await expect(dialog.getByRole('button', { name: copy('routeDialog.addHop'), exact: true })).toHaveCount(0);
await expect(dialog.getByRole('button', { name: copy('routeDialog.grip'), exact: true })).toHaveCount(0);
- await labelledButton(dialog, copy('routeDialog.cancel')).click();
+ await labelledButton(dialog, copy('routing.close')).click();
await expect(dialog).toHaveCount(0);
const row = hub.routeRow(gateway.backend, gateway.model);
diff --git a/ui/src/components/settings/models/RouteChainDialog.test.tsx b/ui/src/components/settings/models/RouteChainDialog.test.tsx
index 178005a40..46f352cc8 100644
--- a/ui/src/components/settings/models/RouteChainDialog.test.tsx
+++ b/ui/src/components/settings/models/RouteChainDialog.test.tsx
@@ -1,5 +1,5 @@
// @vitest-environment jsdom
-import { act, cleanup, render, screen, waitFor } from "@testing-library/react";
+import { act, cleanup, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { I18nextProvider } from "react-i18next";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -187,6 +187,67 @@ afterEach(() => {
});
describe("RouteChainDialog", () => {
+ it('closes inherited inspection with visible Close, not the icon-only Cancel command', async () => {
+ const user = userEvent.setup();
+ const inherited: AgentChain = { ...chain, manual_override: null, route_origin: 'automatic' };
+ vi.spyOn(modelsApi, 'getAgentChain').mockResolvedValue(inherited);
+ const put = vi.spyOn(modelsApi, 'putAgentChain');
+ const restore = vi.spyOn(modelsApi, 'restoreAgentChain');
+ const close = vi.fn();
+ render(<I18nextProvider i18n={i18n}><RouteChainDialog
+ selection={{ agent, modelId: 'opus-5', read: readyRegion(inherited) }}
+ sources={sources} onClose={close} readAgents={vi.fn()} readSources={vi.fn()}
+ /></I18nextProvider>);
+
+ await screen.findByRole('button', { name: 'Edit route' });
+ const footer = within(document.querySelector<HTMLElement>('.model-hub-route-foot')!);
+ const dismiss = footer.getByRole('button', { name: 'Close' });
+ expect(dismiss.textContent).toBe('Close');
+ expect(footer.queryByRole('button', { name: 'Cancel' })).toBeNull();
+ expect(screen.getByRole('button', { name: 'Cancel' }).textContent).toBe('');
+ expect(screen.queryByRole('button', { name: 'Add a hop' })).toBeNull();
+ await user.click(dismiss);
+ expect(close).toHaveBeenCalledTimes(1);
+ expect(put).not.toHaveBeenCalled();
+ expect(restore).not.toHaveBeenCalled();
+ });
+
+ it('uses visible Cancel after Edit and throughout restore preview and undo without writing', async () => {
+ const user = userEvent.setup();
+ const inherited: AgentChain = { ...chain, manual_override: null, route_origin: 'automatic' };
+ vi.spyOn(modelsApi, 'getAgentChain').mockResolvedValue(inherited);
+ const preview = vi.spyOn(modelsApi, 'previewAgentChain').mockResolvedValue(inherited);
+ const put = vi.spyOn(modelsApi, 'putAgentChain');
+ const restore = vi.spyOn(modelsApi, 'restoreAgentChain');
+ const close = vi.fn();
+ render(<I18nextProvider i18n={i18n}><RouteChainDialog
+ selection={{ agent, modelId: 'opus-5', read: readyRegion(inherited) }}
+ sources={sources} onClose={close} readAgents={vi.fn()} readSources={vi.fn()}
+ /></I18nextProvider>);
+
+ await user.click(await screen.findByRole('button', { name: 'Edit route' }));
+ const footer = within(document.querySelector<HTMLElement>('.model-hub-route-foot')!);
+ expect(footer.getByRole('button', { name: 'Cancel' }).textContent).toBe('Cancel');
+ expect(footer.queryByRole('button', { name: 'Close' })).toBeNull();
+ expect(screen.getAllByRole('button', { name: 'Remove hop' })).toHaveLength(2);
+
+ await user.click(screen.getByRole('button', { name: 'Restore automatic' }));
+ await screen.findByRole('button', { name: 'Undo restore' });
+ expect(preview).toHaveBeenCalledWith('claude', 'opus-5', { manual_override: null });
+ expect(footer.getByRole('button', { name: 'Cancel' }).textContent).toBe('Cancel');
+ expect(footer.queryByRole('button', { name: 'Close' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Remove hop' })).toBeNull();
+
+ await user.click(screen.getByRole('button', { name: 'Undo restore' }));
+ expect(footer.getByRole('button', { name: 'Cancel' }).textContent).toBe('Cancel');
+ expect(footer.queryByRole('button', { name: 'Close' })).toBeNull();
+ expect(screen.getAllByRole('button', { name: 'Remove hop' })).toHaveLength(2);
+ await user.click(footer.getByRole('button', { name: 'Cancel' }));
+ expect(close).toHaveBeenCalledTimes(1);
+ expect(put).not.toHaveBeenCalled();
+ expect(restore).not.toHaveBeenCalled();
+ });
+
describe('manual edit capability from an empty inherited route', () => {
const inherited: AgentChain = {
...chain,