feat: unify phase one creation flow

This commit is contained in:
2026-05-30 05:05:02 +08:00
parent 3a87b2d966
commit 26975644b5
33 changed files with 2037 additions and 539 deletions

View File

@@ -0,0 +1,42 @@
/* @vitest-environment jsdom */
import { render, screen } from '@testing-library/react';
import { describe, expect, test } from 'vitest';
import { UnifiedCreationPage } from './UnifiedCreationPage';
import { getUnifiedCreationSpec } from './unifiedCreationSpecs';
describe('UnifiedCreationPage', () => {
test('按后端字段 spec 暴露统一创作页字段契约', () => {
render(
<UnifiedCreationPage spec={getUnifiedCreationSpec('wooden-fish')}>
<div></div>
</UnifiedCreationPage>,
);
const root = screen
.getByText('敲木鱼工作台')
.closest('.unified-creation-page');
expect(root?.getAttribute('data-play-id')).toBe('wooden-fish');
expect(root?.getAttribute('data-field-kinds')).toBe(
'text,image,audio,text',
);
expect(root?.getAttribute('data-workspace-stage')).toBe(
'wooden-fish-workspace',
);
expect(root?.getAttribute('data-generation-stage')).toBe(
'wooden-fish-generating',
);
expect(root?.getAttribute('data-result-stage')).toBe('wooden-fish-result');
const fields = screen.getAllByTestId('unified-creation-field');
expect(fields.map((field) => field.getAttribute('data-field-id'))).toEqual([
'hitObjectPrompt',
'hitObjectReferenceImage',
'hitSoundAsset',
'floatingWords',
]);
expect(fields[2]?.getAttribute('data-field-kind')).toBe('audio');
expect(fields[3]?.getAttribute('data-required')).toBe('true');
});
});