fix: polish bark battle creation flow
This commit is contained in:
@@ -8,9 +8,11 @@ import {
|
||||
formatPlatformWorkDisplayName,
|
||||
formatPlatformWorkDisplayTags,
|
||||
formatPlatformWorldTime,
|
||||
isBarkBattleGalleryEntry,
|
||||
isEdutainmentGalleryEntry,
|
||||
isVisualNovelGalleryEntry,
|
||||
mapBabyObjectMatchDraftToPlatformGalleryCard,
|
||||
mapBarkBattleWorkToPlatformGalleryCard,
|
||||
mapVisualNovelWorkToPlatformGalleryCard,
|
||||
type PlatformEdutainmentGalleryCard,
|
||||
type PlatformPuzzleGalleryCard,
|
||||
@@ -235,3 +237,98 @@ test('maps baby object match draft to edutainment public card', () => {
|
||||
expect(card.coverImageSrc).toBe('/apple.png');
|
||||
expect(card.themeTags[0]).toBe('寓教于乐');
|
||||
});
|
||||
|
||||
test('maps bark battle work to BB public card with scene roles cover', () => {
|
||||
const card = mapBarkBattleWorkToPlatformGalleryCard({
|
||||
workId: 'bark-battle-work-abcdef12',
|
||||
draftId: 'bark-battle-draft-1',
|
||||
ownerUserId: 'user-1',
|
||||
authorDisplayName: '玩家',
|
||||
title: '公园声浪赛',
|
||||
summary: '柯基和哈士奇比拼声浪。',
|
||||
themeDescription: '傍晚公园擂台',
|
||||
playerImageDescription: '红围巾柯基',
|
||||
opponentImageDescription: '蓝头带哈士奇',
|
||||
playerCharacterImageSrc: '/generated-bark-battle/player.png',
|
||||
opponentCharacterImageSrc: '/generated-bark-battle/opponent.png',
|
||||
uiBackgroundImageSrc: '/generated-bark-battle/background.png',
|
||||
difficultyPreset: 'hard',
|
||||
status: 'published',
|
||||
generationStatus: 'ready',
|
||||
publishReady: true,
|
||||
playCount: 9,
|
||||
recentPlayCount7d: 4,
|
||||
updatedAt: '2026-05-20T00:00:00.000Z',
|
||||
publishedAt: '2026-05-20T00:00:00.000Z',
|
||||
});
|
||||
|
||||
expect(isBarkBattleGalleryEntry(card)).toBe(true);
|
||||
expect(card.publicWorkCode).toBe('BB-ABCDEF12');
|
||||
expect(resolvePlatformPublicWorkCode(card)).toBe('BB-ABCDEF12');
|
||||
expect(card.coverImageSrc).toBe('/generated-bark-battle/background.png');
|
||||
expect(card.coverRenderMode).toBe('scene_with_roles');
|
||||
expect(card.coverCharacterImageSrcs).toEqual([
|
||||
'/generated-bark-battle/player.png',
|
||||
'/generated-bark-battle/opponent.png',
|
||||
]);
|
||||
expect(buildPlatformWorldDisplayTags(card, 3)).toEqual([
|
||||
'汪汪声浪',
|
||||
'高能',
|
||||
'傍晚公园',
|
||||
]);
|
||||
});
|
||||
|
||||
test('maps bark battle public card cover from character or reference fallback', () => {
|
||||
const characterCoverCard = mapBarkBattleWorkToPlatformGalleryCard({
|
||||
workId: 'BB-COVER001',
|
||||
draftId: 'bark-battle-draft-cover',
|
||||
ownerUserId: 'user-1',
|
||||
authorDisplayName: '玩家',
|
||||
title: '角色封面赛',
|
||||
summary: '',
|
||||
themeDescription: '草地声浪挑战',
|
||||
playerImageDescription: '柯基选手',
|
||||
opponentImageDescription: '哈士奇对手',
|
||||
playerCharacterImageSrc: '/bark/player-cover.png',
|
||||
opponentCharacterImageSrc: '/bark/opponent-cover.png',
|
||||
uiBackgroundImageSrc: null,
|
||||
difficultyPreset: 'normal',
|
||||
status: 'published',
|
||||
generationStatus: 'ready',
|
||||
publishReady: true,
|
||||
playCount: 1,
|
||||
updatedAt: '2026-05-20T00:00:00.000Z',
|
||||
publishedAt: '2026-05-20T00:00:00.000Z',
|
||||
});
|
||||
const fallbackCoverCard = mapBarkBattleWorkToPlatformGalleryCard({
|
||||
workId: 'BB-COVER002',
|
||||
draftId: 'bark-battle-draft-cover-fallback',
|
||||
ownerUserId: 'user-1',
|
||||
authorDisplayName: '玩家',
|
||||
title: '默认封面赛',
|
||||
summary: '',
|
||||
themeDescription: '夜市声浪挑战',
|
||||
playerImageDescription: '柴犬选手',
|
||||
opponentImageDescription: '机器人对手',
|
||||
playerCharacterImageSrc: null,
|
||||
opponentCharacterImageSrc: null,
|
||||
uiBackgroundImageSrc: null,
|
||||
difficultyPreset: 'easy',
|
||||
status: 'published',
|
||||
generationStatus: 'ready',
|
||||
publishReady: true,
|
||||
playCount: 1,
|
||||
updatedAt: '2026-05-20T00:00:00.000Z',
|
||||
publishedAt: '2026-05-20T00:00:00.000Z',
|
||||
});
|
||||
|
||||
expect(characterCoverCard.coverImageSrc).toBe('/bark/player-cover.png');
|
||||
expect(characterCoverCard.coverCharacterImageSrcs).toEqual([
|
||||
'/bark/player-cover.png',
|
||||
'/bark/opponent-cover.png',
|
||||
]);
|
||||
expect(fallbackCoverCard.coverImageSrc).toBe(
|
||||
'/creation-type-references/bark-battle.webp',
|
||||
);
|
||||
expect(fallbackCoverCard.publicWorkCode).toBe('BB-COVER002');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user