import { describe, expect, it } from 'bun:test';
import { renderToStaticMarkup } from 'react-dom/server';
import { UniverModelGrid } from './UniverModelGrid';
import type { FinancialModel } from '../../../types/research';

describe('UniverModelGrid', () => {
  it('renders workbook cells without requiring the embedded Univer canvas runtime', () => {
    const model: FinancialModel = {
      id: 'model-1',
      workspaceId: 'workspace-1',
      name: 'QCOM 3-Statement Model',
      ticker: 'QCOM',
      templateType: 'three_statement',
      workbookJson: {
        version: 1,
        activeSheetId: 'revenue_build',
        sheets: [
          {
            id: 'revenue_build',
            name: 'Revenue Build',
            cells: {
              A1: { value: 'Revenue Build' },
              A3: { value: 'Metric' },
              B3: { value: 'FY 2023' },
              C3: { value: 'FY 2024' },
              D3: { value: 'FY 2025' },
              A8: { value: 'Total Revenue' },
              B8: { value: 1000, format: 'currency' },
              E8: { formula: '=SUM(E5:E7)', format: 'currency' },
            },
          },
        ],
      },
      annotations: [],
      createdAt: '2026-01-01T00:00:00Z',
      updatedAt: '2026-01-01T00:00:00Z',
    };

    const html = renderToStaticMarkup(
      <UniverModelGrid
        model={model}
        activeSheetId="revenue_build"
        onActiveSheetChange={() => {}}
        onWorkbookChange={() => {}}
      />,
    );

    expect(html).toContain('Revenue Build');
    expect(html).toContain('FY 2023');
    expect(html).toContain('FY 2025');
    expect(html).toContain('Total Revenue');
    expect(html).toContain('=SUM(E5:E7)');
  });
});
