diff options
author | Joas Schilling <coding@schilljs.com> | 2023-01-30 11:06:53 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-01-31 11:25:49 +0100 |
commit | 12b8adaff5e9f3dca4df0b24a20d316c8b66e27e (patch) | |
tree | 3eb197e973ed022c39b90617bb078342464ae98c /tests | |
parent | 7dc878f1899d646c925ee5b073a93430cf3e40d5 (diff) |
Only filter mentions for conversation members
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 48 | ||||
-rw-r--r-- | tests/integration/features/conversation/add-participant.feature | 43 |
2 files changed, 91 insertions, 0 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 7e91444b4..aa5729251 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -2343,6 +2343,54 @@ class FeatureContext implements Context, SnippetAcceptingContext { } /** + * @Then /^user "([^"]*)" gets the following collaborator suggestions in room "([^"]*)" for "([^"]*)" with (\d+)$/ + * + * @param string $user + * @param string $identifier + * @param string $search + * @param string $statusCode + * @param string $apiVersion + * @param TableNode|null $formData + */ + public function userGetsTheFollowingCollaboratorSuggestions($user, $identifier, $search, $statusCode, $apiVersion = 'v1', TableNode $formData = null) { + $this->setCurrentUser($user); + $this->sendRequest('GET', '/core/autocomplete/get?search=' . $search . '&itemType=call&itemId=' . self::$identifierToToken[$identifier] . '&shareTypes[]=0&shareTypes[]=1&shareTypes[]=7&shareTypes[]=4'); + $this->assertStatusCode($this->response, $statusCode); + + $mentions = $this->getDataFromResponse($this->response); + + if ($formData === null) { + Assert::assertEmpty($mentions); + return; + } + + Assert::assertCount(count($formData->getHash()), $mentions, 'Mentions count does not match'); + + usort($mentions, function ($a, $b) { + if ($a['source'] === $b['source']) { + return $a['label'] <=> $b['label']; + } + return $a['source'] <=> $b['source']; + }); + + $expected = $formData->getHash(); + usort($expected, function ($a, $b) { + if ($a['source'] === $b['source']) { + return $a['label'] <=> $b['label']; + } + return $a['source'] <=> $b['source']; + }); + + foreach ($expected as $key => $row) { + unset($mentions[$key]['icon']); + unset($mentions[$key]['status']); + unset($mentions[$key]['subline']); + unset($mentions[$key]['shareWithDisplayNameUnique']); + Assert::assertEquals($row, $mentions[$key]); + } + } + + /** * @Then /^guest "([^"]*)" sets name to "([^"]*)" in room "([^"]*)" with (\d+)(?: \((v1)\))?$/ * * @param string $user diff --git a/tests/integration/features/conversation/add-participant.feature b/tests/integration/features/conversation/add-participant.feature index eb8b6f110..6799e9556 100644 --- a/tests/integration/features/conversation/add-participant.feature +++ b/tests/integration/features/conversation/add-participant.feature @@ -133,3 +133,46 @@ Feature: conversation/add-participant | users | participant1 | 1 | And user "participant2" is not participant of room "room" (v4) And user "participant3" is not participant of room "room" (v4) + + Scenario: Getting participant suggestions in a private room + Given user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" gets the following collaborator suggestions in room "room" for "particip" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + | users | participant3 | participant3-displayname | + And user "participant1" gets the following collaborator suggestions in room "room" for "participant2" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + And user "participant3" gets the following collaborator suggestions in room "room" for "participant2" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + And user "participant1" gets the following collaborator suggestions in room "room" for "participant2" with 200 + And user "participant3" gets the following collaborator suggestions in room "room" for "participant2" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + + Scenario: Getting participant suggestions in a public room + Given user "participant1" creates room "room" (v4) + | roomType | 3 | + | roomName | room | + And user "participant1" gets the following collaborator suggestions in room "room" for "particip" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + | users | participant3 | participant3-displayname | + And user "participant1" gets the following collaborator suggestions in room "room" for "participant2" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + And user "participant3" gets the following collaborator suggestions in room "room" for "participant2" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + And user "guest" joins room "room" with 200 (v4) + And user "guest" gets the following collaborator suggestions in room "room" for "participant2" with 401 + And user "participant1" adds user "participant2" to room "room" with 200 (v4) + And user "participant1" gets the following collaborator suggestions in room "room" for "participant2" with 200 + And user "participant3" gets the following collaborator suggestions in room "room" for "participant2" with 200 + | source | id | label | + | users | participant2 | participant2-displayname | + And user "guest" gets the following collaborator suggestions in room "room" for "participant2" with 401 |