Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-54199 - attachment author name missing on mobile #7575

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AttachmentAuthor it matches snapshot when both name and icon are provided 1`] = `
<View
style={
{
"flex": 1,
"flexDirection": "row",
}
}
>
<View
style={
[
{
"overflow": "hidden",
},
{
"height": 12,
"marginRight": 3,
"width": 12,
},
]
}
>
<FastImageView
defaultSource={null}
resizeMode="cover"
source={
{
"uri": "https://images.com/image.png",
}
}
style={
{
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
}
}
/>
</View>
<Text
onPress={[Function]}
style={
[
{
"color": "rgba(63,67,80,0.5)",
"fontSize": 11,
},
{
"color": "rgba(28,88,217,0.5)",
},
]
}
>
jhondoe
</Text>
</View>
`;

exports[`AttachmentAuthor it matches snapshot when only icon is provided 1`] = `
<View
style={
{
"flex": 1,
"flexDirection": "row",
}
}
>
<View
style={
[
{
"overflow": "hidden",
},
{
"height": 12,
"marginRight": 3,
"width": 12,
},
]
}
>
<FastImageView
defaultSource={null}
resizeMode="cover"
source={
{
"uri": "https://images.com/image.png",
}
}
style={
{
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
}
}
/>
</View>
</View>
`;

exports[`AttachmentAuthor it matches snapshot when only name is provided 1`] = `
<View
style={
{
"flex": 1,
"flexDirection": "row",
}
}
>
<Text
onPress={[Function]}
style={
[
{
"color": "rgba(63,67,80,0.5)",
"fontSize": 11,
},
{
"color": "rgba(28,88,217,0.5)",
},
]
}
>
jhondoe
</Text>
</View>
`;
Original file line number Diff line number Diff line change
@@ -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',
larkox marked this conversation as resolved.
Show resolved Hide resolved
icon: 'https://images.com/image.png',
theme: Preferences.THEMES.denim,
};

test('it matches snapshot when both name and icon are provided', () => {
const wrapper = renderWithIntl(<AttachmentAuthor {...baseProps}/>);
expect(wrapper.toJSON()).toMatchSnapshot();
});

test('it matches snapshot when only name is provided', () => {
const props = {
...baseProps,
icon: undefined,
};

const wrapper = renderWithIntl(<AttachmentAuthor {...props}/>);
expect(wrapper.toJSON()).toMatchSnapshot();
});

test('it matches snapshot when only icon is provided', () => {
const props = {
...baseProps,
name: undefined,
};

const wrapper = renderWithIntl(<AttachmentAuthor {...props}/>);
expect(wrapper.toJSON()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function MessageAttachment({attachment, channelId, layoutWidth, l
value={attachment.pretext}
/>
<View style={[style.container, style.border, borderStyle]}>
{Boolean(attachment.author_icon && attachment.author_name) &&
{Boolean(attachment.author_icon || attachment.author_name) &&
<AttachmentAuthor
icon={attachment.author_icon}
link={attachment.author_link}
Expand Down