Merge codex/sse-stream-architecture into architecture adjustment
This commit is contained in:
@@ -3,8 +3,11 @@ import { expect, test } from 'vitest';
|
||||
import {
|
||||
buildPlatformWorldDisplayTags,
|
||||
buildPuzzleWorkCoverSlides,
|
||||
describePlatformPublicWorkKind,
|
||||
EDUTAINMENT_BABY_OBJECT_MATCH_TEMPLATE_ID,
|
||||
EDUTAINMENT_BABY_OBJECT_MATCH_TEMPLATE_NAME,
|
||||
formatPlatformCompactCount,
|
||||
formatPlatformPublicAuthorAvatarLabel,
|
||||
formatPlatformWorkDisplayName,
|
||||
formatPlatformWorkDisplayTags,
|
||||
formatPlatformWorldTime,
|
||||
@@ -18,10 +21,13 @@ import {
|
||||
mapPuzzleClearWorkToPlatformGalleryCard,
|
||||
mapVisualNovelWorkToPlatformGalleryCard,
|
||||
mapWoodenFishWorkToPlatformGalleryCard,
|
||||
type PlatformBarkBattleGalleryCard,
|
||||
type PlatformBigFishGalleryCard,
|
||||
type PlatformEdutainmentGalleryCard,
|
||||
type PlatformPuzzleGalleryCard,
|
||||
resolvePlatformWorkAuthorDisplayName,
|
||||
resolvePlatformPublicWorkAuthorLookup,
|
||||
resolvePlatformPublicWorkCode,
|
||||
resolvePlatformWorkAuthorDisplayName,
|
||||
resolvePlatformWorldFallbackCoverImage,
|
||||
} from './rpgEntryWorldPresentation';
|
||||
|
||||
@@ -55,6 +61,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',
|
||||
@@ -308,6 +356,57 @@ test('public work author display keeps phone masks and hides bare public user co
|
||||
);
|
||||
});
|
||||
|
||||
test('public work author lookup keeps public user code priority and avatar labels', () => {
|
||||
const barkBattleCard: PlatformBarkBattleGalleryCard = {
|
||||
sourceType: 'bark-battle',
|
||||
workId: 'bark-battle-work-author',
|
||||
profileId: 'bark-battle-profile-author',
|
||||
sourceSessionId: null,
|
||||
publicWorkCode: 'BB-AUTHOR',
|
||||
ownerUserId: 'user-author-id',
|
||||
authorPublicUserCode: ' SY-00012345 ',
|
||||
authorDisplayName: '声浪玩家',
|
||||
worldName: '声浪擂台',
|
||||
subtitle: '汪汪声浪',
|
||||
summaryText: '公开作品',
|
||||
coverImageSrc: null,
|
||||
coverRenderMode: 'image',
|
||||
coverCharacterImageSrcs: [],
|
||||
themeTags: ['声浪'],
|
||||
themeMode: 'martial',
|
||||
playableNpcCount: 0,
|
||||
landmarkCount: 0,
|
||||
visibility: 'published',
|
||||
publishedAt: '2026-05-22T00:00:00.000Z',
|
||||
updatedAt: '2026-05-22T00:00:00.000Z',
|
||||
};
|
||||
|
||||
expect(resolvePlatformPublicWorkAuthorLookup(barkBattleCard)).toEqual({
|
||||
key: 'code:SY-00012345',
|
||||
source: 'publicUserCode',
|
||||
value: 'SY-00012345',
|
||||
});
|
||||
expect(
|
||||
resolvePlatformPublicWorkAuthorLookup({
|
||||
...barkBattleCard,
|
||||
authorPublicUserCode: ' ',
|
||||
}),
|
||||
).toEqual({
|
||||
key: 'id:user-author-id',
|
||||
source: 'ownerUserId',
|
||||
value: 'user-author-id',
|
||||
});
|
||||
expect(
|
||||
resolvePlatformPublicWorkAuthorLookup({
|
||||
...barkBattleCard,
|
||||
authorPublicUserCode: null,
|
||||
ownerUserId: ' ',
|
||||
}),
|
||||
).toBeNull();
|
||||
expect(formatPlatformPublicAuthorAvatarLabel(' 声浪玩家')).toBe('声');
|
||||
expect(formatPlatformPublicAuthorAvatarLabel('')).toBe('玩');
|
||||
});
|
||||
|
||||
test('keeps baby object match public card code and template label intact', () => {
|
||||
const card: PlatformEdutainmentGalleryCard = {
|
||||
sourceType: 'edutainment',
|
||||
|
||||
Reference in New Issue
Block a user