diff --git a/app/screens/long_post/__snapshots__/long_post.test.js.snap b/app/screens/long_post/__snapshots__/long_post.test.js.snap new file mode 100644 index 000000000..5b180e5ad --- /dev/null +++ b/app/screens/long_post/__snapshots__/long_post.test.js.snap @@ -0,0 +1,345 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`LongPost should match snapshot 1`] = ` +LongPost { + "context": Object { + "intl": Object { + "defaultFormats": Object {}, + "defaultLocale": "en", + "formatDate": [Function], + "formatHTMLMessage": [Function], + "formatMessage": [Function], + "formatNumber": [Function], + "formatPlural": [Function], + "formatRelative": [Function], + "formatTime": [Function], + "formats": Object {}, + "formatters": Object { + "getDateTimeFormat": [Function], + "getMessageFormat": [Function], + "getNumberFormat": [Function], + "getPluralFormat": [Function], + "getRelativeFormat": [Function], + }, + "locale": "en", + "messages": Object {}, + "now": [Function], + "onError": [Function], + "textComponent": "span", + "timeZone": null, + }, + }, + "goToThread": [Function], + "handleClose": [Function], + "handlePress": [Function], + "navigationEventListener": undefined, + "props": Object { + "actions": Object { + "loadThreadIfNecessary": [MockFunction], + "selectPost": [MockFunction], + }, + "fileIds": Array [], + "intl": Object { + "defaultFormats": Object {}, + "defaultLocale": "en", + "formatDate": [Function], + "formatHTMLMessage": [Function], + "formatMessage": [Function], + "formatNumber": [Function], + "formatPlural": [Function], + "formatRelative": [Function], + "formatTime": [Function], + "formats": Object {}, + "formatters": Object { + "getDateTimeFormat": [Function], + "getMessageFormat": [Function], + "getNumberFormat": [Function], + "getPluralFormat": [Function], + "getRelativeFormat": [Function], + }, + "locale": "en", + "messages": Object {}, + "now": [Function], + "onError": [Function], + "textComponent": "span", + "timeZone": null, + }, + "isLandscape": false, + "postId": "post-id", + "theme": Object { + "awayIndicator": "#ffbc42", + "buttonBg": "#166de0", + "buttonColor": "#ffffff", + "centerChannelBg": "#ffffff", + "centerChannelColor": "#3d3c40", + "codeTheme": "github", + "dndIndicator": "#f74343", + "errorTextColor": "#fd5960", + "linkColor": "#2389d7", + "mentionBj": "#ffffff", + "mentionColor": "#145dbf", + "mentionHighlightBg": "#ffe577", + "mentionHighlightLink": "#166de0", + "newMessageSeparator": "#ff8800", + "onlineIndicator": "#06d6a0", + "sidebarBg": "#145dbf", + "sidebarHeaderBg": "#1153ab", + "sidebarHeaderTextColor": "#ffffff", + "sidebarText": "#ffffff", + "sidebarTextActiveBorder": "#579eff", + "sidebarTextActiveColor": "#ffffff", + "sidebarTextHoverBg": "#4578bf", + "sidebarUnreadText": "#ffffff", + "type": "Mattermost", + }, + }, + "refs": Object {}, + "setState": [Function], + "state": null, + "updater": Updater { + "_callbacks": Array [], + "_renderer": ReactShallowRenderer { + "_context": Object { + "intl": Object { + "defaultFormats": Object {}, + "defaultLocale": "en", + "formatDate": [Function], + "formatHTMLMessage": [Function], + "formatMessage": [Function], + "formatNumber": [Function], + "formatPlural": [Function], + "formatRelative": [Function], + "formatTime": [Function], + "formats": Object {}, + "formatters": Object { + "getDateTimeFormat": [Function], + "getMessageFormat": [Function], + "getNumberFormat": [Function], + "getPluralFormat": [Function], + "getRelativeFormat": [Function], + }, + "locale": "en", + "messages": Object {}, + "now": [Function], + "onError": [Function], + "textComponent": "span", + "timeZone": null, + }, + }, + "_didScheduleRenderPhaseUpdate": false, + "_dispatcher": Object { + "readContext": [Function], + "useCallback": [Function], + "useContext": [Function], + "useDebugValue": [Function], + "useEffect": [Function], + "useImperativeHandle": [Function], + "useLayoutEffect": [Function], + "useMemo": [Function], + "useReducer": [Function], + "useRef": [Function], + "useState": [Function], + }, + "_element": , + "_firstWorkInProgressHook": null, + "_forcedUpdate": false, + "_instance": [Circular], + "_isReRender": false, + "_newState": null, + "_numberOfReRenders": 0, + "_renderPhaseUpdates": null, + "_rendered": + + + + + + + + + + + + + + + + , + "_rendering": false, + "_updater": [Circular], + "_workInProgressHook": null, + }, + }, +} +`; diff --git a/app/screens/long_post/index.js b/app/screens/long_post/index.js index 6113c3e09..a0ab4f3e4 100644 --- a/app/screens/long_post/index.js +++ b/app/screens/long_post/index.js @@ -6,7 +6,7 @@ import {connect} from 'react-redux'; import {selectPost} from 'mattermost-redux/actions/posts'; import {makeGetChannel} from 'mattermost-redux/selectors/entities/channels'; -import {getPost, makeGetReactionsForPost} from 'mattermost-redux/selectors/entities/posts'; +import {getPost} from 'mattermost-redux/selectors/entities/posts'; import {getTheme} from 'mattermost-redux/selectors/entities/preferences'; import {loadThreadIfNecessary} from 'app/actions/views/channel'; @@ -15,16 +15,13 @@ import LongPost from './long_post'; function makeMapStateToProps() { const getChannel = makeGetChannel(); - const getReactionsForPost = makeGetReactionsForPost(); return function mapStateToProps(state, ownProps) { const post = getPost(state, ownProps.postId); const channel = post ? getChannel(state, {id: post.channel_id}) : null; - const reactions = getReactionsForPost(state, post.id); return { channelName: channel ? channel.display_name : '', - hasReactions: (reactions && Object.keys(reactions).length > 0) || Boolean(post.has_reactions), inThreadView: Boolean(state.entities.posts.selectedPostId), fileIds: post ? post.file_ids : false, theme: getTheme(state), diff --git a/app/screens/long_post/long_post.js b/app/screens/long_post/long_post.js index ccc427a14..682d7a0e7 100644 --- a/app/screens/long_post/long_post.js +++ b/app/screens/long_post/long_post.js @@ -16,7 +16,6 @@ import {Navigation} from 'react-native-navigation'; import FileAttachmentList from 'app/components/file_attachment_list'; import FormattedText from 'app/components/formatted_text'; import Post from 'app/components/post'; -import Reactions from 'app/components/reactions'; import SafeAreaView from 'app/components/safe_area_view'; import {marginHorizontal as margin} from 'app/components/safe_area_view/iphone_x_spacing'; import {emptyFunction} from 'app/utils/general'; @@ -49,7 +48,6 @@ export default class LongPost extends PureComponent { }).isRequired, channelName: PropTypes.string, fileIds: PropTypes.array, - hasReactions: PropTypes.bool, isPermalink: PropTypes.bool, inThreadView: PropTypes.bool, managedConfig: PropTypes.object, @@ -136,28 +134,10 @@ export default class LongPost extends PureComponent { return attachments; } - renderReactions = (style) => { - const {hasReactions, postId} = this.props; - - if (!hasReactions) { - return null; - } - - return ( - - - - ); - }; - render() { const { channelName, fileIds, - hasReactions, managedConfig, onHashtagPress, onPermalinkPress, @@ -168,11 +148,10 @@ export default class LongPost extends PureComponent { const style = getStyleSheet(theme); let footer; - if (hasReactions || fileIds.length) { + if (fileIds.length) { footer = ( {this.renderFileAttachments(style)} - {this.renderReactions(style)} ); } @@ -222,6 +201,7 @@ export default class LongPost extends PureComponent { onPress={this.handlePress} isSearchResult={false} showLongPost={true} + showAddReaction={false} onHashtagPress={onHashtagPress} onPermalinkPress={onPermalinkPress} managedConfig={managedConfig} @@ -297,9 +277,5 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => { height: 95, width: '100%', }, - reactions: { - height: 47, - width: '100%', - }, }; }); diff --git a/app/screens/long_post/long_post.test.js b/app/screens/long_post/long_post.test.js new file mode 100644 index 000000000..c6786b14a --- /dev/null +++ b/app/screens/long_post/long_post.test.js @@ -0,0 +1,32 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; + +import Preferences from 'mattermost-redux/constants/preferences'; + +import {shallowWithIntl} from 'test/intl-test-helper'; + +import LongPost from './long_post'; + +jest.mock('react-native-doc-viewer', () => ({ + openDoc: jest.fn(), +})); + +describe('LongPost', () => { + const baseProps = { + actions: { + loadThreadIfNecessary: jest.fn(), + selectPost: jest.fn(), + }, + postId: 'post-id', + theme: Preferences.THEMES.default, + isLandscape: false, + }; + + test('should match snapshot', () => { + const wrapper = shallowWithIntl(); + + expect(wrapper.instance()).toMatchSnapshot(); + }); +});