From 3638da2536c2421bb0fab4314eb120bb9a633dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20V=C3=A9lez=20Vidal?= Date: Fri, 29 Sep 2023 15:01:16 +0200 Subject: [PATCH] MM-54199 - attachment author name missing on mobile --- .../attachment_author.test.tsx.snap | 135 ++++++++++++++++++ .../attachment_author.test.tsx | 43 ++++++ .../message_attachment.tsx | 2 +- 3 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 app/components/post_list/post/body/content/message_attachments/__snapshots__/attachment_author.test.tsx.snap create mode 100644 app/components/post_list/post/body/content/message_attachments/attachment_author.test.tsx diff --git a/app/components/post_list/post/body/content/message_attachments/__snapshots__/attachment_author.test.tsx.snap b/app/components/post_list/post/body/content/message_attachments/__snapshots__/attachment_author.test.tsx.snap new file mode 100644 index 000000000..bd52a11b9 --- /dev/null +++ b/app/components/post_list/post/body/content/message_attachments/__snapshots__/attachment_author.test.tsx.snap @@ -0,0 +1,135 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AttachmentAuthor it matches snapshot when both name and icon are provided 1`] = ` + + + + + + jhondoe + + +`; + +exports[`AttachmentAuthor it matches snapshot when only icon is provided 1`] = ` + + + + + +`; + +exports[`AttachmentAuthor it matches snapshot when only name is provided 1`] = ` + + + jhondoe + + +`; diff --git a/app/components/post_list/post/body/content/message_attachments/attachment_author.test.tsx b/app/components/post_list/post/body/content/message_attachments/attachment_author.test.tsx new file mode 100644 index 000000000..98f49ca5f --- /dev/null +++ b/app/components/post_list/post/body/content/message_attachments/attachment_author.test.tsx @@ -0,0 +1,43 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; + +import Preferences from '@constants/preferences'; +import {renderWithIntl} from '@test/intl-test-helper'; + +import AttachmentAuthor from './attachment_author'; + +describe('AttachmentAuthor', () => { + const baseProps = { + link: 'http://linktoatachment.com', + name: 'jhondoe', + icon: 'https://images.com/image.png', + theme: Preferences.THEMES.denim, + }; + + test('it matches snapshot when both name and icon are provided', () => { + const wrapper = renderWithIntl(); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + test('it matches snapshot when only name is provided', () => { + const props = { + ...baseProps, + icon: undefined, + }; + + const wrapper = renderWithIntl(); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + test('it matches snapshot when only icon is provided', () => { + const props = { + ...baseProps, + name: undefined, + }; + + const wrapper = renderWithIntl(); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); +}); diff --git a/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx b/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx index 7b00e6268..ed557d6df 100644 --- a/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx +++ b/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx @@ -80,7 +80,7 @@ export default function MessageAttachment({attachment, channelId, layoutWidth, l value={attachment.pretext} /> - {Boolean(attachment.author_icon && attachment.author_name) && + {Boolean(attachment.author_icon || attachment.author_name) &&