Browse Source

Correctly pick the parent if it is index 0 of the messages

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/3580/head
Joas Schilling 6 years ago
parent
commit
f8538f487b
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 2
      lib/Controller/ChatController.php
  2. 24
      tests/integration/features/bootstrap/FeatureContext.php
  3. 17
      tests/integration/features/chat/reply.feature

2
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];

24
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) {

17
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

Loading…
Cancel
Save