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.

1.7 KB
Raw Blame
import { renderToStaticMarkup } from 'react-dom/server';
import { describe, expect, it, vi } from 'vitest';

import { ModelHubRenderBoundary } from './ModelHubCapabilityGate';
import {
  MODEL_HUB_DISABLED_REDIRECT,
  MODEL_HUB_SETTINGS_PATH,
  modelHubRouteTarget,
} from './modelHubRoutes';

describe('Model Hub capability route gate', () => {
  it('redirects the canonical model route while disabled', () => {
    expect(modelHubRouteTarget(MODEL_HUB_SETTINGS_PATH, false)).toBe(MODEL_HUB_DISABLED_REDIRECT);
    expect(modelHubRouteTarget(MODEL_HUB_SETTINGS_PATH, false, true)).toBe('/settings/general');
    expect(modelHubRouteTarget(MODEL_HUB_SETTINGS_PATH, true, true)).toBe(MODEL_HUB_SETTINGS_PATH);
  });

  it('does not render the Models child while disabled or unresolved', () => {
    const ModelsChunk = vi.fn(() => <div>models chunk</div>);

    const disabledHtml = renderToStaticMarkup(
      <ModelHubRenderBoundary enabled={false} disabled={<div>disabled</div>}>
        <ModelsChunk />
      </ModelHubRenderBoundary>,
    );
    const unresolvedHtml = renderToStaticMarkup(
      <ModelHubRenderBoundary enabled={null}>
        <ModelsChunk />
      </ModelHubRenderBoundary>,
    );

    expect(disabledHtml).toContain('disabled');
    expect(unresolvedHtml).toBe('');
    expect(ModelsChunk).not.toHaveBeenCalled();
  });

  it('renders the Models child only after the backend enables it', () => {
    const ModelsChunk = vi.fn(() => <div>models chunk</div>);

    expect(
      renderToStaticMarkup(
        <ModelHubRenderBoundary enabled>
          <ModelsChunk />
        </ModelHubRenderBoundary>,
      ),
    ).toContain('models chunk');
    expect(ModelsChunk).toHaveBeenCalledTimes(1);
  });
});