Fix crash for unarchived system message (#4004)

This commit is contained in:
Miguel Alatzar 2020-03-05 16:39:37 -07:00 committed by GitHub
parent b650c9acc0
commit bdbef9444a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -49,3 +49,5 @@ exports[`renderSystemMessage uses renderer for unarchived channel 1`] = `
value="{username} unarchived the channel"
/>
`;
exports[`renderSystemMessage uses renderer for unarchived channel 2`] = `null`;

View file

@ -147,6 +147,9 @@ const renderArchivedMessage = (postBodyProps, styles, intl) => {
const renderUnarchivedMessage = (postBodyProps, styles, intl) => {
const {postProps} = postBodyProps;
if (!postProps?.username) {
return null;
}
const username = renderUsername(postProps.username);
const localeHolder = {

View file

@ -87,7 +87,16 @@ describe('renderSystemMessage', () => {
postType: Posts.POST_TYPES.CHANNEL_UNARCHIVED,
};
const renderedMessage = SystemMessageHelpers.renderSystemMessage(postBodyProps, mockStyles, mockIntl);
let renderedMessage = SystemMessageHelpers.renderSystemMessage(postBodyProps, mockStyles, mockIntl);
expect(renderedMessage).toMatchSnapshot();
const noUserInPostBodyProps = {
...basePostBodyProps,
postProps: {},
postType: Posts.POST_TYPES.CHANNEL_UNARCHIVED,
};
renderedMessage = SystemMessageHelpers.renderSystemMessage(noUserInPostBodyProps, mockStyles, mockIntl);
expect(renderedMessage).toMatchSnapshot();
});