import { describe, expect, it } from '@jest/globals';
import { buildA2uiArtifact } from './ai-a2ui.artifact';

describe('buildA2uiArtifact', () => {
  it('构造统一 artifact 载荷（id/type/status/messageId/conversationId/payload）', () => {
    const artifact = buildA2uiArtifact({
      type: 'form',
      id: 'form-1',
      status: 'pending',
      messageId: 12,
      conversationId: 3,
      payload: { title: '新增学生' },
    });
    expect(artifact).toEqual({
      id: 'form-1',
      type: 'form',
      status: 'pending',
      messageId: 12,
      conversationId: 3,
      payload: { title: '新增学生' },
    });
  });

  it('未知类型被拒绝', () => {
    expect(() =>
      buildA2uiArtifact({
        type: 'hacker' as never,
        id: 'x',
        status: 'pending',
        messageId: 1,
        conversationId: 1,
        payload: {},
      }),
    ).toThrow();
  });
});
