Fix crash for unarchived system message (#4004)
This commit is contained in:
parent
b650c9acc0
commit
bdbef9444a
3 changed files with 15 additions and 1 deletions
|
|
@ -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`;
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue