Add integration tests for deleted messages

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-01-19 16:37:27 +01:00
Родитель 47c76fa9eb
Коммит 79ff094265
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
2 изменённых файлов: 194 добавлений и 4 удалений

Просмотреть файл

@ -976,7 +976,6 @@ class FeatureContext implements Context, SnippetAcceptingContext {
* @param string $apiVersion
*/
public function userAddAttendeeToRoom($user, $newType, $newId, $identifier, $statusCode, $apiVersion = 'v1') {
var_dump($newType);
$this->setCurrentUser($user);
$this->sendRequest(
'POST', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/participants',
@ -1103,6 +1102,24 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
}
/**
* @Then /^user "([^"]*)" deletes message "([^"]*)" from room "([^"]*)" with (\d+)(?: \((v(1|2|3))\))?$/
*
* @param string $user
* @param string $message
* @param string $identifier
* @param string $statusCode
* @param string $apiVersion
*/
public function userDeletesMessageFromRoom($user, $message, $identifier, $statusCode, $apiVersion = 'v1') {
$this->setCurrentUser($user);
$this->sendRequest(
'DELETE', '/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier] . '/' . self::$messages[$message],
new TableNode([['message', $message]])
);
$this->assertStatusCode($this->response, $statusCode);
}
/**
* @Then /^user "([^"]*)" reads message "([^"]*)" in room "([^"]*)" with (\d+)(?: \((v(1|2|3))\))?$/
*
@ -1191,19 +1208,44 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->compareDataResponse($formData);
}
/**
* @Then /^user "([^"]*)" received a system messages in room "([^"]*)" to delete "([^"]*)"(?: \((v(1|2|3))\))?$/
*
* @param string $user
* @param string $identifier
* @param string $message
* @param string $apiVersion
*/
public function userReceivedDeleteMessage($user, $identifier, $message, $apiVersion = 'v1') {
$this->setCurrentUser($user);
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier] . '?lookIntoFuture=0');
$this->assertStatusCode($this->response, 200);
$actual = $this->getDataFromResponse($this->response);
foreach ($actual as $m) {
if ($m['systemMessage'] === 'message_deleted') {
if (isset($m['parent']['id']) && $m['parent']['id'] === self::$messages[$message]) {
return;
}
}
}
Assert::fail('Missing message_deleted system message for "' . $message . '"');
}
/**
* @Then /^user "([^"]*)" sees the following messages in room "([^"]*)" starting with "([^"]*)" with (\d+)(?: \((v(1|2|3))\))?$/
*
* @param string $user
* @param string $identifier
* @param string $knwonMessage
* @param string $knownMessage
* @param string $statusCode
* @param string $apiVersion
* @param TableNode|null $formData
*/
public function userAwaitsTheFollowingMessagesInRoom($user, $identifier, $knwonMessage, $statusCode, $apiVersion = 'v1', TableNode $formData = null) {
public function userAwaitsTheFollowingMessagesInRoom($user, $identifier, $knownMessage, $statusCode, $apiVersion = 'v1', TableNode $formData = null) {
$this->setCurrentUser($user);
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier] . '?lookIntoFuture=1&includeLastKnown=1&lastKnownMessageId=' . self::$messages[$knwonMessage]);
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier] . '?lookIntoFuture=1&includeLastKnown=1&lastKnownMessageId=' . self::$messages[$knownMessage]);
$this->assertStatusCode($this->response, $statusCode);
$this->compareDataResponse($formData);

Просмотреть файл

@ -0,0 +1,148 @@
Feature: chat/reply
Background:
Given user "participant1" exists
Given user "participant2" exists
Scenario: moderator deletes their own message
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200
And user "participant1" sends message "Message 1" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1 | [] | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1 | [] | |
And user "participant1" deletes message "Message 1" from room "group room" with 200
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant1" received a system messages in room "group room" to delete "Message 1"
Then user "participant2" received a system messages in room "group room" to delete "Message 1"
Scenario: user deletes their own message
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200
And user "participant2" sends message "Message 1" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
And user "participant2" deletes message "Message 1" from room "group room" with 200
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant2 | participant2-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname"}} | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant2 | participant2-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname"}} | |
Then user "participant1" received a system messages in room "group room" to delete "Message 1"
Then user "participant2" received a system messages in room "group room" to delete "Message 1"
Scenario: moderator deletes other user message
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200
And user "participant2" sends message "Message 1" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
And user "participant1" deletes message "Message 1" from room "group room" with 200
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant2 | participant2-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant2 | participant2-displayname | Message deleted by {actor} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant1" received a system messages in room "group room" to delete "Message 1"
Then user "participant2" received a system messages in room "group room" to delete "Message 1"
Scenario: moderator deletes their own message which got replies
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200
And user "participant2" sends message "Message 1" to room "group room" with 201
When user "participant1" sends reply "Message 1-1" on message "Message 1" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message 1 |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message 1 |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
And user "participant1" deletes message "Message 1" from room "group room" with 200
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message deleted by you |
| group room | users | participant2 | participant2-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message deleted by {actor} |
| group room | users | participant2 | participant2-displayname | Message deleted by {actor} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant1" received a system messages in room "group room" to delete "Message 1"
Then user "participant2" received a system messages in room "group room" to delete "Message 1"
Scenario: user deletes their own message which got replies
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200
And user "participant2" sends message "Message 1" to room "group room" with 201
When user "participant1" sends reply "Message 1-1" on message "Message 1" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message 1 |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message 1 |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
And user "participant2" deletes message "Message 1" from room "group room" with 200
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message deleted by author |
| group room | users | participant2 | participant2-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname"}} | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message deleted by you |
| group room | users | participant2 | participant2-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname"}} | |
Then user "participant1" received a system messages in room "group room" to delete "Message 1"
Then user "participant2" received a system messages in room "group room" to delete "Message 1"
Scenario: moderator deletes other user message
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200
And user "participant2" sends message "Message 1" to room "group room" with 201
When user "participant1" sends reply "Message 1-1" on message "Message 1" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message 1 |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message 1 |
| group room | users | participant2 | participant2-displayname | Message 1 | [] | |
And user "participant1" deletes message "Message 1" from room "group room" with 200
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message deleted by you |
| group room | users | participant2 | participant2-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
| group room | users | participant1 | participant1-displayname | Message 1-1 | [] | Message deleted by {actor} |
| group room | users | participant2 | participant2-displayname | Message deleted by {actor} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | |
Then user "participant1" received a system messages in room "group room" to delete "Message 1"
Then user "participant2" received a system messages in room "group room" to delete "Message 1"