Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

1.3 KB
Raw Blame
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
const fixture = vi.hoisted(() => ({ status: null, options: null }));
vi.mock('../hooks/useMaintenance.js', () => ({ useMaintenance: options => { fixture.options = options; return { status: fixture.status }; } }));
import MaintenanceBanner from './MaintenanceBanner.jsx';

const show = status => { fixture.status = status; return render(<MemoryRouter><MaintenanceBanner /></MemoryRouter>); };

describe('MaintenanceBanner', () => {
  it('uses the coarse banner mode and renders the draining blocker count', () => {
    show({ state: 'draining', blockerCount: 3 });
    expect(fixture.options).toEqual({ mode: 'banner' });
    expect(screen.getByRole('status')).toHaveTextContent('3 operation(s) finishing');
  });
  it('renders nothing for normal operation and a warning for unavailable state', () => {
    const { container, unmount } = show({ state: 'normal', blockerCount: 0 });
    expect(container).toBeEmptyDOMElement();
    unmount();
    show({ state: 'unavailable', blockerCount: 0 });
    expect(screen.getByRole('status')).toHaveTextContent('recovery needed');
    expect(screen.getByRole('link', { name: 'View maintenance' })).toHaveAttribute('href', '/settings/general');
  });
});