summaryrefslogtreecommitdiffstats
path: root/app/notification_test.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-10-30 13:15:01 +0100
committerJoram Wilander <jwawilander@gmail.com>2017-10-30 08:15:01 -0400
commit63df41b91110bac06baffef87fe0c1952b47ac93 (patch)
tree78b76635c349c3472a19a41b5fdf8333cda5879a /app/notification_test.go
parentbbe971cc4522dfa567d7dceafcf30a7afd5c35be (diff)
downloadchat-63df41b91110bac06baffef87fe0c1952b47ac93.tar.gz
chat-63df41b91110bac06baffef87fe0c1952b47ac93.tar.bz2
chat-63df41b91110bac06baffef87fe0c1952b47ac93.zip
fix push notification when user status is in DND (#7731)
Diffstat (limited to 'app/notification_test.go')
-rw-r--r--app/notification_test.go35
1 files changed, 32 insertions, 3 deletions
diff --git a/app/notification_test.go b/app/notification_test.go
index 51dba7c0e..83e725646 100644
--- a/app/notification_test.go
+++ b/app/notification_test.go
@@ -796,6 +796,7 @@ func TestDoesStatusAllowPushNotification(t *testing.T) {
offline := &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
away := &model.Status{UserId: userId, Status: model.STATUS_AWAY, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
online := &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
+ dnd := &model.Status{UserId: userId, Status: model.STATUS_DND, Manual: true, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
userNotifyProps["push_status"] = model.STATUS_ONLINE
// WHEN props is ONLINE and user is offline
@@ -825,6 +826,15 @@ func TestDoesStatusAllowPushNotification(t *testing.T) {
t.Fatal("Should have been false")
}
+ // WHEN props is ONLINE and user is dnd
+ if DoesStatusAllowPushNotification(userNotifyProps, dnd, channelId) {
+ t.Fatal("Should have been false")
+ }
+
+ if DoesStatusAllowPushNotification(userNotifyProps, dnd, "") {
+ t.Fatal("Should have been false")
+ }
+
userNotifyProps["push_status"] = model.STATUS_AWAY
// WHEN props is AWAY and user is offline
if !DoesStatusAllowPushNotification(userNotifyProps, offline, channelId) {
@@ -853,8 +863,17 @@ func TestDoesStatusAllowPushNotification(t *testing.T) {
t.Fatal("Should have been false")
}
+ // WHEN props is AWAY and user is dnd
+ if DoesStatusAllowPushNotification(userNotifyProps, dnd, channelId) {
+ t.Fatal("Should have been false")
+ }
+
+ if DoesStatusAllowPushNotification(userNotifyProps, dnd, "") {
+ t.Fatal("Should have been false")
+ }
+
userNotifyProps["push_status"] = model.STATUS_OFFLINE
- // WHEN props is AWAY and user is offline
+ // WHEN props is OFFLINE and user is offline
if !DoesStatusAllowPushNotification(userNotifyProps, offline, channelId) {
t.Fatal("Should have been true")
}
@@ -863,7 +882,7 @@ func TestDoesStatusAllowPushNotification(t *testing.T) {
t.Fatal("Should have been true")
}
- // WHEN props is AWAY and user is away
+ // WHEN props is OFFLINE and user is away
if DoesStatusAllowPushNotification(userNotifyProps, away, channelId) {
t.Fatal("Should have been false")
}
@@ -872,7 +891,7 @@ func TestDoesStatusAllowPushNotification(t *testing.T) {
t.Fatal("Should have been false")
}
- // WHEN props is AWAY and user is online
+ // WHEN props is OFFLINE and user is online
if DoesStatusAllowPushNotification(userNotifyProps, online, channelId) {
t.Fatal("Should have been false")
}
@@ -880,6 +899,16 @@ func TestDoesStatusAllowPushNotification(t *testing.T) {
if DoesStatusAllowPushNotification(userNotifyProps, online, "") {
t.Fatal("Should have been false")
}
+
+ // WHEN props is OFFLINE and user is dnd
+ if DoesStatusAllowPushNotification(userNotifyProps, dnd, channelId) {
+ t.Fatal("Should have been false")
+ }
+
+ if DoesStatusAllowPushNotification(userNotifyProps, dnd, "") {
+ t.Fatal("Should have been false")
+ }
+
}
func TestGetDirectMessageNotificationEmailSubject(t *testing.T) {