summaryrefslogtreecommitdiffstats
path: root/app/notification_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-04-02 12:40:28 -0400
committerGitHub <noreply@github.com>2018-04-02 12:40:28 -0400
commit088f76ad6e2d10a1c50ef548f2226213271abde3 (patch)
tree3132588e6b38e7b618e32b81cddf5b08c16450f9 /app/notification_test.go
parentcffb8918544aaaabbeccd3a84ab5173fee7b18c8 (diff)
downloadchat-088f76ad6e2d10a1c50ef548f2226213271abde3.tar.gz
chat-088f76ad6e2d10a1c50ef548f2226213271abde3.tar.bz2
chat-088f76ad6e2d10a1c50ef548f2226213271abde3.zip
MM-9868 Fixed mentioning users when followed by multiple periods (#8548)
* MM-9868 Fixed mentioning users when followed by multiple periods * Added additional unit test * Added comment to clarify test purpose
Diffstat (limited to 'app/notification_test.go')
-rw-r--r--app/notification_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/app/notification_test.go b/app/notification_test.go
index 05574eb08..c72610b60 100644
--- a/app/notification_test.go
+++ b/app/notification_test.go
@@ -344,6 +344,45 @@ func TestGetExplicitMentions(t *testing.T) {
ChannelMentioned: true,
},
},
+
+ // The following tests cover cases where the message mentions @user.name, so we shouldn't assume that
+ // the user might be intending to mention some @user that isn't in the channel.
+ "Don't include potential mention that's part of an actual mention (without trailing period)": {
+ Message: "this is an message for @user.name",
+ Keywords: map[string][]string{"@user.name": {id1}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ },
+ },
+ },
+ "Don't include potential mention that's part of an actual mention (with trailing period)": {
+ Message: "this is an message for @user.name.",
+ Keywords: map[string][]string{"@user.name": {id1}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ },
+ },
+ },
+ "Don't include potential mention that's part of an actual mention (with multiple trailing periods)": {
+ Message: "this is an message for @user.name...",
+ Keywords: map[string][]string{"@user.name": {id1}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ },
+ },
+ },
+ "Don't include potential mention that's part of an actual mention (containing and followed by multiple periods)": {
+ Message: "this is an message for @user...name...",
+ Keywords: map[string][]string{"@user...name": {id1}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ },
+ },
+ },
} {
t.Run(name, func(t *testing.T) {
m := GetExplicitMentions(tc.Message, tc.Keywords)