diff options
author | Joas Schilling <coding@schilljs.com> | 2023-03-13 10:48:03 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-03-13 11:16:05 +0100 |
commit | 8d8b09ba9644b5953fc691a9bedbfa6bb644b687 (patch) | |
tree | 46ebd0228d728bf9f5373733b10787c8b9d62897 /tests | |
parent | 3e770939bf38a37350e71fc4d820bbfd3cf7855c (diff) |
fix(notifications): Only send reply notification when also mentioning
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 12 | ||||
-rw-r--r-- | tests/integration/features/chat/notifications.feature | 79 |
2 files changed, 82 insertions, 9 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 5f6f014c6..74fd1531b 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -1638,7 +1638,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { } /** - * @Then /^user "([^"]*)" (silent sends|sends) message "([^"]*)" to room "([^"]*)" with (\d+)(?: \((v1)\))?$/ + * @Then /^user "([^"]*)" (silent sends|sends) message ("[^"]*"|'[^']*') to room "([^"]*)" with (\d+)(?: \((v1)\))?$/ * * @param string $user * @param string $sendingMode @@ -1648,6 +1648,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { * @param string $apiVersion */ public function userSendsMessageToRoom(string $user, string $sendingMode, string $message, string $identifier, string $statusCode, string $apiVersion = 'v1') { + $message = substr($message, 1, -1); if ($sendingMode === 'silent sends') { $body = new TableNode([['message', $message], ['silent', true]]); } else { @@ -1696,6 +1697,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $response = $this->getDataFromResponse($this->response); if (isset($response['id'])) { self::$textToMessageId['shared::' . $type . '::' . $id] = $response['id']; + self::$messageIdToText[$response['id']] = 'shared::' . $type . '::' . $id; } } @@ -2026,13 +2028,14 @@ class FeatureContext implements Context, SnippetAcceptingContext { $response = $this->getDataFromResponse($this->response); if (isset($response['id'])) { self::$textToMessageId[$message] = $response['id']; + self::$messageIdToText[$response['id']] = $message; } Assert::assertStringStartsWith($response['referenceId'], $referenceId); } /** - * @Then /^user "([^"]*)" sends reply "([^"]*)" on message "([^"]*)" to room "([^"]*)" with (\d+)(?: \((v1)\))?$/ + * @Then /^user "([^"]*)" sends reply ("[^"]*"|'[^']*') on message ("[^"]*"|'[^']*') to room "([^"]*)" with (\d+)(?: \((v1)\))?$/ * * @param string $user * @param string $reply @@ -2042,6 +2045,8 @@ class FeatureContext implements Context, SnippetAcceptingContext { * @param string $apiVersion */ public function userSendsReplyToRoom($user, $reply, $message, $identifier, $statusCode, $apiVersion = 'v1') { + $reply = substr($reply, 1, -1); + $message = substr($message, 1, -1); $replyTo = self::$textToMessageId[$message]; $this->setCurrentUser($user); @@ -2055,6 +2060,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $response = $this->getDataFromResponse($this->response); if (isset($response['id'])) { self::$textToMessageId[$reply] = $response['id']; + self::$messageIdToText[$response['id']] = $reply; } } @@ -2196,6 +2202,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { self::$textToMessageId[$message['message']] = $message['id']; if ($message['message'] === '{file}' && isset($message['messageParameters']['file']['name'])) { self::$textToMessageId['shared::file::' . $message['messageParameters']['file']['name']] = $message['id']; + self::$messageIdToText[$message['id']] = 'shared::file::' . $message['messageParameters']['file']['name']; } } @@ -2308,6 +2315,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { // Include the received system messages in the list of messages used // for replies. self::$textToMessageId[$systemMessage['systemMessage']] = $systemMessage['id']; + self::$messageIdToText[$systemMessage['id']] = $systemMessage['systemMessage']; } if ($formData === null) { diff --git a/tests/integration/features/chat/notifications.feature b/tests/integration/features/chat/notifications.feature index 5dfa5d9ea..1e6d0da72 100644 --- a/tests/integration/features/chat/notifications.feature +++ b/tests/integration/features/chat/notifications.feature @@ -3,6 +3,8 @@ Feature: chat/notifications Background: Given user "participant1" exists Given user "participant2" exists + And group "attendees1" exists + And user "participant2" is member of group "attendees1" Scenario: Normal message when recipient is online in the one-to-one When user "participant1" creates room "one-to-one room" (v4) @@ -235,8 +237,8 @@ Feature: chat/notifications Given user "participant2" joins room "room" with 200 (v4) When user "participant1" sends message "Hi @all bye" to room "room" with 201 Then user "participant2" has the following notifications - | app | object_type | object_id | subject | - | spreed | chat | room/Hi @all bye | participant1-displayname mentioned you in conversation room | + | app | object_type | object_id | subject | + | spreed | chat | room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | Scenario: At-all when recipient is offline in the group room When user "participant1" creates room "room" (v4) @@ -248,8 +250,8 @@ Feature: chat/notifications Given user "participant2" leaves room "room" with 200 (v4) When user "participant1" sends message "Hi @all bye" to room "room" with 201 Then user "participant2" has the following notifications - | app | object_type | object_id | subject | - | spreed | chat | room/Hi @all bye | participant1-displayname mentioned you in conversation room | + | app | object_type | object_id | subject | + | spreed | chat | room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | Scenario: Silent at-all when recipient is offline in the group room When user "participant1" creates room "room" (v4) @@ -276,6 +278,69 @@ Feature: chat/notifications Then user "participant2" has the following notifications | app | object_type | object_id | subject | + Scenario: Group-mention when recipient is online in the group room + When user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + Given user "participant2" joins room "room" with 200 (v4) + When user "participant1" sends message 'Hi @"group/attendees1" bye' to room "room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + | spreed | chat | room/Hi @"group/attendees1" bye | participant1-displayname mentioned group attendees1 in conversation room | + + Scenario: Group-mention when recipient is offline in the group room + When user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + # Join and leave to clear the invite notification + Given user "participant2" joins room "room" with 200 (v4) + Given user "participant2" leaves room "room" with 200 (v4) + When user "participant1" sends message 'Hi @"group/attendees1" bye' to room "room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + | spreed | chat | room/Hi @"group/attendees1" bye | participant1-displayname mentioned group attendees1 in conversation room | + + Scenario: Silent group-mention when recipient is offline in the group room + When user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + # Join and leave to clear the invite notification + Given user "participant2" joins room "room" with 200 (v4) + Given user "participant2" leaves room "room" with 200 (v4) + When user "participant1" silent sends message 'Hi @"group/attendees1" bye' to room "room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + + Scenario: Group-mention when recipient with disabled notifications in the group room + When user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + # Join and leave to clear the invite notification + Given user "participant2" joins room "room" with 200 (v4) + Given user "participant2" leaves room "room" with 200 (v4) + And user "participant2" sets notifications to disabled for room "room" (v4) + When user "participant1" sends message 'Hi @"group/attendees1" bye' to room "room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + + Scenario: Replying with all mention types only gives a reply notification + When user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + # Join and leave to clear the invite notification + Given user "participant2" joins room "room" with 200 (v4) + Given user "participant2" leaves room "room" with 200 (v4) + When user "participant2" sends message "Hi part 1" to room "room" with 201 + When user "participant1" sends reply 'Hi @all @participant2 @"group/attendees1" bye' on message "Hi part 1" to room "room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + | spreed | chat | room/Hi @all @participant2 @"group/attendees1" bye | participant1-displayname replied to your message in conversation room | + Scenario: Delete notification when the message is deleted When user "participant1" creates room "one-to-one room" (v4) | roomType | 1 | @@ -355,7 +420,7 @@ Feature: chat/notifications | app | object_type | object_id | subject | | spreed | chat | room/Hi @participant2 | participant1-displayname mentioned you in conversation room | | spreed | chat | room/Message 1 | participant1-displayname reacted with 🚀 to your message in conversation room | - | spreed | chat | room/Hi @all bye | participant1-displayname mentioned you in conversation room | + | spreed | chat | room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | Scenario: Lobby: Notifications for moderators Given user "participant1" creates room "room" (v4) @@ -376,7 +441,7 @@ Feature: chat/notifications | app | object_type | object_id | subject | | spreed | chat | room/Hi @participant2 | participant1-displayname mentioned you in conversation room | | spreed | chat | room/Message 1 | participant1-displayname reacted with 🚀 to your message in conversation room | - | spreed | chat | room/Hi @all bye | participant1-displayname mentioned you in conversation room | + | spreed | chat | room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | Scenario: Lobby: Wipe notifications when being blocked by the lobby Given user "participant1" creates room "room" (v4) @@ -395,7 +460,7 @@ Feature: chat/notifications | app | object_type | object_id | subject | | spreed | chat | room/Hi @participant2 | participant1-displayname mentioned you in conversation room | | spreed | chat | room/Message 1 | participant1-displayname reacted with 🚀 to your message in conversation room | - | spreed | chat | room/Hi @all bye | participant1-displayname mentioned you in conversation room | + | spreed | chat | room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | When user "participant1" sets lobby state for room "room" to "non moderators" with 200 (v4) Then user "participant2" has the following notifications | app | object_type | object_id | subject | |