refactor: 收口公开作品展示格式

This commit is contained in:
2026-06-03 18:18:01 +08:00
parent f67f57b415
commit 5fecceef4f
6 changed files with 150 additions and 64 deletions

View File

@@ -3,8 +3,10 @@ import { expect, test } from 'vitest';
import {
buildPlatformWorldDisplayTags,
buildPuzzleWorkCoverSlides,
describePlatformPublicWorkKind,
EDUTAINMENT_BABY_OBJECT_MATCH_TEMPLATE_ID,
EDUTAINMENT_BABY_OBJECT_MATCH_TEMPLATE_NAME,
formatPlatformCompactCount,
formatPlatformWorkDisplayName,
formatPlatformWorkDisplayTags,
formatPlatformWorldTime,
@@ -16,10 +18,11 @@ import {
mapBarkBattleWorkToPlatformGalleryCard,
mapVisualNovelWorkToPlatformGalleryCard,
mapWoodenFishWorkToPlatformGalleryCard,
type PlatformBigFishGalleryCard,
type PlatformEdutainmentGalleryCard,
type PlatformPuzzleGalleryCard,
resolvePlatformWorkAuthorDisplayName,
resolvePlatformPublicWorkCode,
resolvePlatformWorkAuthorDisplayName,
resolvePlatformWorldFallbackCoverImage,
} from './rpgEntryWorldPresentation';
@@ -53,6 +56,48 @@ test('platform work display text limits names and tags by character count', () =
).toEqual(['超长机关', '星桥']);
});
test('platform public work presentation formats compact counts and kind labels', () => {
const puzzleCard: PlatformPuzzleGalleryCard = {
sourceType: 'puzzle',
workId: 'puzzle-work-kind',
profileId: 'puzzle-profile-kind',
publicWorkCode: 'PZ-KIND',
ownerUserId: 'user-1',
authorDisplayName: '玩家',
worldName: '机关拼图',
subtitle: '拼图关卡',
summaryText: '公开作品',
coverImageSrc: null,
themeTags: ['拼图'],
visibility: 'published',
publishedAt: '2026-05-18T00:00:00.000Z',
updatedAt: '2026-05-18T00:00:00.000Z',
};
const bigFishCard: PlatformBigFishGalleryCard = {
sourceType: 'big-fish',
workId: 'big-fish-work-kind',
profileId: 'big-fish-profile-kind',
publicWorkCode: 'BF-KIND',
ownerUserId: 'user-1',
authorDisplayName: '玩家',
worldName: '大鱼海湾',
subtitle: '大鱼关卡',
summaryText: '公开作品',
coverImageSrc: null,
themeTags: ['大鱼'],
visibility: 'published',
publishedAt: '2026-05-18T00:00:00.000Z',
updatedAt: '2026-05-18T00:00:00.000Z',
};
expect(formatPlatformCompactCount(-1)).toBe('0');
expect(formatPlatformCompactCount(9999)).toBe('9999');
expect(formatPlatformCompactCount(10000)).toBe('1.0万');
expect(formatPlatformCompactCount(100000000)).toBe('1.0亿');
expect(describePlatformPublicWorkKind(puzzleCard)).toBe('拼图');
expect(describePlatformPublicWorkKind(bigFishCard)).toBe('大鱼吃小');
});
test('platform public cards use play type reference images as cover fallback', () => {
const puzzleCard: PlatformPuzzleGalleryCard = {
sourceType: 'puzzle',