import { describe, it, expect } from 'vitest';
import { renderOperatorPackStatus, renderSummary } from './summary.js';
import type { SetupConfig } from './config.js';

describe('renderSummary', () => {
  it('renders operator-pack related automation and backup state', () => {
    const config = {
      models: {
        default: { provider: 'anthropic', model: 'claude-sonnet' },
      },
      server: { port: 18800, localhost: true },
      automation: {
        heartbeat: { enabled: true },
        daily_briefing: { enabled: true },
        minio_sync: { enabled: true },
      },
      backup: {
        enabled: true,
        schedule: '0 2 * * *',
      },
    } as unknown as SetupConfig;

    const output = renderSummary(config);
    expect(output).toContain('Automation: heartbeat, daily-briefing, minio-sync');
    expect(output).toContain('Backup:     enabled (cron 0 2 * * *)');
  });

  it('renders compact operator pack status line with routing when enabled', () => {
    const config = {
      models: {
        default: { provider: 'anthropic', model: 'claude-sonnet' },
      },
      server: { port: 18800, localhost: true },
      automation: {
        heartbeat: {
          enabled: true,
          notify: { channel: 'telegram', peer: '123' },
        },
        daily_briefing: { enabled: true },
      },
      backup: {
        enabled: true,
        notify: { channel: 'telegram', peer: '123' },
      },
    } as unknown as SetupConfig;

    expect(renderOperatorPackStatus(config)).toBe('Operator Pack: enabled (telegram/123)');
  });

  it('renders compact operator pack status line as disabled when partial config', () => {
    const config = {
      models: {
        default: { provider: 'anthropic', model: 'claude-sonnet' },
      },
      server: { port: 18800, localhost: true },
      automation: {
        heartbeat: { enabled: true },
      },
      backup: {
        enabled: true,
      },
    } as unknown as SetupConfig;

    expect(renderOperatorPackStatus(config)).toBe('Operator Pack: disabled');
  });
});
