Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-07-07 17:01:25 +0300
committerJoas Schilling <coding@schilljs.com>2021-07-07 17:01:25 +0300
commitbbed7ef20200e626eb070520b61c5fff9c07e7f3 (patch)
tree9eda875742a50a6c7c9588a9831a5292c6337908 /tests
parent81922eef896b9a3b34e7ea68ac99f554760a6d93 (diff)
Add integration test
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php16
-rw-r--r--tests/integration/features/chat/delete.feature32
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index e3acd1ec2..16160049c 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -1278,6 +1278,22 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
+ * @Then /^user "([^"]*)" deletes chat history for room "([^"]*)" with (\d+)(?: \((v1)\))?$/
+ *
+ * @param string $user
+ * @param string $identifier
+ * @param int $statusCode
+ * @param string $apiVersion
+ */
+ public function userDeletesHistoryFromRoom(string $user, string $identifier, int $statusCode, string $apiVersion = 'v1'): void {
+ $this->setCurrentUser($user);
+ $this->sendRequest(
+ 'DELETE', '/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier]
+ );
+ $this->assertStatusCode($this->response, $statusCode);
+ }
+
+ /**
* @Then /^user "([^"]*)" reads message "([^"]*)" in room "([^"]*)" with (\d+)(?: \((v1)\))?$/
*
* @param string $user
diff --git a/tests/integration/features/chat/delete.feature b/tests/integration/features/chat/delete.feature
index 904f7b0ea..5096ce582 100644
--- a/tests/integration/features/chat/delete.feature
+++ b/tests/integration/features/chat/delete.feature
@@ -148,7 +148,7 @@ Feature: chat/reply
Then user "participant2" received a system messages in room "group room" to delete "Message 1"
Scenario: Can only delete own messages in one-to-one
- Given user "participant1" creates room "room1"
+ Given user "participant1" creates room "room1" (v4)
| roomType | 1 |
| invite | participant2 |
And user "participant1" sends message "Message 1" to room "room1" with 201
@@ -177,3 +177,33 @@ Feature: chat/reply
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| room1 | users | participant2 | participant2-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname"}} |
| room1 | users | participant1 | participant1-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |
+
+ Scenario: Clear chat history as a moderator
+ Given user "participant1" creates room "room1" (v4)
+ | roomType | 2 |
+ | roomName | room |
+ And user "participant1" adds user "participant2" to room "room1" with 200 (v4)
+ And user "participant1" sends message "Message 1" to room "room1" with 201
+ And user "participant2" sends message "Message 2" to room "room1" with 201
+ Then user "participant1" sees the following messages in room "room1" with 200
+ | room | actorType | actorId | actorDisplayName | message | messageParameters |
+ | room1 | users | participant2 | participant2-displayname | Message 2 | [] |
+ | room1 | users | participant1 | participant1-displayname | Message 1 | [] |
+ Then user "participant2" sees the following messages in room "room1" with 200
+ | room | actorType | actorId | actorDisplayName | message | messageParameters |
+ | room1 | users | participant2 | participant2-displayname | Message 2 | [] |
+ | room1 | users | participant1 | participant1-displayname | Message 1 | [] |
+ And user "participant2" deletes chat history for room "room1" with 403
+ Then user "participant1" sees the following messages in room "room1" with 200
+ | room | actorType | actorId | actorDisplayName | message | messageParameters |
+ | room1 | users | participant2 | participant2-displayname | Message 2 | [] |
+ | room1 | users | participant1 | participant1-displayname | Message 1 | [] |
+ And user "participant1" deletes chat history for room "room1" with 200
+ Then user "participant1" sees the following messages in room "room1" with 200
+ | room | actorType | actorId | actorDisplayName | message | messageParameters |
+ Then user "participant1" sees the following system messages in room "room1" with 200 (v1)
+ | room | actorType | actorId | actorDisplayName | systemMessage |
+ | room1 | users | participant1 | participant1-displayname | cleared_history |
+ Then user "participant2" sees the following system messages in room "room1" with 200 (v1)
+ | room | actorType | actorId | actorDisplayName | systemMessage |
+ | room1 | users | participant1 | participant1-displayname | cleared_history |