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

import { CustomWorldAgentWorkspace } from './CustomWorldAgentWorkspace';

test('custom world agent workspace renders minimum loop chat layout', () => {
  const html = renderToStaticMarkup(
    <CustomWorldAgentWorkspace
      session={{
        sessionId: 'custom-world-agent-session-1',
        currentTurn: 3,
        anchorContent: {
          worldPromise: {
            hook: '一个被潮雾改写航线秩序的群岛世界。',
            differentiator: '所有人都要为每一次借路付出代价。',
            desiredExperience: '压迫、悬疑、带一点海上传奇感',
          },
          playerFantasy: null,
          themeBoundary: null,
          playerEntryPoint: null,
          coreConflict: null,
          keyRelationships: [],
          hiddenLines: null,
          iconicElements: null,
        },
        progressPercent: 42,
        lastAssistantReply: '我先把世界底色收住了，接下来想确认玩家会怎么被卷进来。',
        stage: 'collecting_intent',
        focusCardId: null,
        creatorIntent: {},
        creatorIntentReadiness: {
          isReady: false,
          completedKeys: ['world_hook'],
          missingKeys: [
            'player_premise',
            'theme_and_tone',
            'core_conflict',
            'relationship_seed',
            'iconic_element',
          ],
        },
        anchorPack: {},
        lockState: {},
        draftProfile: null,
        messages: [
          {
            id: 'message-1',
            role: 'assistant',
            kind: 'chat',
            text: '先告诉我你想做一个怎样的世界。',
            createdAt: new Date().toISOString(),
            relatedOperationId: null,
          },
        ],
        draftCards: [],
        pendingClarifications: [],
        suggestedActions: [],
        recommendedReplies: [],
        qualityFindings: [],
        assetCoverage: {
          roleAssets: [],
          sceneAssets: [],
          allRoleAssetsReady: false,
          allSceneAssetsReady: false,
        },
        updatedAt: new Date().toISOString(),
      }}
      activeOperation={null}
      onBack={() => {}}
      onSubmitMessage={() => {}}
      onExecuteAction={() => {}}
    />,
  );

  expect(html).toContain('创作进度');
  expect(html).toContain('42%');
  expect(html).toContain('输入消息');
  expect(html).toContain('总结当前设定');
  expect(html).toContain('补全剩余设定');
  expect(html).not.toContain('Agent');
  expect(html).not.toContain('刷新');
  expect(html).not.toContain('当前轮次');
  expect(html).not.toContain('当前状态');
  expect(html).not.toContain('草稿抽屉');
  expect(html).not.toContain('快捷动作');
});
