Skip to content

Commit 5037229

Browse files
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
1 parent 2fb2e9d commit 5037229

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

app/components/post_list/post/post.test.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import {getPostById} from '@queries/servers/post';
1111
import {renderWithEverything, waitFor} from '@test/intl-test-helper';
1212
import TestHelper from '@test/test_helper';
1313

14+
import Body from './body';
1415
import Post from './post';
1516

1617
import type {Database} from '@nozbe/watermelondb';
1718
import type PostModel from '@typings/database/models/servers/post';
1819

1920
jest.mock('@managers/performance_metrics_manager');
2021
jest.mock('@components/post_list/post/burn_on_read/unrevealed');
22+
jest.mock('./body');
2123

2224
describe('performance metrics', () => {
2325
let database: Database;
@@ -84,18 +86,37 @@ describe('performance metrics', () => {
8486

8587
it('should render unrevealed post correctly', async () => {
8688
const props = getBaseProps();
87-
const unrevealedBoRPost = TestHelper.fakePostModel({
89+
props.post = TestHelper.fakePostModel({
8890
type: PostTypes.BURN_ON_READ,
8991
props: {
9092
expire_at: Date.now() + 1000000,
9193
},
9294
});
9395

94-
props.post = unrevealedBoRPost;
95-
9696
renderWithEverything(<Post {...props}/>, {database, serverUrl});
9797
await waitFor(() => {
9898
expect(UnrevealedBurnOnReadPost).toHaveBeenCalled();
9999
});
100100
});
101+
102+
it('own BoR post should show as revealed even without metadata', async () => {
103+
const currentUser = TestHelper.fakeUserModel();
104+
const props = {
105+
...getBaseProps(),
106+
currentUser,
107+
};
108+
props.post = TestHelper.fakePostModel({
109+
type: PostTypes.BURN_ON_READ,
110+
userId: currentUser.id,
111+
props: {
112+
expire_at: Date.now() + 1000000,
113+
},
114+
});
115+
116+
renderWithEverything(<Post {...props}/>, {database, serverUrl});
117+
await waitFor(() => {
118+
expect(Body).toHaveBeenCalled();
119+
});
120+
expect(UnrevealedBurnOnReadPost).not.toHaveBeenCalled();
121+
});
101122
});

app/components/post_list/post/post.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ const Post = ({
163163
const isCallsPost = isCallsCustomMessage(post);
164164
const borPost = isBoRPost(post);
165165
const isUnrevealedPost = isUnrevealedBoRPost(post);
166+
const isOwnPost = Boolean(currentUser && post.userId === currentUser.id);
166167
const isAgentPostType = isAgentPost(post);
167168
const hasBeenDeleted = (post.deleteAt !== 0);
168169
const isWebHook = isFromWebhook(post);
@@ -365,7 +366,7 @@ const Post = ({
365366
joiningChannelId={null}
366367
/>
367368
);
368-
} else if (isUnrevealedPost) {
369+
} else if (isUnrevealedPost && !isOwnPost) {
369370
body = (
370371
<UnrevealedBurnOnReadPost post={post}/>
371372
);

0 commit comments

Comments
 (0)