import { describe, expect, it } from 'vitest';
import * as Primitives from '@/components/ui/Primitives';

/**
 * UX-1 — Primitives export-presence guard.
 *
 * `src/components/ui/Primitives.tsx` is the single sanctioned adapter for the
 * shared `@bytelyst/ui` layer (enforced by the `no-restricted-imports` ratchet
 * in `eslint.config.mjs`). If a re-export silently disappears, every consumer
 * breaks at build time — this test fails fast instead, and documents the
 * surface the rest of admin-web is allowed to rely on.
 */

// Product-specific component implementations + helpers defined locally.
const LOCAL_EXPORTS = [
  'Button',
  'IconButton',
  'Input',
  'Select',
  'Textarea',
  'Badge',
  'ProductStatusBadge',
  'statusToneFor',
] as const;

// Shared `@bytelyst/ui` primitives re-exported through the adapter.
const SHARED_REEXPORTS = [
  'ActionMenu',
  'AlertBanner',
  'DataList',
  'DataTable',
  'Drawer',
  'EmptyState',
  'EntityCard',
  'Field',
  'FieldLabel',
  'FilterBar',
  'FormSection',
  'MetricCard',
  'Modal',
  'PageHeader',
  'Panel',
  'PanelHeader',
  'PanelTitle',
  'Skeleton',
  'Timeline',
  'Toolbar',
] as const;

describe('Primitives adapter exports', () => {
  it.each(LOCAL_EXPORTS)('exposes local export %s', name => {
    expect(Primitives[name as keyof typeof Primitives]).toBeDefined();
  });

  it.each(SHARED_REEXPORTS)('re-exports shared @bytelyst/ui primitive %s', name => {
    expect(Primitives[name as keyof typeof Primitives]).toBeDefined();
  });

  it('maps product statuses to a known tone (helper is wired)', () => {
    expect(Primitives.statusToneFor('active')).toBe('success');
    expect(Primitives.statusToneFor('failed')).toBe('error');
    expect(Primitives.statusToneFor(null)).toBe('neutral');
    expect(Primitives.statusToneFor('totally-unknown')).toBe('neutral');
  });
});
