diff options
author | Joas Schilling <coding@schilljs.com> | 2024-02-23 14:20:14 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-02-23 14:33:10 +0100 |
commit | a4b3822236f70a35338a158e0a28558f548f7d2a (patch) | |
tree | 6a0e186f06e536f33ee85162dfd9f205d03699c9 /tests/integration | |
parent | 3249b6593624aceb5d147ef9ef70553f30d565b5 (diff) |
test(federation): Add tests for basic chatting functionality
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 20 | ||||
-rw-r--r-- | tests/integration/features/federation/chat.feature | 60 |
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 7a37fe8d6..a55100b15 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -2652,6 +2652,23 @@ class FeatureContext implements Context, SnippetAcceptingContext { } $expected[$i]['message'] = str_replace('\n', "\n", $expected[$i]['message']); + + if (str_ends_with($expected[$i]['actorId'], '@{$BASE_URL}')) { + $expected[$i]['actorId'] = str_replace('{$BASE_URL}', rtrim($this->baseUrl, '/'), $expected[$i]['actorId']); + } + if (str_ends_with($expected[$i]['actorId'], '@{$REMOTE_URL}')) { + $expected[$i]['actorId'] = str_replace('{$REMOTE_URL}', rtrim($this->baseRemoteUrl, '/'), $expected[$i]['actorId']); + } + + if (isset($expected[$i]['lastEditActorId'])) { + if (str_ends_with($expected[$i]['lastEditActorId'], '@{$BASE_URL}')) { + $expected[$i]['lastEditActorId'] = str_replace('{$BASE_URL}', rtrim($this->baseUrl, '/'), $expected[$i]['lastEditActorId']); + } + if (str_ends_with($expected[$i]['lastEditActorId'], '@{$REMOTE_URL}')) { + $expected[$i]['lastEditActorId'] = str_replace('{$REMOTE_URL}', rtrim($this->baseRemoteUrl, '/'), $expected[$i]['lastEditActorId']); + } + } + if ($expected[$i]['actorType'] === 'bots') { $result = preg_match('/BOT\(([^)]+)\)/', $expected[$i]['actorId'], $matches); if ($result && isset(self::$botNameToHash[$matches[1]])) { @@ -2680,6 +2697,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { 'message' => $message['message'], 'messageParameters' => json_encode($message['messageParameters']), ]; + if ($includeParents) { $data['parentMessage'] = $message['parent']['message'] ?? ''; } @@ -2707,6 +2725,8 @@ class FeatureContext implements Context, SnippetAcceptingContext { $data['lastEditActorId'] = self::$sessionIdToUser[$message['lastEditActorId']]; } } + + return $data; }, $messages, $expected)); } diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 39ae62be9..f0e38a065 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -65,3 +65,63 @@ Feature: federation/chat | calls | all | room | | federated_users | participant1@{$BASE_URL} | participant1-displayname | | users | participant3 | participant3-displayname | + + Scenario: Basic chatting including posting, getting, editing and deleting + Given the following "spreed" app config is set + | federation_enabled | yes | + Given user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds federated_user "participant2" to room "room" with 200 (v4) + And user "participant1" adds federated_user "participant3" to room "room" with 200 (v4) + And user "participant2" has the following invitations (v1) + | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) + | id | name | type | remoteServer | remoteToken | + | room | room | 2 | LOCAL | room | + And user "participant3" has the following invitations (v1) + | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + And user "participant3" accepts invite to room "room" of server "LOCAL" with 200 (v1) + | id | name | type | remoteServer | remoteToken | + | room | room | 2 | LOCAL | room | + Then user "participant2" is participant of the following rooms (v4) + | id | type | + | room | 2 | + And user "participant1" sends message "Message 1" to room "room" with 201 + When user "participant2" sends reply "Message 1-1" on message "Message 1" to room "LOCAL::room" with 201 + Then user "participant1" sees the following messages in room "room" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | + | room | federated_users | participant2@{$REMOTE_URL} | participant2-displayname | Message 1-1 | [] | Message 1 | + | room | users | participant1 | participant1-displayname | Message 1 | [] | | + When next message request has the following parameters set + | timeout | 0 | + And user "participant2" sees the following messages in room "LOCAL::room" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | + | room | users | participant2 | participant2-displayname | Message 1-1 | [] | Message 1 | + | room | federated_users | participant1@{$BASE_URL} | participant1-displayname | Message 1 | [] | | + And user "participant1" edits message "Message 1" in room "room" to "Message 1 - Edit 1" with 200 + And user "participant2" edits message "Message 1-1" in room "LOCAL::room" to "Message 1-1 - Edit 1" with 200 + Then user "participant1" sees the following messages in room "room" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName | + | room | federated_users | participant2@{$REMOTE_URL} | participant2-displayname | Message 1-1 - Edit 1 | [] | Message 1 - Edit 1 | federated_users | participant2@{$REMOTE_URL} | participant2-displayname | + | room | users | participant1 | participant1-displayname | Message 1 - Edit 1 | [] | | users | participant1 | participant1-displayname | + When next message request has the following parameters set + | timeout | 0 | + And user "participant2" sees the following messages in room "LOCAL::room" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | lastEditActorType | lastEditActorId | lastEditActorDisplayName | + | room | users | participant2 | participant2-displayname | Message 1-1 - Edit 1 | [] | Message 1 - Edit 1 | users | participant2 | participant2-displayname | + | room | federated_users | participant1@{$BASE_URL} | participant1-displayname | Message 1 - Edit 1 | [] | | federated_users | participant1@{$BASE_URL} | participant1-displayname | + And user "participant1" deletes message "Message 1 - Edit 1" from room "room" with 200 + And user "participant2" deletes message "Message 1-1 - Edit 1" from room "LOCAL::room" with 200 + Then user "participant1" sees the following messages in room "room" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | + | room | federated_users | participant2@{$REMOTE_URL} | participant2-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} | Message deleted by you | + | room | users | participant1 | participant1-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | | + When next message request has the following parameters set + | timeout | 0 | + And user "participant2" sees the following messages in room "LOCAL::room" with 200 + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | + | room | users | participant2 | participant2-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} | Message deleted by author | + | room | federated_users | participant1@{$BASE_URL} | participant1-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | | |