fix(jump-hop): preserve themed runtime metadata

This commit is contained in:
kdletters
2026-06-05 23:40:12 +08:00
parent cd8088d1fd
commit 36969726b4
3 changed files with 108 additions and 1 deletions

View File

@@ -37,3 +37,93 @@ test('jump hop creation keeps image2 generation requests alive long enough', asy
}),
);
});
test('jump hop work detail preserves flattened back button asset', async () => {
const backButtonAsset = {
assetId: 'back-button-1',
imageSrc: '/generated-jump-hop-assets/back-button-1.png',
imageObjectKey: 'jump-hop/back-button-1.png',
assetObjectId: 'asset-object-back-button-1',
generationProvider: 'image2',
prompt: '主题返回按钮',
width: 1024,
height: 1024,
};
const characterAsset = {
assetId: 'character-1',
imageSrc: 'builtin://jump-hop/default-character',
imageObjectKey: '',
assetObjectId: 'character-object-1',
generationProvider: 'builtin-three',
prompt: '内置默认角色',
width: 0,
height: 0,
};
const draft = {
templateId: 'jump-hop',
templateName: '跳一跳',
profileId: 'profile-1',
themeText: '森林茶馆',
workTitle: '森林茶馆跳一跳',
workDescription: '森林茶馆主题',
themeTags: ['森林茶馆', '跳一跳'],
difficulty: 'standard',
stylePreset: 'minimal-blocks',
defaultCharacter: null,
characterPrompt: '内置默认角色',
tilePrompt: '森林茶馆主题地块',
endMoodPrompt: null,
characterAsset,
tileAtlasAsset: characterAsset,
tileAssets: [],
path: {
seed: 'profile-1',
difficulty: 'standard',
platforms: [],
scoring: {
perfectRadiusRatio: 0.24,
hitRadiusRatio: 0.52,
maxChargeMs: 1200,
minChargeMs: 80,
maxJumpDistance: 5,
},
},
coverComposite: null,
backButtonAsset: null,
generationStatus: 'ready',
};
requestJsonMock.mockResolvedValue({
item: {
runtimeKind: 'jump-hop',
workId: 'work-1',
profileId: 'profile-1',
ownerUserId: 'owner-1',
sourceSessionId: 'session-1',
themeText: '森林茶馆',
workTitle: '森林茶馆跳一跳',
workDescription: '森林茶馆主题',
themeTags: ['森林茶馆', '跳一跳'],
difficulty: 'standard',
stylePreset: 'minimal-blocks',
coverImageSrc: null,
publicationStatus: 'published',
playCount: 0,
updatedAt: '2026-06-05T00:00:00Z',
publishedAt: '2026-06-05T00:00:00Z',
publishReady: true,
generationStatus: 'ready',
draft,
path: draft.path,
defaultCharacter: null,
characterAsset,
tileAtlasAsset: characterAsset,
tileAssets: [],
backButtonAsset,
},
});
const { jumpHopClient } = await import('./jumpHopClient');
const response = await jumpHopClient.getWorkDetail('profile-1');
expect(response.item.backButtonAsset).toEqual(backButtonAsset);
});

View File

@@ -136,6 +136,8 @@ function normalizeJumpHopWorkProfile(
characterAsset: flattened.characterAsset,
tileAtlasAsset: flattened.tileAtlasAsset,
tileAssets: flattened.tileAssets,
backButtonAsset:
flattened.backButtonAsset ?? flattened.draft?.backButtonAsset ?? null,
};
}