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.

3.6 KB
Raw Blame
import { expect, test } from '@playwright/test';
import { hub } from '../support/copy';

for (const lang of ['en', 'zh'] as const) {
  for (const long of [false, true]) {
    test(`MH-GATEWAY-STATUS-001: gateway status and Agent details remain separate without overflow (${lang}, long=${long})`, async ({ page }) => {
      await page.goto(`/e2e/model-catalog/fixture.html?view=gateway&backend=opencode&lang=${lang}${long ? '&long=1' : ''}`);
      const card = page.locator('[data-agent-backend="opencode"]');
      const head = card.locator('[data-agent-group-head]');
      await expect(head).toContainText(lang === 'zh' ? '网关 · 路由可用' : 'Gateway · Ready');
      await expect(head).not.toContainText('grok');
      await expect(card.locator('[data-route-model]')).toHaveCount(5);
      const issues = card.locator('[data-agent-supply-issues]');
      const toggle = issues.getByRole('button');
      await expect(toggle).toHaveAttribute('aria-expanded', 'false');
      await expect(issues.locator('ul')).toBeHidden();
      const headBefore = await head.boundingBox();
      await toggle.click();
      await expect(toggle).toHaveAttribute('aria-expanded', 'true');
      await expect(issues.locator('ul')).toBeVisible();
      await expect(issues).toContainText(long ? 'long-model-id-' : 'grok/grok-4.6');
      await expect(issues).toContainText(lang === 'zh' ? '模型名不存在' : 'is not a known model name');
      expect(await head.boundingBox()).toEqual(headBefore);
      const overflow = await card.evaluate((element) => {
        const box = element.getBoundingClientRect();
        return [...element.querySelectorAll<HTMLElement>('[data-agent-supply-issue] p, [data-agent-supply-issues] button > span, .model-hub-agent-mode-trigger > span')]
          .filter((node) => node.scrollWidth > node.clientWidth + 1 || node.getBoundingClientRect().right > box.right + 1)
          .map((node) => node.textContent);
      });
      expect(overflow).toEqual([]);
      expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
      await page.screenshot({ path: test.info().outputPath('gateway-expanded.png'), fullPage: true, scale: 'css' });
      await toggle.focus();
      await page.keyboard.press('Enter');
      await expect(issues.locator('ul')).toBeHidden();
    });
  }

  test(`MH-GATEWAY-STATUS-001: every route status fits the compact mode trigger (${lang})`, async ({ page }) => {
    for (const status of ['empty', 'unknown', 'unconfigured', 'available', 'partial', 'unavailable']) {
      await test.step(status, async () => {
        await page.goto(`/e2e/model-catalog/fixture.html?view=gateway&backend=opencode&lang=${lang}&status=${status}`);
        const trigger = page.locator('.model-hub-agent-mode-trigger');
        await expect(trigger).toContainText(hub(`gateway.routeStatus.${status}`, {}, lang));
        // Platform fallback fonts have different widths; reserve room for a wider fallback too.
        for (const font of ['inherit', 'monospace']) {
          await trigger.evaluate((element, family) => { element.style.fontFamily = family; }, font);
          const label = trigger.locator('span').last();
          const size = await label.evaluate((element) => ({ available: element.clientWidth, text: element.scrollWidth }));
          expect(size.text, `${status}/${font}`).toBeLessThanOrEqual(size.available + 1);
          expect((await trigger.boundingBox())!.width).toBeLessThanOrEqual(190);
          expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
        }
      });
    }
  });
}