diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 5dc2db47bb4..5d7e7318664 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -573,6 +573,37 @@ public function userSeesTheFollowingSystemMessagesInRoom($user, $identifier, $st }, $messages)); } + /** + * @Then /^user "([^"]*)" gets the following candidate mentions in room "([^"]*)" for "([^"]*)" with (\d+)$/ + * + * @param string $user + * @param string $identifier + * @param string $search + * @param string $statusCode + * @param TableNode|null $formData + */ + public function userGetsTheFollowingCandidateMentionsInRoomFor($user, $identifier, $search, $statusCode, TableNode $formData = null) { + $this->setCurrentUser($user); + $this->sendRequest('GET', '/apps/spreed/api/v1/chat/' . self::$identifierToToken[$identifier] . '/mentions?search=' . $search); + $this->assertStatusCode($this->response, $statusCode); + + $mentions = $this->getDataFromResponse($this->response); + + if ($formData === null) { + PHPUnit_Framework_Assert::assertEmpty($mentions); + return; + } + + PHPUnit_Framework_Assert::assertCount(count($formData->getHash()), $mentions, 'Mentions count does not match'); + PHPUnit_Framework_Assert::assertEquals($formData->getHash(), array_map(function($mention) { + return [ + 'id' => (string) $mention['id'], + 'label' => (string) $mention['label'], + 'source' => (string) $mention['source'], + ]; + }, $mentions)); + } + /** * Parses the xml answer to get the array of users returned. * @param ResponseInterface $response diff --git a/tests/integration/features/chat/mentions.feature b/tests/integration/features/chat/mentions.feature new file mode 100644 index 00000000000..c09a038ad86 --- /dev/null +++ b/tests/integration/features/chat/mentions.feature @@ -0,0 +1,185 @@ +Feature: chat/mentions + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + Given user "participant4" exists + + Scenario: get mentions in a one-to-one room + When user "participant1" creates room "one-to-one room" + | roomType | 1 | + | invite | participant2 | + Then user "participant1" gets the following candidate mentions in room "one-to-one room" for "" with 200 + | id | label | source | + | participant2 | participant2-displayname | users | + And user "participant2" gets the following candidate mentions in room "one-to-one room" for "" with 200 + | id | label | source | + | participant1 | participant1-displayname | users | + + Scenario: get matched mentions in a one-to-one room + When user "participant1" creates room "one-to-one room" + | roomType | 1 | + | invite | participant2 | + Then user "participant1" gets the following candidate mentions in room "one-to-one room" for "part" with 200 + | id | label | source | + | participant2 | participant2-displayname | users | + And user "participant2" gets the following candidate mentions in room "one-to-one room" for "part" with 200 + | id | label | source | + | participant1 | participant1-displayname | users | + + Scenario: get unmatched mentions in a one-to-one room + When user "participant1" creates room "one-to-one room" + | roomType | 1 | + | invite | participant2 | + Then user "participant1" gets the following candidate mentions in room "one-to-one room" for "unknown" with 200 + And user "participant2" gets the following candidate mentions in room "one-to-one room" for "unknown" with 200 + + Scenario: get mentions in a one-to-one room with a participant not in the room + When user "participant1" creates room "one-to-one room" + | roomType | 1 | + | invite | participant2 | + Then user "participant3" gets the following candidate mentions in room "one-to-one room" for "" with 404 + + + + Scenario: get mentions in a group room with no other participant + When user "participant1" creates room "group room" + | roomType | 2 | + | roomName | room | + Then user "participant1" gets the following candidate mentions in room "group room" for "" with 200 + | id | label | source | + | all | room | calls | + + Scenario: get mentions in a group room + When user "participant1" creates room "group room" + | roomType | 2 | + | roomName | room | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + Then user "participant1" gets the following candidate mentions in room "group room" for "" with 200 + | id | label | source | + | all | room | calls | + | participant2 | participant2-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant2" gets the following candidate mentions in room "group room" for "" with 200 + | id | label | source | + | all | room | calls | + | participant1 | participant1-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant3" gets the following candidate mentions in room "group room" for "" with 200 + | id | label | source | + | all | room | calls | + | participant1 | participant1-displayname | users | + | participant2 | participant2-displayname | users | + + Scenario: get matched mentions in a group room + When user "participant1" creates room "group room" + | roomType | 2 | + | roomName | room | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + Then user "participant1" gets the following candidate mentions in room "group room" for "part" with 200 + | id | label | source | + | participant2 | participant2-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant2" gets the following candidate mentions in room "group room" for "part" with 200 + | id | label | source | + | participant1 | participant1-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant3" gets the following candidate mentions in room "group room" for "part" with 200 + | id | label | source | + | participant1 | participant1-displayname | users | + | participant2 | participant2-displayname | users | + + Scenario: get unmatched mentions in a group room + When user "participant1" creates room "group room" + | roomType | 2 | + | roomName | room | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + Then user "participant1" gets the following candidate mentions in room "group room" for "unknown" with 200 + And user "participant2" gets the following candidate mentions in room "group room" for "unknown" with 200 + And user "participant3" gets the following candidate mentions in room "group room" for "unknown" with 200 + + Scenario: get mentions in a group room with a participant not in the room + When user "participant1" creates room "group room" + | roomType | 2 | + | roomName | room | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + Then user "participant4" gets the following candidate mentions in room "group room" for "" with 404 + + + + Scenario: get mentions in a public room with no other participant + When user "participant1" creates room "public room" + | roomType | 3 | + | roomName | room | + Then user "participant1" gets the following candidate mentions in room "public room" for "" with 200 + | id | label | source | + | all | room | calls | + + Scenario: get mentions in a public room + When user "participant1" creates room "public room" + | roomType | 3 | + | roomName | room | + And user "participant1" adds "participant2" to room "public room" with 200 + And user "participant3" joins room "public room" with 200 + And user "guest" joins room "public room" with 200 + Then user "participant1" gets the following candidate mentions in room "public room" for "" with 200 + | id | label | source | + | all | room | calls | + | participant2 | participant2-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant2" gets the following candidate mentions in room "public room" for "" with 200 + | id | label | source | + | all | room | calls | + | participant1 | participant1-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant3" gets the following candidate mentions in room "public room" for "" with 200 + | id | label | source | + | all | room | calls | + | participant1 | participant1-displayname | users | + | participant2 | participant2-displayname | users | + + Scenario: get matched mentions in a public room + When user "participant1" creates room "public room" + | roomType | 3 | + | roomName | room | + And user "participant1" adds "participant2" to room "public room" with 200 + And user "participant3" joins room "public room" with 200 + And user "guest" joins room "public room" with 200 + Then user "participant1" gets the following candidate mentions in room "public room" for "part" with 200 + | id | label | source | + | participant2 | participant2-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant2" gets the following candidate mentions in room "public room" for "part" with 200 + | id | label | source | + | participant1 | participant1-displayname | users | + | participant3 | participant3-displayname | users | + And user "participant3" gets the following candidate mentions in room "public room" for "part" with 200 + | id | label | source | + | participant1 | participant1-displayname | users | + | participant2 | participant2-displayname | users | + + Scenario: get unmatched mentions in a public room + When user "participant1" creates room "public room" + | roomType | 3 | + | roomName | room | + And user "participant1" adds "participant2" to room "public room" with 200 + And user "participant3" joins room "public room" with 200 + And user "guest" joins room "public room" with 200 + Then user "participant1" gets the following candidate mentions in room "public room" for "unknown" with 200 + And user "participant2" gets the following candidate mentions in room "public room" for "unknown" with 200 + And user "participant3" gets the following candidate mentions in room "public room" for "unknown" with 200 + + Scenario: get mentions in a public room with a participant not in the room + When user "participant1" creates room "public room" + | roomType | 3 | + | roomName | room | + And user "participant1" adds "participant2" to room "public room" with 200 + And user "participant3" joins room "public room" with 200 + And user "guest" joins room "public room" with 200 + Then user "participant4" gets the following candidate mentions in room "public room" for "" with 404 + And user "guest2" gets the following candidate mentions in room "public room" for "" with 404