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): align live browser routing and protocol contracts (#1898)

Call White0abad3c5b898
diff --git a/docs/plans/model-hub-e2e-test-plan.md b/docs/plans/model-hub-e2e-test-plan.md
index 9c3d3dcf4..d3519f1a7 100644
--- a/docs/plans/model-hub-e2e-test-plan.md
+++ b/docs/plans/model-hub-e2e-test-plan.md
@@ -43,7 +43,7 @@ Out of scope (documented, not dropped silently):
| ID | Steps | Expect | Status |
|---|---|---|---|
| B1 | observe against mock for each protocol, `protocol:'auto'` | correct protocol chosen by response shape; observation payload contract_version 9 | assert |
-| B2 | manual protocol ≠ actual | create refused with matching proof error | assert |
+| B2 | custom user-declared protocol differs from response shape, authentication succeeds | declaration badge and runtime-risk warning stay visible; explicit confirmation persists exactly the chosen protocol, not an inferred one. Authentication remains required. Auto still needs matching shape evidence (2026-09-04 declaration rule; adapter consumer rejects authenticated but unshaped Auto responses). | assert |
| B3 | pull models (mock returns `display_name`, `context_length`, `pricing`, `supported_parameters`) | unrelated metadata is dropped; `supported_parameters` is retained in observation and the provenance ladder applies protocol-default tiers | assert |
| B4 | discovery fails | 422 `inventory_unavailable` unless `accept_unavailable_inventory:true`; then source commits with `state.status=error` | assert |
| B5 | replay create with same `client_nonce` | idempotent, no duplicate source | assert |
diff --git a/ui/e2e/b-add-api-key.spec.ts b/ui/e2e/b-add-api-key.spec.ts
index 5212a1946..2dab290a4 100644
--- a/ui/e2e/b-add-api-key.spec.ts
+++ b/ui/e2e/b-add-api-key.spec.ts
@@ -10,7 +10,6 @@ import type { HubApi } from './support/api';
import { hub as copy } from './support/copy';
import { E2E_SOURCE_PREFIX, mockBaseUrl } from './support/env';
import {
- expectVisibleWithout,
requireMockUpstream,
requireModelHub,
requireRuntimeRunning,
@@ -187,32 +186,35 @@ test.describe('B · add an API-key source', () => {
await expect(hub.addKeyDialog).toBeVisible();
});
- test('B2 · naming the wrong interface is refused, and says why', async ({ hub, mock }) => {
- // The upstream speaks OpenAI Chat Completions; the user insists on Anthropic
- // Messages. The probe path then 404s, so nothing proves the interface.
+ test('B2 · a declared interface is warned about and persisted without claiming response proof', async ({ hub, mock, api }) => {
+ // A concrete custom interface is a declaration, not a response-shape claim.
+ // Authentication still gates it; Auto's shape-proof branch is covered by B1
+ // and test_source_observation_accepts_catalog_pin_and_custom_declaration_without_shape_proof.
await mock.configure({ auth: 'ok', protocol: 'openai_chat', models_endpoint: 'ok' });
+ const name = `${E2E_SOURCE_PREFIX}mismatch`;
await hub.goto();
await hub.addApiKeyButton.click();
await fillApiKeyForm(hub.addKeyDialog, {
- // Prefixed for the same reason as B1's rejected credential: a mismatch
- // that commits anyway must still be sweepable.
- name: `${E2E_SOURCE_PREFIX}mismatch`,
+ name,
baseUrl: mockBaseUrl(),
apiKey: 'e2e-mismatch',
protocol: copy('addKey.protocol.anthropicMessages'),
});
await hub.addKeyDialog.getByRole('button', { name: copy('addKey.detect'), exact: true }).click();
- // "Connected and authenticated, but we cannot tell which interface" — the
- // distinction from a credential failure is the whole point of the copy.
- await expect(hub.addKeyDialog).toContainText(copy('addKey.undetermined.title'), { timeout: 30_000 });
- await expect(hub.addKeyDialog).toContainText(copy('addKey.undetermined.detail'));
- await expectVisibleWithout(hub.addKeyDialog, copy('addKey.fail.auth'));
- // Retry stays available because a different choice is a different probe.
- await expect(
- hub.addKeyDialog.getByRole('button', { name: copy('addKey.retry'), exact: true }),
- ).toBeEnabled();
+ await expect(hub.addKeyDialog.locator('.model-hub-add-key-protocol-badge')).toHaveText(copy('addKey.protocol.declared'));
+ await expect(hub.addKeyDialog).toContainText(copy('addKey.field.protocol.hint'));
+ const confirm = hub.addKeyDialog.getByRole('button', { name: copy('addKey.confirm'), exact: true });
+ await expect(confirm).toBeEnabled({ timeout: 30_000 });
+ expect((await api.sources()).filter((source) => source.display_name === name)).toEqual([]);
+ await confirm.click();
+ await expect(hub.addKeyDialog).toHaveCount(0, { timeout: 30_000 });
+ await expect(hub.sourceDetailDialog).toBeVisible();
+ await expect(hub.sourceDetailDialog).toContainText(name);
+ const saved = (await api.sources()).filter((source) => source.display_name === name);
+ expect(saved).toHaveLength(1);
+ expect(saved[0]).toMatchObject({ vendor: 'custom', protocol: 'anthropic' });
});
test('B3 · Detect reports the count, and only ids survive the save', async ({ hub, mock, api }) => {
diff --git a/ui/e2e/d-routing.spec.ts b/ui/e2e/d-routing.spec.ts
index 9845e7a4e..91983f729 100644
--- a/ui/e2e/d-routing.spec.ts
+++ b/ui/e2e/d-routing.spec.ts
@@ -13,7 +13,7 @@ test.describe('D: inherited routes, manual editing, and default routing', () =>
await requireMockUpstream(mock);
});
- test('D: inherited inspection stays read-only until Edit route', async ({ api, hub, gateway }) => {
+ test('D: inherited inspection stays read-only until Edit route', async ({ api, hub, gateway, page }) => {
const original = await captureAgentChain(api, gateway);
try {
expect(await api.deleteAgentChain(gateway.backend, gateway.model)).toBe(true);
@@ -23,6 +23,41 @@ 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 expect(dialog).toHaveCount(0);
+
+ const row = hub.routeRow(gateway.backend, gateway.model);
+ const badge = row.locator('button.model-hub-route-origin');
+ const help = page.locator('.model-hub-origin-help');
+ await badge.hover();
+ await expect(help).toBeVisible();
+ await expect(dialog).toHaveCount(0);
+ await page.mouse.move(0, 0);
+ await expect(help).toHaveCount(0);
+ await badge.focus();
+ await expect(help).toBeVisible();
+ await expect(dialog).toHaveCount(0);
+ await badge.press('Escape');
+ await expect(help).toHaveCount(0);
+ await badge.click();
+ await expect(help).toBeVisible();
+ await expect(dialog).toHaveCount(0);
+ await badge.press('Escape');
+ await expect(help).toHaveCount(0);
+
+ // The label is pointer-transparent over the actual opener; its center
+ // avoids the separate badge that can cover the full-size button's center.
+ const opener = hub.routeOpener(gateway.backend, gateway.model);
+ const labelBox = await row.getByText(gateway.model, { exact: true }).boundingBox();
+ const openerBox = await opener.boundingBox();
+ expect(labelBox).not.toBeNull();
+ expect(openerBox).not.toBeNull();
+ await opener.click({ position: {
+ x: labelBox!.x + labelBox!.width / 2 - openerBox!.x,
+ y: labelBox!.y + labelBox!.height / 2 - openerBox!.y,
+ } });
+ await expect(dialog).toBeVisible();
+ await expect(dialog.getByRole('button', { name: copy('routeDialog.addHop'), exact: true })).toHaveCount(0);
await labelledButton(dialog, copy('routing.editRoute')).click();
await expect(dialog.getByRole('button', { name: copy('routeDialog.addHop'), exact: true })).toBeVisible();
await expect(dialog.getByRole('button', { name: copy('routeDialog.grip'), exact: true }).first()).toBeVisible();
@@ -53,6 +88,13 @@ test.describe('D: inherited routes, manual editing, and default routing', () =>
await search.press('ArrowDown');
await search.press('Enter');
await search.press('Tab');
+ const selector = page.locator('.model-hub-route-selector');
+ const source = selector.getByLabel(copy('routeDialog.add.source'), { exact: true });
+ const exactModel = selector.getByLabel(copy('routing.exactModel'), { exact: true });
+ await expect(source).toBeFocused();
+ await source.press('Tab');
+ await expect(exactModel).toBeFocused();
+ await exactModel.press('Tab');
const confirm = page.getByRole('button', { name: copy('routeDialog.add.confirm'), exact: true });
await expect(confirm).toBeFocused();
await confirm.press(' ');
diff --git a/ui/e2e/model-route-cleanup.spec.ts b/ui/e2e/model-route-cleanup.spec.ts
index 920fcc7fc..b4a48578e 100644
--- a/ui/e2e/model-route-cleanup.spec.ts
+++ b/ui/e2e/model-route-cleanup.spec.ts
@@ -1,7 +1,8 @@
-import { expect, test } from '@playwright/test';
+import { expect, test, type Page } from '@playwright/test';
import type { AgentChain, HubApi } from './support/api';
import { HubApi as HubApiClient } from './support/api';
+import { ModelHubPage } from './support/hub';
import { captureAgentChain, restoreAgentChain } from './support/restore';
for (const override of [null, { hops: [] }, { hops: [{ source_id: 'src_operator', model_id: 'vendor/model' }] }]) {
@@ -65,3 +66,52 @@ test('gateway fixture cleanup keeps every source that preceded this test', async
await HubApiClient.prototype.removeSuiteSources.call(client, new Set(['src_previous_fixture', 'src_operator']));
expect(removed).toEqual(['src_this_fixture']);
});
+
+for (const collapsed of [false, true]) {
+ test(`route opening targets the model command, not the badge-covered row (${collapsed ? 'collapsed' : 'visible'})`, async () => {
+ let expanded = !collapsed;
+ let opened = false;
+ let helpOpened = false;
+ const commands: string[] = [];
+ const opener = {
+ focus: async () => { commands.push('focus model opener'); },
+ press: async (key: string) => {
+ expect(key).toBe('Enter');
+ expect(commands.at(-1)).toBe('focus model opener');
+ commands.push('activate model opener');
+ opened = true;
+ },
+ };
+ const row = {
+ count: async () => expanded ? 1 : 0,
+ // Models the live failure: the whole-row center activates its separate badge.
+ click: async () => { helpOpened = true; },
+ locator: (selector: string) => {
+ expect(selector).toBe('button.model-hub-model-open');
+ return opener;
+ },
+ };
+ const card = {
+ waitFor: async () => {},
+ locator: (selector: string) => {
+ expect(selector).toBe('.model-hub-model-collapse');
+ return { first: () => ({ count: async () => 1, click: async () => { expanded = true; commands.push('expand models'); } }) };
+ },
+ };
+ const page = {
+ locator: (selector: string) => {
+ if (selector === '[data-agent-backend="claude"]') return card;
+ expect(selector).toBe('[data-route-backend="claude"][data-route-model="model-id"]');
+ return row;
+ },
+ } as unknown as Page;
+
+ await new ModelHubPage(page).openRoute('claude', 'model-id');
+
+ expect(opened).toBe(true);
+ expect(helpOpened).toBe(false);
+ expect(commands).toEqual([
+ ...(collapsed ? ['expand models'] : []), 'focus model opener', 'activate model opener',
+ ]);
+ });
+}
diff --git a/ui/e2e/support/hub.ts b/ui/e2e/support/hub.ts
index 1df56c05a..05c011240 100644
--- a/ui/e2e/support/hub.ts
+++ b/ui/e2e/support/hub.ts
@@ -132,6 +132,10 @@ export class ModelHubPage {
return this.page.locator(attr('data-route-backend', backend) + attr('data-route-model', model));
}
+ routeOpener(backend: string, model: string): Locator {
+ return this.routeRow(backend, model).locator('button.model-hub-model-open');
+ }
+
async openRoute(backend: string, model: string): Promise<void> {
await this.agentCard(backend).waitFor({ state: 'visible' });
const row = this.routeRow(backend, model);
@@ -139,7 +143,10 @@ export class ModelHubPage {
const expand = this.agentCard(backend).locator('.model-hub-model-collapse').first();
if (await expand.count()) await expand.click();
}
- await row.click();
+ // The row center can belong to its separate origin-help badge.
+ const opener = this.routeOpener(backend, model);
+ await opener.focus();
+ await opener.press('Enter');
}
/** The card collapses its model list, so a spec that just needs *a* route