diff options
-rw-r--r-- | lib/Controller/ChatController.php | 2 | ||||
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 24 | ||||
-rw-r--r-- | tests/integration/features/chat/reply.feature | 17 |
3 files changed, 42 insertions, 1 deletions
diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 1f4afbe2b..3e9b793e8 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -305,7 +305,7 @@ class ChatController extends AEnvironmentAwareController { $commentKey = $commentIdToIndex[$commentId]; // Parent is already parsed in the message list - if (!empty($commentIdToIndex[$parentId])) { + if (isset($commentIdToIndex[$parentId])) { $parentKey = $commentIdToIndex[$parentId]; $messages[$commentKey]['parent'] = $messages[$parentKey]; diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index db78038ff..891f30d8e 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -774,6 +774,30 @@ class FeatureContext implements Context, SnippetAcceptingContext { $this->sendRequest('GET', '/apps/spreed/api/v1/chat/' . self::$identifierToToken[$identifier] . '?lookIntoFuture=0'); $this->assertStatusCode($this->response, $statusCode); + $this->compareDataResponse($formData); + } + + /** + * @Then /^user "([^"]*)" sees the following messages in room "([^"]*)" starting with "([^"]*)" with (\d+)$/ + * + * @param string $user + * @param string $identifier + * @param string $knwonMessage + * @param string $statusCode + * @param TableNode|null $formData + */ + public function userAwaitsTheFollowingMessagesInRoom($user, $identifier, $knwonMessage, $statusCode, TableNode $formData = null) { + $this->setCurrentUser($user); + $this->sendRequest('GET', '/apps/spreed/api/v1/chat/' . self::$identifierToToken[$identifier] . '?lookIntoFuture=1&includeLastKnown=1&lastKnownMessageId=' . self::$messages[$knwonMessage]); + $this->assertStatusCode($this->response, $statusCode); + + $this->compareDataResponse($formData); + } + + /** + * @param TableNode|null $formData + */ + protected function compareDataResponse(TableNode $formData = null) { $actual = $this->getDataFromResponse($this->response); $messages = []; array_map(function (array $message) use (&$messages) { diff --git a/tests/integration/features/chat/reply.feature b/tests/integration/features/chat/reply.feature index 4a8c9a56e..f2a2fcaf1 100644 --- a/tests/integration/features/chat/reply.feature +++ b/tests/integration/features/chat/reply.feature @@ -185,6 +185,23 @@ Feature: chat/reply | group room | users | participant2 | participant2-displayname | Message 1-1 | [] | Message 1 | | group room | users | participant1 | participant1-displayname | Message 1 | [] | | + Scenario: getting parent and quote works + Given user "participant1" creates room "group room" + | roomType | 2 | + | invite | attendees1 | + And user "participant1" sends message "Message 1" to room "group room" with 201 + And user "participant1" sends message "Message 2" to room "group room" with 201 + And user "participant2" sends reply "Message 2-1" on message "Message 2" to room "group room" with 201 + Then user "participant1" sees the following messages in room "group room" starting with "Message 1" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | + | group room | users | participant1 | participant1-displayname | Message 1 | [] | | + | group room | users | participant1 | participant1-displayname | Message 2 | [] | | + | group room | users | participant2 | participant2-displayname | Message 2-1 | [] | Message 2 | + Then user "participant1" sees the following messages in room "group room" starting with "Message 2" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | + | group room | users | participant1 | participant1-displayname | Message 2 | [] | | + | group room | users | participant2 | participant2-displayname | Message 2-1 | [] | Message 2 | + Scenario: user can not reply when not in the room |