MM-18054 Checked for prev post comment line (#3523)
* MM-18054 Checked for prev post comment line Added check for prev post to stop the "Commented on" line when in same thread. * MM-18054 Added Unit Tests Added Unit Tests * MM-18054 Update props Updated the prop for isFirstReply
This commit is contained in:
parent
c5cf784c76
commit
c7cdce01fa
4 changed files with 193 additions and 1 deletions
|
|
@ -254,6 +254,7 @@ export default class Post extends PureComponent {
|
|||
isLandscape,
|
||||
previousPostExists,
|
||||
beforePrevPostUserId,
|
||||
isFirstReply,
|
||||
} = this.props;
|
||||
|
||||
if (!post) {
|
||||
|
|
@ -305,6 +306,7 @@ export default class Post extends PureComponent {
|
|||
theme={theme}
|
||||
previousPostExists={previousPostExists}
|
||||
beforePrevPostUserId={beforePrevPostUserId}
|
||||
isFirstReply={isFirstReply}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,6 +244,76 @@ exports[`PostHeader should match snapshot when post is from system message 1`] =
|
|||
</React.Fragment>
|
||||
`;
|
||||
|
||||
exports[`PostHeader should match snapshot when post is same thread, so dont display Commented On 1`] = `
|
||||
<React.Fragment>
|
||||
<View
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"marginTop": 10,
|
||||
},
|
||||
false,
|
||||
]
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
}
|
||||
}
|
||||
>
|
||||
<TouchableWithFeedbackIOS
|
||||
onPress={[Function]}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"marginBottom": 3,
|
||||
"marginRight": 5,
|
||||
"maxWidth": "60%",
|
||||
},
|
||||
null,
|
||||
]
|
||||
}
|
||||
type="opacity"
|
||||
>
|
||||
<Text
|
||||
ellipsizeMode="tail"
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Object {
|
||||
"color": "#3d3c40",
|
||||
"flexGrow": 1,
|
||||
"fontSize": 15,
|
||||
"fontWeight": "600",
|
||||
"paddingVertical": 2,
|
||||
}
|
||||
}
|
||||
>
|
||||
John Smith
|
||||
</Text>
|
||||
</TouchableWithFeedbackIOS>
|
||||
<FormattedTime
|
||||
hour12={true}
|
||||
style={
|
||||
Object {
|
||||
"color": "#3d3c40",
|
||||
"flex": 1,
|
||||
"fontSize": 12,
|
||||
"marginTop": 5,
|
||||
"opacity": 0.5,
|
||||
}
|
||||
}
|
||||
timeZone=""
|
||||
value={0}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</React.Fragment>
|
||||
`;
|
||||
|
||||
exports[`PostHeader should match snapshot when post isBot and shouldRenderReplyButton 1`] = `
|
||||
<React.Fragment>
|
||||
<View
|
||||
|
|
@ -396,6 +466,93 @@ exports[`PostHeader should match snapshot when post isBot and shouldRenderReplyB
|
|||
</React.Fragment>
|
||||
`;
|
||||
|
||||
exports[`PostHeader should match snapshot when post renders Commented On for new post 1`] = `
|
||||
<React.Fragment>
|
||||
<View
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"flex": 1,
|
||||
"marginTop": 10,
|
||||
},
|
||||
false,
|
||||
]
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"flex": 1,
|
||||
"flexDirection": "row",
|
||||
}
|
||||
}
|
||||
>
|
||||
<TouchableWithFeedbackIOS
|
||||
onPress={[Function]}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"marginBottom": 3,
|
||||
"marginRight": 5,
|
||||
"maxWidth": "60%",
|
||||
},
|
||||
null,
|
||||
]
|
||||
}
|
||||
type="opacity"
|
||||
>
|
||||
<Text
|
||||
ellipsizeMode="tail"
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Object {
|
||||
"color": "#3d3c40",
|
||||
"flexGrow": 1,
|
||||
"fontSize": 15,
|
||||
"fontWeight": "600",
|
||||
"paddingVertical": 2,
|
||||
}
|
||||
}
|
||||
>
|
||||
John Smith
|
||||
</Text>
|
||||
</TouchableWithFeedbackIOS>
|
||||
<FormattedTime
|
||||
hour12={true}
|
||||
style={
|
||||
Object {
|
||||
"color": "#3d3c40",
|
||||
"flex": 1,
|
||||
"fontSize": 12,
|
||||
"marginTop": 5,
|
||||
"opacity": 0.5,
|
||||
}
|
||||
}
|
||||
timeZone=""
|
||||
value={0}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<FormattedText
|
||||
defaultMessage="Commented on {name}{apostrophe} message: "
|
||||
id="post_body.commentedOn"
|
||||
style={
|
||||
Object {
|
||||
"color": "rgba(61,60,64,0.65)",
|
||||
"lineHeight": 21,
|
||||
"marginBottom": 3,
|
||||
}
|
||||
}
|
||||
values={
|
||||
Object {
|
||||
"apostrophe": "'s",
|
||||
"name": "John Doe",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
`;
|
||||
|
||||
exports[`PostHeader should match snapshot when post should display reply button 1`] = `
|
||||
<React.Fragment>
|
||||
<View
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ export default class PostHeader extends PureComponent {
|
|||
previousPostExists: PropTypes.bool,
|
||||
post: PropTypes.object,
|
||||
beforePrevPostUserId: PropTypes.string,
|
||||
isFirstReply: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
|
@ -68,8 +69,9 @@ export default class PostHeader extends PureComponent {
|
|||
previousPostExists,
|
||||
renderReplies,
|
||||
theme,
|
||||
isFirstReply,
|
||||
} = this.props;
|
||||
if (!renderReplies || !commentedOnDisplayName || (!previousPostExists && post.user_id === beforePrevPostUserId)) {
|
||||
if (!isFirstReply || !renderReplies || !commentedOnDisplayName || (!previousPostExists && post.user_id === beforePrevPostUserId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ describe('PostHeader', () => {
|
|||
post: {id: 'post'},
|
||||
beforePrevPostUserId: '0',
|
||||
onPress: jest.fn(),
|
||||
isFirstReply: true,
|
||||
};
|
||||
|
||||
test('should match snapshot when just a base post', () => {
|
||||
|
|
@ -95,4 +96,34 @@ describe('PostHeader', () => {
|
|||
expect(wrapper.getElement()).toMatchSnapshot();
|
||||
expect(wrapper.find('#ReplyIcon').exists()).toEqual(false);
|
||||
});
|
||||
|
||||
test('should match snapshot when post renders Commented On for new post', () => {
|
||||
const props = {
|
||||
...baseProps,
|
||||
isFirstReply: true,
|
||||
renderReplies: true,
|
||||
commentedOnDisplayName: 'John Doe',
|
||||
previousPostExists: true,
|
||||
};
|
||||
|
||||
const wrapper = shallow(
|
||||
<PostHeader {...props}/>
|
||||
);
|
||||
expect(wrapper.getElement()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match snapshot when post is same thread, so dont display Commented On', () => {
|
||||
const props = {
|
||||
...baseProps,
|
||||
isFirstReply: false,
|
||||
renderReplies: true,
|
||||
commentedOnDisplayName: 'John Doe',
|
||||
previousPostExists: true,
|
||||
};
|
||||
|
||||
const wrapper = shallow(
|
||||
<PostHeader {...props}/>
|
||||
);
|
||||
expect(wrapper.getElement()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue