72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
import { describe, expect, test } from 'vitest';
|
|
|
|
import type { CustomWorldGenerationProgress } from '../../../packages/shared/src/contracts/runtime';
|
|
import { UnifiedGenerationPage } from './UnifiedGenerationPage';
|
|
|
|
function createProgress(): CustomWorldGenerationProgress {
|
|
return {
|
|
phaseId: 'puzzle-cover-image',
|
|
phaseLabel: '生成拼图首图',
|
|
phaseDetail: '正在生成图片。',
|
|
batchLabel: '生成拼图首图',
|
|
overallProgress: 36,
|
|
completedWeight: 36,
|
|
totalWeight: 100,
|
|
elapsedMs: 12_000,
|
|
estimatedRemainingMs: 30_000,
|
|
activeStepIndex: 0,
|
|
steps: [
|
|
{
|
|
id: 'puzzle-cover-image',
|
|
label: '生成拼图首图',
|
|
detail: '正在生成图片。',
|
|
completed: 0.36,
|
|
total: 1,
|
|
status: 'active',
|
|
},
|
|
],
|
|
};
|
|
}
|
|
|
|
describe('UnifiedGenerationPage', () => {
|
|
test('按玩法下发统一生成页文案并透传进度', () => {
|
|
render(
|
|
<UnifiedGenerationPage
|
|
playId="puzzle"
|
|
settingText="一只发光的纸船"
|
|
progress={createProgress()}
|
|
isGenerating
|
|
onBack={() => {}}
|
|
onEditSetting={() => {}}
|
|
onRetry={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(document.body.textContent).toContain('拼图图片生成进度');
|
|
expect(screen.getByText('图片生成中')).toBeTruthy();
|
|
expect(screen.getAllByText('生成拼图首图').length).toBeGreaterThan(0);
|
|
expect(screen.getByText('当前拼图信息')).toBeTruthy();
|
|
});
|
|
|
|
test('jump-hop generation page uses unified copy', () => {
|
|
render(
|
|
<UnifiedGenerationPage
|
|
playId="jump-hop"
|
|
settingText="云端糖果塔"
|
|
progress={createProgress()}
|
|
isGenerating
|
|
onBack={() => {}}
|
|
onEditSetting={() => {}}
|
|
onRetry={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(document.body.textContent).toContain('跳一跳草稿生成进度');
|
|
expect(screen.getByText('素材生成中')).toBeTruthy();
|
|
expect(screen.getByText('当前跳一跳信息')).toBeTruthy();
|
|
});
|
|
});
|