From 976a29ed297d38190396566fb15c2ddf795758bc Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 12 Feb 2019 15:41:20 -0500 Subject: [PATCH] MM-14001 Don't mount PostBodyAdditionalContent for system messages (#2564) --- app/components/post_body/post_body.js | 16 ++++- app/components/post_body/post_body.test.js | 70 ++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 app/components/post_body/post_body.test.js diff --git a/app/components/post_body/post_body.js b/app/components/post_body/post_body.js index 7700e8872..2590d223a 100644 --- a/app/components/post_body/post_body.js +++ b/app/components/post_body/post_body.js @@ -236,7 +236,21 @@ export default class PostBody extends PureComponent { } renderPostAdditionalContent = (blockStyles, messageStyle, textStyles) => { - const {isReplyPost, message, navigator, onHashtagPress, onPermalinkPress, postId, postProps, metadata} = this.props; + const { + isReplyPost, + isSystemMessage, + message, + metadata, + navigator, + onHashtagPress, + onPermalinkPress, + postId, + postProps, + } = this.props; + + if (isSystemMessage) { + return null; + } if (metadata && !metadata.embeds) { return null; diff --git a/app/components/post_body/post_body.test.js b/app/components/post_body/post_body.test.js new file mode 100644 index 000000000..ce6277e4e --- /dev/null +++ b/app/components/post_body/post_body.test.js @@ -0,0 +1,70 @@ +// 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'; + +import PostBodyAdditionalContent from 'app/components/post_body_additional_content'; +import {shallowWithIntl} from 'test/intl-test-helper'; + +import PostBody from './post_body.js'; + +describe('PostBody', () => { + const baseProps = { + canDelete: true, + channelIsReadOnly: false, + deviceHeight: 1920, + fileIds: [], + hasBeenDeleted: false, + hasBeenEdited: false, + hasReactions: false, + highlight: false, + isFailed: false, + isFlagged: false, + isPending: false, + isPostAddChannelMember: false, + isPostEphemeral: false, + isReplyPost: false, + isSearchResult: false, + isSystemMessage: false, + managedConfig: {}, + message: 'Hello, World!', + navigator: {}, + onFailedPostPress: jest.fn(), + onHashtagPress: jest.fn(), + onPermalinkPress: jest.fn(), + onPress: jest.fn(), + postId: 'post', + postProps: {}, + postType: '', + replyBarStyle: [], + showAddReaction: true, + showLongPost: true, + isEmojiOnly: false, + shouldRenderJumboEmoji: false, + theme: Preferences.THEMES.default, + }; + + test('should mount additional content for non-system messages', () => { + const props = { + ...baseProps, + isSystemMessage: false, + }; + + const wrapper = shallowWithIntl(); + + expect(wrapper.find(PostBodyAdditionalContent).exists()).toBeTruthy(); + }); + + test('should not mount additional content for system messages', () => { + const props = { + ...baseProps, + isSystemMessage: true, + }; + + const wrapper = shallowWithIntl(); + + expect(wrapper.find(PostBodyAdditionalContent).exists()).toBeFalsy(); + }); +});