refactor: 收口小玩法生成 action payload
This commit is contained in:
@@ -19,7 +19,9 @@ import type {
|
||||
import type {
|
||||
WoodenFishAudioAsset,
|
||||
WoodenFishImageAsset,
|
||||
WoodenFishSessionSnapshotResponse,
|
||||
WoodenFishWorkProfileResponse,
|
||||
WoodenFishWorkspaceCreateRequest,
|
||||
WoodenFishWorkSummaryResponse,
|
||||
} from '../../../packages/shared/src/contracts/woodenFish';
|
||||
import {
|
||||
@@ -27,6 +29,7 @@ import {
|
||||
buildPuzzleRuntimeWorkFromSession,
|
||||
buildSquareHoleProfileFromSession,
|
||||
buildVisualNovelSessionFromWorkDetail,
|
||||
buildWoodenFishGeneratingWorkSummary,
|
||||
buildWoodenFishPendingSession,
|
||||
buildWoodenFishSessionFromWorkDetail,
|
||||
} from './platformMiniGameSessionMappingModel';
|
||||
@@ -423,6 +426,37 @@ function buildWoodenFishWorkProfile(
|
||||
};
|
||||
}
|
||||
|
||||
function buildWoodenFishSession(
|
||||
overrides: Partial<WoodenFishSessionSnapshotResponse> = {},
|
||||
): WoodenFishSessionSnapshotResponse {
|
||||
const summary = buildWoodenFishSummary();
|
||||
return {
|
||||
sessionId: 'wooden-fish-session-1',
|
||||
ownerUserId: 'user-1',
|
||||
status: 'generating',
|
||||
draft: buildWoodenFishWorkProfile({ summary }).draft,
|
||||
createdAt: '2026-06-01T11:59:00.000Z',
|
||||
updatedAt: '2026-06-01T12:00:00.000Z',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function buildWoodenFishCreatePayload(
|
||||
overrides: Partial<WoodenFishWorkspaceCreateRequest> = {},
|
||||
): WoodenFishWorkspaceCreateRequest {
|
||||
return {
|
||||
templateId: 'wooden-fish',
|
||||
workTitle: '表单星灯木鱼',
|
||||
workDescription: '表单里敲亮星灯。',
|
||||
themeTags: ['表单星灯'],
|
||||
hitObjectPrompt: '星灯',
|
||||
hitObjectReferenceImageSrc: null,
|
||||
hitSoundPrompt: null,
|
||||
floatingWords: ['功德 +1'],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('platformMiniGameSessionMappingModel', () => {
|
||||
test('builds a draft puzzle runtime work from a session', () => {
|
||||
expect(
|
||||
@@ -607,6 +641,47 @@ describe('platformMiniGameSessionMappingModel', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('builds wooden fish generating work summary from session and payload', () => {
|
||||
expect(
|
||||
buildWoodenFishGeneratingWorkSummary(
|
||||
buildWoodenFishSession(),
|
||||
buildWoodenFishCreatePayload(),
|
||||
),
|
||||
).toEqual({
|
||||
runtimeKind: 'wooden-fish',
|
||||
workId: 'wooden-fish-session-1',
|
||||
profileId: 'wooden-fish-session-1',
|
||||
ownerUserId: 'user-1',
|
||||
sourceSessionId: 'wooden-fish-session-1',
|
||||
workTitle: '表单星灯木鱼',
|
||||
workDescription: '表单里敲亮星灯。',
|
||||
themeTags: ['表单星灯'],
|
||||
coverImageSrc: '/wooden-fish-cover.png',
|
||||
publicationStatus: 'draft',
|
||||
playCount: 0,
|
||||
updatedAt: '2026-06-01T12:00:00.000Z',
|
||||
publishedAt: null,
|
||||
publishReady: false,
|
||||
generationStatus: 'generating',
|
||||
});
|
||||
|
||||
expect(
|
||||
buildWoodenFishGeneratingWorkSummary(
|
||||
buildWoodenFishSession({
|
||||
draft: null,
|
||||
createdAt: '2026-06-01T11:59:00.000Z',
|
||||
}),
|
||||
null,
|
||||
),
|
||||
).toMatchObject({
|
||||
workTitle: '敲木鱼',
|
||||
workDescription: '',
|
||||
themeTags: ['敲木鱼'],
|
||||
coverImageSrc: null,
|
||||
updatedAt: '2026-06-01T12:00:00.000Z',
|
||||
});
|
||||
});
|
||||
|
||||
test('builds wooden fish recovered session with summary, fallback and profile id priority', () => {
|
||||
expect(
|
||||
buildWoodenFishSessionFromWorkDetail(
|
||||
|
||||
Reference in New Issue
Block a user