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

const sampleNote: ResearchNote = {
  id: 'note-1',
  workspaceId: 'workspace-1',
  rawText: 'Management says enterprise demand improved sequentially.',
  cleanedText: 'Management says enterprise demand improved sequentially.',
  embeds: [],
  fileIds: [],
  title: 'Demand improving',
  noteType: 'management_signal',
  analystStatus: 'captured',
  aiAnnotation: 'Signals demand stabilization, but operating evidence still needs confirmation.',
  confidence: 0.82,
  evidenceStatus: 'source_linked',
  inferredLinks: [],
  ghostStatus: 'candidate_input',
  thesisStatus: 'candidate_support',
  createdAt: '2026-04-09T10:00:00Z',
  updatedAt: '2026-04-09T10:00:00Z',
  provenance: {
    createdBy: 'manual',
    captureMethod: 'quick_entry',
    sourceKind: 'manual',
    createdAt: '2026-04-09T10:00:00Z',
    rawInputHash: 'hash',
  },
  tags: ['earnings'],
  catalysts: ['margin expansion'],
  risks: ['commentary unconfirmed'],
  valuationRefs: [],
  priority: 'high',
  pinned: false,
  archived: false,
  revision: 1,
};

describe('NoteCard', () => {
  it('renders note metadata and annotation', () => {
    const html = renderToStaticMarkup(
      <NoteCard note={sampleNote} density="comfortable" />,
    );

    expect(html).toContain('Demand improving');
    expect(html).toContain('Mgmt Signal');
    expect(html).toContain('Source linked');
    expect(html).toContain('Signals demand stabilization');
  });

  it('renders attachment count when files are linked', () => {
    const html = renderToStaticMarkup(
      <NoteCard note={{ ...sampleNote, fileIds: ['file-1', 'file-2'] }} density="compact" />,
    );

    expect(html).toContain('2');
  });
});
