fix: hide public card account identifiers
This commit is contained in:
@@ -163,7 +163,7 @@ test('PlatformWorkDetailView prefers resolved public user display name', () => {
|
||||
expect(screen.queryByText('137****6613')).toBeNull();
|
||||
});
|
||||
|
||||
test('PlatformWorkDetailView prefers display name then public user code for wooden fish works', () => {
|
||||
test('PlatformWorkDetailView prefers display name without appending public user code', () => {
|
||||
render(
|
||||
<PlatformWorkDetailView
|
||||
entry={createWoodenFishEntry()}
|
||||
@@ -183,10 +183,11 @@ test('PlatformWorkDetailView prefers display name then public user code for wood
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText('公开昵称 · SY-00000004')).toBeTruthy();
|
||||
expect(screen.getByText('公开昵称')).toBeTruthy();
|
||||
expect(screen.queryByText('公开昵称 · SY-00000004')).toBeNull();
|
||||
expect(screen.queryByText('SY-00000004')).toBeNull();
|
||||
expect(screen.queryByText('phone_00000004')).toBeNull();
|
||||
expect(screen.queryByText('敲木鱼玩家')).toBeNull();
|
||||
expect(screen.queryByText('公开昵称')).toBeNull();
|
||||
});
|
||||
|
||||
test('PlatformWorkDetailView calls like handler', () => {
|
||||
|
||||
@@ -3434,6 +3434,34 @@ test('public gallery cards hide work code until detail is opened', async () => {
|
||||
expect(onOpenGalleryDetail).toHaveBeenCalledWith(puzzlePublicEntry);
|
||||
});
|
||||
|
||||
test('public gallery cards hide phone masked author and public user code', async () => {
|
||||
mockDesktopLayout();
|
||||
const user = userEvent.setup();
|
||||
const maskedAuthorEntry = {
|
||||
...puzzlePublicEntry,
|
||||
workId: 'puzzle-work-masked-author',
|
||||
profileId: 'puzzle-profile-masked-author',
|
||||
publicWorkCode: 'PZ-MASKED1',
|
||||
authorDisplayName: '158****3533 · SY-00000003',
|
||||
worldName: '喜气洋洋',
|
||||
} satisfies PlatformPublicGalleryCard;
|
||||
|
||||
renderStatefulLoggedOutHomeView(
|
||||
{
|
||||
latestEntries: [maskedAuthorEntry],
|
||||
},
|
||||
true,
|
||||
);
|
||||
await user.click(screen.getByRole('button', { name: '发现' }));
|
||||
|
||||
const card = screen.getByRole('button', { name: /喜气洋洋/u });
|
||||
expect(card).toBeTruthy();
|
||||
expect(within(card).getByText('公开作者')).toBeTruthy();
|
||||
expect(within(card).queryByText('158****3533 · SY-00000003')).toBeNull();
|
||||
expect(within(card).queryByText('158****3533')).toBeNull();
|
||||
expect(within(card).queryByText('SY-00000003')).toBeNull();
|
||||
});
|
||||
|
||||
test('logged out mobile shell defaults to discover tab', () => {
|
||||
const { container } = renderStatefulLoggedOutHomeView({
|
||||
latestEntries: [puzzlePublicEntry],
|
||||
|
||||
@@ -224,7 +224,7 @@ test('resolves public work author from display name and public user code before
|
||||
displayName: '公开昵称',
|
||||
avatarUrl: null,
|
||||
}),
|
||||
).toBe('公开昵称 · SY-00000004');
|
||||
).toBe('公开昵称');
|
||||
expect(
|
||||
resolvePlatformWorkAuthorDisplayName(card, {
|
||||
id: 'user_00000004',
|
||||
@@ -237,6 +237,36 @@ test('resolves public work author from display name and public user code before
|
||||
expect(resolvePlatformWorkAuthorDisplayName(card, null)).toBe('敲木鱼玩家');
|
||||
});
|
||||
|
||||
test('public work author display hides phone masks and public user codes on cards', () => {
|
||||
const card = mapWoodenFishWorkToPlatformGalleryCard({
|
||||
publicWorkCode: 'WF-AUTHOR2',
|
||||
workId: 'wooden-fish-work-author-mask',
|
||||
profileId: 'wooden-fish-profile-author-mask',
|
||||
ownerUserId: 'user-author-mask',
|
||||
authorDisplayName: '158****3533 · SY-00000003',
|
||||
workTitle: '喜气洋洋',
|
||||
workDescription: '喜庆主题敲木鱼。',
|
||||
coverImageSrc: null,
|
||||
themeTags: ['敲木鱼'],
|
||||
publicationStatus: 'published',
|
||||
playCount: 0,
|
||||
updatedAt: '2026-05-20T00:00:00.000Z',
|
||||
publishedAt: '2026-05-20T00:00:00.000Z',
|
||||
generationStatus: 'ready',
|
||||
});
|
||||
|
||||
expect(
|
||||
resolvePlatformWorkAuthorDisplayName(card, {
|
||||
id: 'user_00000003',
|
||||
publicUserCode: 'SY-00000003',
|
||||
username: '158****3533',
|
||||
displayName: '158****3533',
|
||||
avatarUrl: null,
|
||||
}),
|
||||
).toBe('玩家');
|
||||
expect(resolvePlatformWorkAuthorDisplayName(card, null)).toBe('玩家');
|
||||
});
|
||||
|
||||
test('keeps baby object match public card code and template label intact', () => {
|
||||
const card: PlatformEdutainmentGalleryCard = {
|
||||
sourceType: 'edutainment',
|
||||
|
||||
@@ -867,14 +867,31 @@ export function resolvePlatformWorkAuthorDisplayName(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
authorSummary?: PublicUserSummary | null,
|
||||
) {
|
||||
const displayName = authorSummary?.displayName?.trim();
|
||||
const publicUserCode = authorSummary?.publicUserCode?.trim();
|
||||
const displayName = normalizePlatformPublicAuthorName(
|
||||
authorSummary?.displayName,
|
||||
);
|
||||
const entryAuthorName = normalizePlatformPublicAuthorName(
|
||||
entry.authorDisplayName,
|
||||
);
|
||||
|
||||
if (displayName && publicUserCode) {
|
||||
return `${displayName} · ${publicUserCode}`;
|
||||
return displayName || entryAuthorName || '玩家';
|
||||
}
|
||||
|
||||
function normalizePlatformPublicAuthorName(value: string | null | undefined) {
|
||||
const normalized = value?.trim() ?? '';
|
||||
if (!normalized || normalized === 'null' || normalized === 'undefined') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return displayName || publicUserCode || entry.authorDisplayName.trim() || '玩家';
|
||||
const compact = normalized.replace(/\s+/gu, '');
|
||||
if (/^\d+\*+\d+(?:[·.-]?SY-\d+)?$/iu.test(compact)) {
|
||||
return '';
|
||||
}
|
||||
if (/^SY-\d+$/iu.test(compact)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function buildPlatformWorldDisplayTags(
|
||||
|
||||
Reference in New Issue
Block a user