Skip to content

Commit

Permalink
fix(federation): Add integration tests for reactions
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Mar 12, 2024
1 parent 835c144 commit 0bb0582
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3734,10 +3734,14 @@ private function assertReactionList(?TableNode $formData): void {
$expected[$reaction][] = $row;
}

$actual = array_map(static function ($reaction, $list) use ($expected): array {
$actual = array_map(function ($reaction, $list) use ($expected): array {
$list = array_map(function ($reaction) {
unset($reaction['timestamp']);
$reaction['actorId'] = ($reaction['actorType'] === 'guests') ? self::$sessionIdToUser[$reaction['actorId']] : (string) $reaction['actorId'];
if ($reaction['actorType'] === 'federated_users') {
$reaction['actorId'] = str_replace(rtrim($this->baseUrl, '/'), '{$BASE_URL}', $reaction['actorId']);
$reaction['actorId'] = str_replace(rtrim($this->baseRemoteUrl, '/'), '{$REMOTE_URL}', $reaction['actorId']);
}
return $reaction;
}, $list);
Assert::assertArrayHasKey($reaction, $expected, 'Not expected reaction: ' . $reaction);
Expand Down
32 changes: 32 additions & 0 deletions tests/integration/features/federation/chat.feature
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,35 @@ Feature: federation/chat
| spreed | chat | room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | Hi room bye |
| spreed | chat | room/Hi @"federated_user/participant2@{$REMOTE_URL}" bye | participant1-displayname mentioned you in conversation room | Hi @participant2-displayname bye |
| spreed | chat | room/Message 1-1 | participant1-displayname replied to your message in conversation room | Message 1-1 |

Scenario: Reaction on federated chat messages
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 "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 |
Then user "participant2" is participant of the following rooms (v4)
| id | type |
| room | 2 |
# Join and leave to clear the invite notification
Given user "participant2" joins room "LOCAL::room" with 200 (v4)
Given user "participant2" leaves room "LOCAL::room" with 200 (v4)
And user "participant2" sends message "Message 1" to room "LOCAL::room" with 201
And user "participant1" react with "πŸš€" on message "Message 1" to room "room" with 201
| actorType | actorId | actorDisplayName | reaction |
| users | participant1 | participant1-displayname | πŸš€ |
And user "participant2" react with "πŸš€" on message "Message 1" to room "LOCAL::room" with 201
| actorType | actorId | actorDisplayName | reaction |
| federated_users | participant1@{$BASE_URL} | participant1-displayname | πŸš€ |
| users | participant2 | participant2-displayname | πŸš€ |
And user "participant1" retrieve reactions "all" of message "Message 1" in room "room" with 200
| actorType | actorId | actorDisplayName | reaction |
| users | participant1 | participant1-displayname | πŸš€ |
| federated_users | participant2@{$REMOTE_URL} | participant2-displayname | πŸš€ |

0 comments on commit 0bb0582

Please sign in to comment.