import { describe, expect, test } from 'vitest'; import { buildMiniGameDraftGenerationProgress, buildPuzzleGenerationAnchorEntries, type MiniGameDraftGenerationState, } from './miniGameDraftGenerationProgress'; describe('miniGameDraftGenerationProgress', () => { test('puzzle draft generation follows picture-only creation steps', () => { const state: MiniGameDraftGenerationState = { kind: 'puzzle', phase: 'compile', startedAtMs: 1000, completedAssetCount: 0, totalAssetCount: 0, error: null, }; const progress = buildMiniGameDraftGenerationProgress(state, 1500); expect(progress?.steps.map((step) => step.label)).toEqual([ '编译首关草稿', '生成首关画面', '写入正式草稿', ]); expect(progress?.phaseLabel).toBe('编译首关草稿'); expect(progress?.steps[0]?.detail).toBe( '根据画面描述生成首关名称和结果页草稿。', ); }); test('puzzle ready copy points to result page work info completion', () => { const state: MiniGameDraftGenerationState = { kind: 'puzzle', phase: 'ready', startedAtMs: 1000, completedAssetCount: 1, totalAssetCount: 1, error: null, }; const progress = buildMiniGameDraftGenerationProgress(state, 2000); expect(progress?.phaseDetail).toBe( '首关草稿与正式图已准备完成,可进入结果页补作品信息。', ); }); test('big fish draft generation exposes multiple draft steps', () => { const state: MiniGameDraftGenerationState = { kind: 'big-fish', phase: 'big-fish-draft', startedAtMs: 1000, completedAssetCount: 0, totalAssetCount: 0, error: null, }; const progress = buildMiniGameDraftGenerationProgress(state, 1500); expect(progress).not.toBeNull(); expect(progress?.steps).toHaveLength(3); expect(progress?.steps.map((step) => step.id)).toEqual([ 'big-fish-draft', 'big-fish-levels', 'big-fish-runtime', ]); expect(progress?.steps[0]?.label).toBe('整理玩法骨架'); }); test('big fish generation progresses to level and runtime phases over time', () => { const state: MiniGameDraftGenerationState = { kind: 'big-fish', phase: 'big-fish-draft', startedAtMs: 1000, completedAssetCount: 0, totalAssetCount: 0, error: null, }; const levelProgress = buildMiniGameDraftGenerationProgress(state, 3200); const runtimeProgress = buildMiniGameDraftGenerationProgress(state, 6200); expect(levelProgress?.phaseId).toBe('big-fish-levels'); expect(levelProgress?.phaseLabel).toBe('编译等级蓝图'); expect(runtimeProgress?.phaseId).toBe('big-fish-runtime'); expect(runtimeProgress?.phaseLabel).toBe('校准场地与参数'); }); test('big fish ready copy directs user to continue generating assets on result page', () => { const state: MiniGameDraftGenerationState = { kind: 'big-fish', phase: 'ready', startedAtMs: 1000, completedAssetCount: 0, totalAssetCount: 0, error: null, }; const progress = buildMiniGameDraftGenerationProgress(state, 2000); expect(progress?.phaseDetail).toBe( '玩法草稿已准备完成,可进入结果页继续生成主图、动作和背景。', ); }); test('puzzle generation anchors expose form payload as the display source', () => { const entries = buildPuzzleGenerationAnchorEntries({ sessionId: 'puzzle-session-1', currentTurn: 1, progressPercent: 0, stage: 'collecting_anchors', anchorPack: { themePromise: { key: 'themePromise', label: '题材承诺', value: '雨夜猫街', status: 'locked', }, visualSubject: { key: 'visualSubject', label: '画面主体', value: '一只猫在雨夜灯牌下回头。', status: 'locked', }, visualMood: { key: 'visualMood', label: '视觉气质', value: '清晰、适合拼图切块', status: 'inferred', }, compositionHooks: { key: 'compositionHooks', label: '拼图记忆点', value: '主体轮廓、色块分区、局部细节', status: 'inferred', }, tagsAndForbidden: { key: 'tagsAndForbidden', label: '标签与禁忌', value: '猫咪、雨夜、拼图;禁止标题字', status: 'inferred', }, }, draft: null, messages: [], lastAssistantReply: null, publishedProfileId: null, suggestedActions: [], resultPreview: null, updatedAt: '2026-04-29T00:00:00.000Z', }, { seedText: '一只猫在雨夜灯牌下回头。', pictureDescription: '一只猫在雨夜灯牌下回头。', referenceImageSrc: null, }); expect(entries).toEqual([ { id: 'picture-description', label: '画面描述', value: '一只猫在雨夜灯牌下回头。', }, ]); }); });