import { describe, expect, it } from 'bun:test';
import { renderToStaticMarkup } from 'react-dom/server';
import { TerminalOutput } from './TerminalOutput';
import type { TerminalEntry } from '../../types/terminal';

describe('TerminalOutput', () => {
  it('renders the filings panel variant', () => {
    const history: TerminalEntry[] = [
      {
        id: 'command-1',
        type: 'command',
        content: '/filings AAPL',
        timestamp: new Date('2026-04-17T12:00:00Z'),
      },
      {
        id: 'panel-1',
        type: 'panel',
        content: {
          type: 'filings',
          data: {
            symbol: 'AAPL',
            companyName: 'Apple Inc.',
            cik: '0000320193',
            items: [
              {
                accessionNumber: '0000320193-25-000010',
                filingDate: '2025-02-01',
                reportDate: '2024-12-31',
                form: '10-K',
                primaryDocument: 'annual.htm',
                filingUrl:
                  'https://www.sec.gov/Archives/edgar/data/320193/000032019325000010/annual.htm',
                overview: 'Annual report',
              },
            ],
            page: 1,
            pageSize: 25,
            totalResults: 1,
            totalPages: 1,
            latestFiling: {
              accessionNumber: '0000320193-25-000010',
              filingDate: '2025-02-01',
              reportDate: '2024-12-31',
              form: '10-K',
              primaryDocument: 'annual.htm',
              filingUrl:
                'https://www.sec.gov/Archives/edgar/data/320193/000032019325000010/annual.htm',
              overview: 'Annual report',
            },
          },
        },
        timestamp: new Date('2026-04-17T12:00:01Z'),
      },
    ];

    const html = renderToStaticMarkup(
      <TerminalOutput
        workspaceId="workspace-1"
        history={history}
        scrollTop={0}
        stickToBottom
        collapsedThinkingEntryIds={[]}
        onScrollStateChange={() => {}}
        onToggleThinkingEntry={() => {}}
        onRunCommand={() => {}}
        onStartPortfolioAction={() => {}}
      />,
    );

    expect(html).toContain('Apple Inc.');
    expect(html).toContain('SEC filing history');
    expect(html).toContain('annual.htm');
  });
});
