fix public author display

This commit is contained in:
kdletters
2026-05-28 20:45:27 +08:00
parent 31afb2b18a
commit d2f838582f
6 changed files with 82 additions and 56 deletions

View File

@@ -198,7 +198,7 @@ test('maps wooden fish work to platform gallery card with WF public code', () =>
expect(buildPlatformWorldDisplayTags(card, 2)).toEqual(['敲木鱼']);
});
test('resolves public work author from live username before stored author name', () => {
test('resolves public work author from display name and public user code before stored author name', () => {
const card = mapWoodenFishWorkToPlatformGalleryCard({
publicWorkCode: 'WF-AUTHOR1',
workId: 'wooden-fish-work-author',
@@ -216,10 +216,25 @@ test('resolves public work author from live username before stored author name',
generationStatus: 'ready',
});
expect(resolvePlatformWorkAuthorDisplayName(card, 'lotus_user')).toBe(
'lotus_user',
);
expect(resolvePlatformWorkAuthorDisplayName(card, ' ')).toBe('敲木鱼玩家');
expect(
resolvePlatformWorkAuthorDisplayName(card, {
id: 'user_00000004',
publicUserCode: 'SY-00000004',
username: 'phone_00000004',
displayName: '公开昵称',
avatarUrl: null,
}),
).toBe('公开昵称 · SY-00000004');
expect(
resolvePlatformWorkAuthorDisplayName(card, {
id: 'user_00000004',
publicUserCode: '',
username: 'phone_00000004',
displayName: '公开昵称',
avatarUrl: null,
}),
).toBe('公开昵称');
expect(resolvePlatformWorkAuthorDisplayName(card, null)).toBe('敲木鱼玩家');
});
test('keeps baby object match public card code and template label intact', () => {