mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(ui): hide account author ID on pending replies
This commit is contained in:
@@ -664,6 +664,26 @@ describe('post community address compatibility', () => {
|
||||
expect(container.textContent).toContain('ID: Pending');
|
||||
});
|
||||
|
||||
it('shows a pending ID instead of the account author shortAddress while a reply is publishing', async () => {
|
||||
testState.pseudonymityMode = 'per-post';
|
||||
const post = makeLegacyThread();
|
||||
const reply = post.replies?.pages?.new?.comments?.[0];
|
||||
if (!reply) {
|
||||
throw new Error('missing fixture reply');
|
||||
}
|
||||
reply.cid = undefined;
|
||||
reply.state = 'publishing';
|
||||
reply.author = { shortAddress: 'account.author.shortAddress' };
|
||||
|
||||
await renderWithRoute(createElement(PostDesktop, { post, showAllReplies: true }), '/mu/thread/post-1');
|
||||
expect(container.textContent).toContain('ID: Pending');
|
||||
expect(container.textContent).not.toContain('account.author.shortAddress');
|
||||
|
||||
await renderWithRoute(createElement(PostMobile, { post, showAllReplies: true }), '/mu/thread/post-1');
|
||||
expect(container.textContent).toContain('ID: Pending');
|
||||
expect(container.textContent).not.toContain('account.author.shortAddress');
|
||||
});
|
||||
|
||||
it('forwards Pretext-backed reply estimates into Virtuoso for desktop and mobile thread views', async () => {
|
||||
testState.hasMoreReplies = true;
|
||||
|
||||
|
||||
@@ -3,8 +3,12 @@ import { getCommentUserID, preservePublishedUserID } from '../comment-user-id-ut
|
||||
|
||||
describe('getCommentUserID', () => {
|
||||
it('uses only the comment author short address for per-post user IDs', () => {
|
||||
expect(getCommentUserID({ author: { address: 'poster.bso', shortAddress: 'short-poster' } } as any)).toBe('short-poster');
|
||||
expect(getCommentUserID({ author: { shortAddress: 'short-poster' } } as any)).toBe('short-poster');
|
||||
expect(getCommentUserID({ cid: 'published-comment', author: { address: 'poster.bso', shortAddress: 'short-poster' } } as any)).toBe('short-poster');
|
||||
expect(getCommentUserID({ cid: 'published-comment', author: { shortAddress: 'short-poster' } } as any)).toBe('short-poster');
|
||||
});
|
||||
|
||||
it('does not expose a local account author shortAddress before the comment is published', () => {
|
||||
expect(getCommentUserID({ state: 'publishing', author: { shortAddress: 'account.author.shortAddress' } } as any)).toBe('');
|
||||
});
|
||||
|
||||
it('does not derive a user ID from an author address', () => {
|
||||
@@ -20,10 +24,11 @@ describe('preservePublishedUserID', () => {
|
||||
it('keeps local account author data but preserves the published user ID', () => {
|
||||
const merged = preservePublishedUserID(
|
||||
{
|
||||
cid: 'published-reply',
|
||||
accountId: 'viewer-account',
|
||||
author: { address: 'account-author.bso', shortAddress: 'account-author' },
|
||||
} as any,
|
||||
{ author: { address: 'published-reply-address', shortAddress: 'ReplyKid9' } } as any,
|
||||
{ cid: 'published-reply', author: { address: 'published-reply-address', shortAddress: 'ReplyKid9' } } as any,
|
||||
);
|
||||
|
||||
expect(merged.author.address).toBe('account-author.bso');
|
||||
@@ -33,10 +38,11 @@ describe('preservePublishedUserID', () => {
|
||||
it('removes an overlaid shortAddress when the published author has no user ID', () => {
|
||||
const merged = preservePublishedUserID(
|
||||
{
|
||||
cid: 'published-reply',
|
||||
accountId: 'viewer-account',
|
||||
author: { address: 'account-author.bso', shortAddress: 'account-author' },
|
||||
} as any,
|
||||
{ author: {} } as any,
|
||||
{ cid: 'published-reply', author: {} } as any,
|
||||
);
|
||||
|
||||
expect(merged.author.address).toBe('account-author.bso');
|
||||
@@ -45,15 +51,15 @@ describe('preservePublishedUserID', () => {
|
||||
|
||||
it('mirrors the published user ID even when the overlaid comment is not an account comment', () => {
|
||||
const merged = preservePublishedUserID(
|
||||
{ author: { address: 'account-author.bso', shortAddress: 'account-author' } } as any,
|
||||
{ author: { shortAddress: 'ReplyKid9' } } as any,
|
||||
{ cid: 'published-reply', author: { address: 'account-author.bso', shortAddress: 'account-author' } } as any,
|
||||
{ cid: 'published-reply', author: { shortAddress: 'ReplyKid9' } } as any,
|
||||
);
|
||||
|
||||
expect(getCommentUserID(merged)).toBe('ReplyKid9');
|
||||
});
|
||||
|
||||
it('returns the comment unchanged when the user ID already matches', () => {
|
||||
const comment = { author: { address: 'account-author.bso', shortAddress: 'ReplyKid9' } } as any;
|
||||
expect(preservePublishedUserID(comment, { author: { shortAddress: 'ReplyKid9' } } as any)).toBe(comment);
|
||||
const comment = { cid: 'published-reply', author: { address: 'account-author.bso', shortAddress: 'ReplyKid9' } } as any;
|
||||
expect(preservePublishedUserID(comment, { cid: 'published-reply', author: { shortAddress: 'ReplyKid9' } } as any)).toBe(comment);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { Comment } from '@bitsocial/bitsocial-react-hooks';
|
||||
// author.address can carry the local account identity (overlaid so author edit/delete
|
||||
// controls keep working), so it must never be used for display.
|
||||
export function getCommentUserID(comment: Comment | undefined): string {
|
||||
if (!comment?.cid) return '';
|
||||
return comment?.author?.shortAddress || '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user