MM-54173 group mention punctuation (#24402)

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Ross Baquir 2023-08-31 12:41:01 -07:00 committed by GitHub
parent f2fcf3d839
commit a2adc0e33e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 24 deletions

View File

@ -1,27 +1,56 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/AtMention should match snapshot when mentioning a group that is allowed reference 1`] = ` exports[`components/AtMention should match snapshot when mentioning a group followed by punctuation 1`] = `
<span> <Fragment>
<Memo(AtMentionGroup) <span>
group={ <Memo(AtMentionGroup)
Object { group={
"allow_reference": true, Object {
"create_at": 1, "allow_reference": true,
"delete_at": 0, "create_at": 1,
"description": "", "delete_at": 0,
"display_name": "group_display_name", "description": "",
"has_syncables": false, "display_name": "group_display_name",
"id": "qwerty1", "has_syncables": false,
"member_count": 0, "id": "qwerty1",
"name": "developers", "member_count": 0,
"remote_id": "", "name": "developers",
"scheme_admin": false, "remote_id": "",
"source": "", "scheme_admin": false,
"update_at": 1, "source": "",
"update_at": 1,
}
} }
} />
/> </span>
</span> .
</Fragment>
`;
exports[`components/AtMention should match snapshot when mentioning a group that is allowed reference 1`] = `
<Fragment>
<span>
<Memo(AtMentionGroup)
group={
Object {
"allow_reference": true,
"create_at": 1,
"delete_at": 0,
"description": "",
"display_name": "group_display_name",
"has_syncables": false,
"id": "qwerty1",
"member_count": 0,
"name": "developers",
"remote_id": "",
"scheme_admin": false,
"source": "",
"update_at": 1,
}
}
/>
</span>
</Fragment>
`; `;
exports[`components/AtMention should match snapshot when mentioning a group that is allowed reference with group highlight disabled 1`] = ` exports[`components/AtMention should match snapshot when mentioning a group that is allowed reference with group highlight disabled 1`] = `

View File

@ -214,6 +214,19 @@ describe('components/AtMention', () => {
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();
}); });
test('should match snapshot when mentioning a group followed by punctuation', () => {
const wrapper = shallow<AtMention>(
<AtMention
{...baseProps}
mentionName='developers.'
>
{'(at)-developers.'}
</AtMention>,
);
expect(wrapper).toMatchSnapshot();
});
test('should have placement state based on ref position of click handler', () => { test('should have placement state based on ref position of click handler', () => {
const wrapper = shallow<AtMention>( const wrapper = shallow<AtMention>(
<AtMention <AtMention

View File

@ -90,10 +90,18 @@ export default class AtMention extends React.PureComponent<Props, State> {
if (!this.props.disableGroupHighlight && !user) { if (!this.props.disableGroupHighlight && !user) {
const group = getUserOrGroupFromMentionName(this.props.groupsByName, this.props.mentionName) as Group | ''; const group = getUserOrGroupFromMentionName(this.props.groupsByName, this.props.mentionName) as Group | '';
if (group && group.allow_reference) { if (group && group.allow_reference) {
return (<span> const suffix = this.props.mentionName.substring(group.name.length);
<AtMentionGroup group={group}/>
</span>); return (
<>
<span>
<AtMentionGroup group={group}/>
</span>
{suffix}
</>
);
} }
} }