From 50372294c1e7811ec4f8ca9fe477dd87b3ff61c9 Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Thu, 11 Dec 2025 05:59:29 +0100 Subject: [PATCH] Handled the case of own BoR post not relying on post.metadata (#9341) * Added scaffolding for unrevealed BoR post * Displayed reveal UI * Displayed expiry timer * WIP * Displayed own post indicator and blur text * restored button * Ungrouped BoR posts * WIP * WIP * DIsplayed error message on revealing * Added last run check on mobile app cleanup job * Cleanup * lint fix * i18n-fix * Added tests * test: add test suite for revealBoRPost function * test: add unrevealed burn on read post test file * feat: add tests for UnrevealedBurnOnReadPost component * test: update UnrevealedBurnOnReadPost test with PostModel type * test: replace toBeTruthy with toBeVisible for component visibility assertions * test: add initial test file for expiry timer component * test: add comprehensive tests for ExpiryCountdown component * refactor: clean up test formatting and remove redundant test case * fix: adjust test timing for ExpiryCountdown onExpiry callback * test: fix timer test by advancing timers in smaller increments * Added tests * Updated tests * fixed accidental change * restored package.resolved * WIP review fixes * Review fixes * Review fixes * Fixed tests * restored package.resolved * WIP * test: add test for skipping BoR post cleanup within 15 minutes * test: add comprehensive test cases for expiredBoRPostCleanup * WIP * WIP * test: add bor.test.ts placeholder file * test: add comprehensive tests for BoR utility functions * test: add comprehensive tests for formatTime function * WIP * test: add comprehensive tests for getLastBoRPostCleanupRun function * Added tests * removed a commented code * post list optimization * test: add test case for updating unrevealed burn-on-read post * fix: handle error logging in expiredBoRPostCleanup test * test: add test case for updateLastBoRCleanupRun error handling * review fixes * lint fixes * Added WS event handling (#9320) * Added WS event handling * test: add burn on read websocket action test * test: add tests for handleBoRPostRevealedEvent in burn_on_read * Added tests * test: add comprehensive error handling test cases for burn on read * Added tests and error handling * BoR post - restricted actions (#9315) * Restricted post actions for BoR post type * Prevent opening thread fr nBoR post * WIP * fix: remove redundant observable wrapping in post options * fixed a change * removed broken * restored package.resolved * Added tests * Awaiting for last run to be set * Added tests for validating expiry timer behaviour (#9338) * Added tests for validating expiry timer behaviour * No need of use event setup * Bor ux fixes (#9336) * WIP * UI and delete fixes * lint fixes * fixed tests * Improved mocking * Improved test * Handled the case of own BoR post not relying on post.metadata --- app/components/post_list/post/post.test.tsx | 27 ++++++++++++++++++--- app/components/post_list/post/post.tsx | 3 ++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/components/post_list/post/post.test.tsx b/app/components/post_list/post/post.test.tsx index 1445b0db1..bfee993eb 100644 --- a/app/components/post_list/post/post.test.tsx +++ b/app/components/post_list/post/post.test.tsx @@ -11,6 +11,7 @@ import {getPostById} from '@queries/servers/post'; import {renderWithEverything, waitFor} from '@test/intl-test-helper'; import TestHelper from '@test/test_helper'; +import Body from './body'; import Post from './post'; import type {Database} from '@nozbe/watermelondb'; @@ -18,6 +19,7 @@ import type PostModel from '@typings/database/models/servers/post'; jest.mock('@managers/performance_metrics_manager'); jest.mock('@components/post_list/post/burn_on_read/unrevealed'); +jest.mock('./body'); describe('performance metrics', () => { let database: Database; @@ -84,18 +86,37 @@ describe('performance metrics', () => { it('should render unrevealed post correctly', async () => { const props = getBaseProps(); - const unrevealedBoRPost = TestHelper.fakePostModel({ + props.post = TestHelper.fakePostModel({ type: PostTypes.BURN_ON_READ, props: { expire_at: Date.now() + 1000000, }, }); - props.post = unrevealedBoRPost; - renderWithEverything(, {database, serverUrl}); await waitFor(() => { expect(UnrevealedBurnOnReadPost).toHaveBeenCalled(); }); }); + + it('own BoR post should show as revealed even without metadata', async () => { + const currentUser = TestHelper.fakeUserModel(); + const props = { + ...getBaseProps(), + currentUser, + }; + props.post = TestHelper.fakePostModel({ + type: PostTypes.BURN_ON_READ, + userId: currentUser.id, + props: { + expire_at: Date.now() + 1000000, + }, + }); + + renderWithEverything(, {database, serverUrl}); + await waitFor(() => { + expect(Body).toHaveBeenCalled(); + }); + expect(UnrevealedBurnOnReadPost).not.toHaveBeenCalled(); + }); }); diff --git a/app/components/post_list/post/post.tsx b/app/components/post_list/post/post.tsx index 6953f2633..74950b2a9 100644 --- a/app/components/post_list/post/post.tsx +++ b/app/components/post_list/post/post.tsx @@ -163,6 +163,7 @@ const Post = ({ const isCallsPost = isCallsCustomMessage(post); const borPost = isBoRPost(post); const isUnrevealedPost = isUnrevealedBoRPost(post); + const isOwnPost = Boolean(currentUser && post.userId === currentUser.id); const isAgentPostType = isAgentPost(post); const hasBeenDeleted = (post.deleteAt !== 0); const isWebHook = isFromWebhook(post); @@ -365,7 +366,7 @@ const Post = ({ joiningChannelId={null} /> ); - } else if (isUnrevealedPost) { + } else if (isUnrevealedPost && !isOwnPost) { body = ( );