From a2adc0e33e4550d45579e7453633e7f93614f510 Mon Sep 17 00:00:00 2001 From: Ross Baquir Date: Thu, 31 Aug 2023 12:41:01 -0700 Subject: [PATCH] MM-54173 group mention punctuation (#24402) Co-authored-by: Mattermost Build --- .../__snapshots__/at_mention.test.tsx.snap | 71 +++++++++++++------ .../components/at_mention/at_mention.test.tsx | 13 ++++ .../src/components/at_mention/at_mention.tsx | 14 +++- 3 files changed, 74 insertions(+), 24 deletions(-) diff --git a/webapp/channels/src/components/at_mention/__snapshots__/at_mention.test.tsx.snap b/webapp/channels/src/components/at_mention/__snapshots__/at_mention.test.tsx.snap index 1f24fe5154..b4810a8d4b 100644 --- a/webapp/channels/src/components/at_mention/__snapshots__/at_mention.test.tsx.snap +++ b/webapp/channels/src/components/at_mention/__snapshots__/at_mention.test.tsx.snap @@ -1,27 +1,56 @@ // 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 that is allowed reference 1`] = ` + + + + + `; exports[`components/AtMention should match snapshot when mentioning a group that is allowed reference with group highlight disabled 1`] = ` diff --git a/webapp/channels/src/components/at_mention/at_mention.test.tsx b/webapp/channels/src/components/at_mention/at_mention.test.tsx index 5301a1c681..495b56dae5 100644 --- a/webapp/channels/src/components/at_mention/at_mention.test.tsx +++ b/webapp/channels/src/components/at_mention/at_mention.test.tsx @@ -214,6 +214,19 @@ describe('components/AtMention', () => { expect(wrapper).toMatchSnapshot(); }); + test('should match snapshot when mentioning a group followed by punctuation', () => { + const wrapper = shallow( + + {'(at)-developers.'} + , + ); + + expect(wrapper).toMatchSnapshot(); + }); + test('should have placement state based on ref position of click handler', () => { const wrapper = shallow( { if (!this.props.disableGroupHighlight && !user) { const group = getUserOrGroupFromMentionName(this.props.groupsByName, this.props.mentionName) as Group | ''; + if (group && group.allow_reference) { - return ( - - ); + const suffix = this.props.mentionName.substring(group.name.length); + + return ( + <> + + + + {suffix} + + ); } }