import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';

import { CustomWorldAgentDraftDetailPanel } from './CustomWorldAgentDraftDetailPanel';

test('draft detail panel renders editable form in edit mode', () => {
  const html = renderToStaticMarkup(
    <CustomWorldAgentDraftDetailPanel
      detail={{
        id: 'character-1',
        kind: 'character',
        title: '沈砺',
        sections: [
          {
            id: 'name',
            label: '角色名',
            value: '沈砺',
          },
          {
            id: 'publicMask',
            label: '外显身份',
            value: '守灯会里最熟悉旧航道的人。',
          },
          {
            id: 'summary',
            label: '角色摘要',
            value: '他像旧友，但也像一把始终没收回鞘的刀。',
          },
        ],
        linkedIds: ['thread-1'],
        locked: false,
        editable: true,
        editableSectionIds: ['name', 'publicMask', 'summary'],
        warningMessages: [],
      }}
      loading={false}
      editMode
      onClose={() => {}}
      onCancelEdit={() => {}}
      onSave={() => {}}
    />,
  );

  expect(html).toContain('保存');
  expect(html).toContain('取消');
  expect(html).toContain('角色名');
  expect(html).toContain('textarea');
});
