diff options
author | Joas Schilling <coding@schilljs.com> | 2022-05-06 09:59:27 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-05-13 11:34:23 +0200 |
commit | 866201678f95301ef37d2a93ea05707edb0f6927 (patch) | |
tree | e1f7861a36e3d5338353365b11c66b9b32c39538 /tests | |
parent | 2742779a7621e13bb92a059eda34b4a433f739f9 (diff) |
Add an option for "Silent send" to the API
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 13 | ||||
-rw-r--r-- | tests/integration/features/chat/notifications.feature | 35 | ||||
-rw-r--r-- | tests/php/CapabilitiesTest.php | 1 | ||||
-rw-r--r-- | tests/php/Chat/ChatManagerTest.php | 2 | ||||
-rw-r--r-- | tests/php/Chat/NotifierTest.php | 4 |
5 files changed, 49 insertions, 6 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 65e30539f..264a57629 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -1399,19 +1399,26 @@ class FeatureContext implements Context, SnippetAcceptingContext { } /** - * @Then /^user "([^"]*)" sends message "([^"]*)" to room "([^"]*)" with (\d+)(?: \((v1)\))?$/ + * @Then /^user "([^"]*)" (silent sends|sends) message "([^"]*)" to room "([^"]*)" with (\d+)(?: \((v1)\))?$/ * * @param string $user + * @param string $sendingMode * @param string $message * @param string $identifier * @param string $statusCode * @param string $apiVersion */ - public function userSendsMessageToRoom($user, $message, $identifier, $statusCode, $apiVersion = 'v1') { + public function userSendsMessageToRoom(string $user, string $sendingMode, string $message, string $identifier, string $statusCode, string $apiVersion = 'v1') { + if ($sendingMode === 'silent sends') { + $body = new TableNode([['message', $message], ['silent', true]]); + } else { + $body = new TableNode([['message', $message]]); + } + $this->setCurrentUser($user); $this->sendRequest( 'POST', '/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier], - new TableNode([['message', $message]]) + $body ); $this->assertStatusCode($this->response, $statusCode); sleep(1); // make sure Postgres manages the order of the messages diff --git a/tests/integration/features/chat/notifications.feature b/tests/integration/features/chat/notifications.feature index 4d62db44c..8301f8345 100644 --- a/tests/integration/features/chat/notifications.feature +++ b/tests/integration/features/chat/notifications.feature @@ -25,6 +25,17 @@ Feature: chat/notifications | app | object_type | object_id | subject | | spreed | chat | one-to-one room/Message 1 | participant1-displayname sent you a private message | + Scenario: Silent sent message when recipient is offline in the one-to-one + When user "participant1" creates room "one-to-one room" (v4) + | roomType | 1 | + | invite | participant2 | + # Join and leave to clear the invite notification + Given user "participant2" joins room "one-to-one room" with 200 (v4) + Given user "participant2" leaves room "one-to-one room" with 200 (v4) + When user "participant1" silent sends message "Message 1" to room "one-to-one room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + Scenario: Normal message when recipient disabled notifications in the one-to-one When user "participant1" creates room "one-to-one room" (v4) | roomType | 1 | @@ -152,6 +163,18 @@ Feature: chat/notifications | app | object_type | object_id | subject | | spreed | chat | room/Hi @participant2 bye | participant1-displayname mentioned you in conversation room | + Scenario: Silent 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) + # 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 @participant2 bye" to room "room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + Scenario: Mention when recipient is offline in the group room When user "participant1" creates room "room" (v4) | roomType | 2 | @@ -202,6 +225,18 @@ Feature: chat/notifications | app | object_type | object_id | subject | | spreed | chat | room/Hi @all bye | participant1-displayname mentioned you in conversation room | + Scenario: Silent at-all 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 @all bye" to room "room" with 201 + Then user "participant2" has the following notifications + | app | object_type | object_id | subject | + Scenario: At-all when recipient with disabled notifications in the group room When user "participant1" creates room "room" (v4) | roomType | 2 | diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index e64a66c9d..60cb07ab2 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -107,6 +107,7 @@ class CapabilitiesTest extends TestCase { 'rich-object-list-media', 'rich-object-delete', 'chat-permission', + 'silent-send', 'reactions', ]; } diff --git a/tests/php/Chat/ChatManagerTest.php b/tests/php/Chat/ChatManagerTest.php index 86750e8c4..e0e79869f 100644 --- a/tests/php/Chat/ChatManagerTest.php +++ b/tests/php/Chat/ChatManagerTest.php @@ -275,7 +275,7 @@ class ChatManagerTest extends TestCase { $participant = $this->createMock(Participant::class); - $return = $this->chatManager->sendMessage($chat, $participant, 'users', $userId, $message, $creationDateTime, $replyTo, $referenceId); + $return = $this->chatManager->sendMessage($chat, $participant, 'users', $userId, $message, $creationDateTime, $replyTo, $referenceId, false); $this->assertCommentEquals($commentExpected, $return); } diff --git a/tests/php/Chat/NotifierTest.php b/tests/php/Chat/NotifierTest.php index 0acec8008..25133491b 100644 --- a/tests/php/Chat/NotifierTest.php +++ b/tests/php/Chat/NotifierTest.php @@ -177,7 +177,7 @@ class NotifierTest extends TestCase { 'type' => Attendee::ACTOR_USERS, ]; }, $expectedReturn); - $actual = $notifier->notifyMentionedUsers($room, $comment, $alreadyNotifiedUsers); + $actual = $notifier->notifyMentionedUsers($room, $comment, $alreadyNotifiedUsers, false); $this->assertEqualsCanonicalizing($expectedReturn, $actual); } @@ -341,7 +341,7 @@ class NotifierTest extends TestCase { $this->assertCount(count($return), $actual); foreach ($actual as $key => $value) { $this->assertIsArray($value); - if (key_exists('attendee', $value)) { + if (array_key_exists('attendee', $value)) { $this->assertInstanceOf(Attendee::class, $value['attendee']); unset($value['attendee']); } |