From 6f381cfcf544bb84b5e75599f0ebfc334f15b48e Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Wed, 6 Nov 2024 13:01:42 -0400 Subject: [PATCH] MM-53775: hide Thread Overview until a reply occurs (#8316) --- .../thread_overview.test.tsx.snap | 127 +----------------- .../thread_overview/thread_overview.test.tsx | 2 +- .../thread_overview/thread_overview.tsx | 43 ++---- assets/base/i18n/en.json | 2 - detox/e2e/test/smoke_test/messaging.e2e.ts | 6 + 5 files changed, 21 insertions(+), 159 deletions(-) diff --git a/app/components/post_list/thread_overview/__snapshots__/thread_overview.test.tsx.snap b/app/components/post_list/thread_overview/__snapshots__/thread_overview.test.tsx.snap index 6f75e3965..e2d8804a8 100644 --- a/app/components/post_list/thread_overview/__snapshots__/thread_overview.test.tsx.snap +++ b/app/components/post_list/thread_overview/__snapshots__/thread_overview.test.tsx.snap @@ -1,126 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ThreadOverview should match snapshot when post is not saved and 0 replies 1`] = ` - - - - No replies yet - - - - - - - - - - - - - - - -`; - exports[`ThreadOverview should match snapshot when post is saved and has replies 1`] = ` `; + +exports[`ThreadOverview should match snapshot when post is saved with no replies 1`] = `null`; diff --git a/app/components/post_list/thread_overview/thread_overview.test.tsx b/app/components/post_list/thread_overview/thread_overview.test.tsx index 93a6a0330..157b7e97c 100644 --- a/app/components/post_list/thread_overview/thread_overview.test.tsx +++ b/app/components/post_list/thread_overview/thread_overview.test.tsx @@ -10,7 +10,7 @@ import ThreadOverview from './thread_overview'; import type PostModel from '@typings/database/models/servers/post'; describe('ThreadOverview', () => { - it('should match snapshot when post is not saved and 0 replies', () => { + it('should match snapshot when post is saved with no replies', () => { const props = { isSaved: true, repliesCount: 0, diff --git a/app/components/post_list/thread_overview/thread_overview.tsx b/app/components/post_list/thread_overview/thread_overview.tsx index 04b81d793..005533ce8 100644 --- a/app/components/post_list/thread_overview/thread_overview.tsx +++ b/app/components/post_list/thread_overview/thread_overview.tsx @@ -13,7 +13,6 @@ import {Screens} from '@constants'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import {useIsTablet} from '@hooks/device'; -import {useFetchingThreadState} from '@hooks/fetching_thread'; import {bottomSheetModalOptions, showModal, showModalOverCurrentContext} from '@screens/navigation'; import {preventDoubleTap} from '@utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; @@ -58,14 +57,13 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { }; }); -const ThreadOverview = ({isSaved, repliesCount, rootId, rootPost, style, testID}: Props) => { +const ThreadOverview = ({isSaved, repliesCount, rootPost, style, testID}: Props) => { const theme = useTheme(); const styles = getStyleSheet(theme); const intl = useIntl(); const isTablet = useIsTablet(); const serverUrl = useServerUrl(); - const isFetchingThread = useFetchingThreadState(rootId); const onHandleSavePress = useCallback(preventDoubleTap(() => { if (rootPost?.id) { @@ -101,35 +99,8 @@ const ThreadOverview = ({isSaved, repliesCount, rootId, rootPost, style, testID} const saveButtonTestId = isSaved ? `${testID}.unsave.button` : `${testID}.save.button`; - let repliesCountElement; - if (repliesCount > 0) { - repliesCountElement = ( - - ); - } else if (isFetchingThread) { - repliesCountElement = ( - - ); - } else { - repliesCountElement = ( - - ); + if (repliesCount === 0) { + return null; } return ( @@ -138,7 +109,13 @@ const ThreadOverview = ({isSaved, repliesCount, rootId, rootPost, style, testID} testID={testID} > - {repliesCountElement} + { // * Verify on reply thread screen await ThreadScreen.toBeVisible(); + // * Verify no thread overview while there are no replies + await expect(ThreadScreen.getThreadOverview()).not.toBeVisible(); + // # Reply to parent post const replyMessage = `${message} reply`; await ThreadScreen.postMessage(replyMessage); @@ -120,6 +123,9 @@ describe('Smoke Test - Messaging', () => { const {postListPostItem: replyPostListPostItem} = ThreadScreen.getPostListPostItem(replyPost.id, replyMessage); await expect(replyPostListPostItem).toBeVisible(); + // * Verify thread overview when there are replies + await expect(ThreadScreen.getThreadOverview()).toBeVisible(); + // # Go back to channel list screen await ThreadScreen.back(); await ChannelScreen.back();