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>2020-03-11 18:58:25 +0300
committerJoas Schilling <coding@schilljs.com>2020-04-22 16:35:37 +0300
commit5d4b8c08f4cc41ef9d60b57f1de59ebe54f6aaa4 (patch)
treefb1d48af1c7fcae73ca5d35fefbdd314a4e60b71 /tests
parent165bb50bb13ac0fc3b55b289223a9c56c9ee84ac (diff)
Add integration tests for the reference id
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php32
-rw-r--r--tests/integration/features/chat/reference-id.feature36
2 files changed, 67 insertions, 1 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index af2e5225f..e7fda0f14 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -711,6 +711,32 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
+ * @Then /^user "([^"]*)" sends message "([^"]*)" with reference id "([^"]*)" to room "([^"]*)" with (\d+)$/
+ *
+ * @param string $user
+ * @param string $message
+ * @param string $referenceId
+ * @param string $identifier
+ * @param string $statusCode
+ */
+ public function userSendsMessageWithReferenceIdToRoom($user, $message, $referenceId, $identifier, $statusCode) {
+ $this->setCurrentUser($user);
+ $this->sendRequest(
+ 'POST', '/apps/spreed/api/v1/chat/' . self::$identifierToToken[$identifier],
+ new TableNode([['message', $message], ['referenceId', $referenceId]])
+ );
+ $this->assertStatusCode($this->response, $statusCode);
+ sleep(1); // make sure Postgres manages the order of the messages
+
+ $response = $this->getDataFromResponse($this->response);
+ if (isset($response['id'])) {
+ self::$messages[$message] = $response['id'];
+ }
+
+ Assert::assertStringStartsWith($response['referenceId'], $referenceId);
+ }
+
+ /**
* @Then /^user "([^"]*)" sends reply "([^"]*)" on message "([^"]*)" to room "([^"]*)" with (\d+)$/
*
* @param string $user
@@ -769,6 +795,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
return;
}
$includeParents = in_array('parentMessage', $formData->getRow(0), true);
+ $includeReferenceId = in_array('referenceId', $formData->getRow(0), true);
$count = count($formData->getHash());
Assert::assertCount($count, $messages, 'Message count does not match');
@@ -777,7 +804,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$messages[$i]['messageParameters'] = 'IGNORE';
}
}
- Assert::assertEquals($formData->getHash(), array_map(function($message) use($includeParents) {
+ Assert::assertEquals($formData->getHash(), array_map(function($message) use($includeParents, $includeReferenceId) {
$data = [
'room' => self::$tokenToIdentifier[$message['token']],
'actorType' => $message['actorType'],
@@ -791,6 +818,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
if ($includeParents) {
$data['parentMessage'] = $message['parent']['message'] ?? '';
}
+ if ($includeReferenceId) {
+ $data['referenceId'] = $message['referenceId'];
+ }
return $data;
}, $messages));
}
diff --git a/tests/integration/features/chat/reference-id.feature b/tests/integration/features/chat/reference-id.feature
new file mode 100644
index 000000000..dc57f5dee
--- /dev/null
+++ b/tests/integration/features/chat/reference-id.feature
@@ -0,0 +1,36 @@
+Feature: chat/reference-id
+ Background:
+ Given user "participant1" exists
+
+ Scenario: user can send a message with a reference id and see it afterwards
+ Given user "participant1" creates room "group room"
+ | roomType | 2 |
+ | roomName | room |
+ When user "participant1" sends message "Message 1" with reference id "ref 1" to room "group room" with 201
+ When user "participant1" sends message "Message 2" with reference id "ref 2" 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 | referenceId |
+ | group room | users | participant1 | participant1-displayname | Message 2 | [] | ref 2 |
+ | group room | users | participant1 | participant1-displayname | Message 1 | [] | ref 1 |
+
+ Scenario: user can send a message with the same reference id
+ Given user "participant1" creates room "group room"
+ | roomType | 2 |
+ | roomName | room |
+ When user "participant1" sends message "Message 1" with reference id "ref 1" to room "group room" with 201
+ When user "participant1" sends message "Message 2" with reference id "ref 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 | referenceId |
+ | group room | users | participant1 | participant1-displayname | Message 2 | [] | ref 1 |
+ | group room | users | participant1 | participant1-displayname | Message 1 | [] | ref 1 |
+
+ Scenario: too long references dont break the api
+ Given user "participant1" creates room "group room"
+ | roomType | 2 |
+ | roomName | room |
+ When user "participant1" sends message "Message 1" with reference id "1234567890123456789012345678901234567890" to room "group room" with 201
+ When user "participant1" sends message "Message 2" with reference id "too long ref is cut off 123456789012345678901234567890" 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 | referenceId |
+ | group room | users | participant1 | participant1-displayname | Message 2 | [] | too long ref is cut off 1234567890123456 |
+ | group room | users | participant1 | participant1-displayname | Message 1 | [] | 1234567890123456789012345678901234567890 |