summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-16 13:32:06 +0200
committerJoas Schilling <coding@schilljs.com>2022-08-16 13:33:22 +0200
commitdb3c0d7554c4dde2b0f848a32da3731733792465 (patch)
tree28e0a563e34aa87e364990e9d2e059e57d3ceacf /tests
parentf90ee7c1f136be45191dcb05aafe81242368aa45 (diff)
Order the list of rooms to ensure the order on postgres even if all last messages are written in the same second
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php22
-rw-r--r--tests/integration/features/command/user-remove.feature2
2 files changed, 18 insertions, 6 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 82208d6c0..738a691ee 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -254,13 +254,14 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
- * @Then /^user "([^"]*)" is participant of the following rooms \((v4)\)$/
+ * @Then /^user "([^"]*)" is participant of the following (unordered )?rooms \((v4)\)$/
*
* @param string $user
+ * @param string $shouldOrder
* @param string $apiVersion
* @param TableNode|null $formData
*/
- public function userIsParticipantOfRooms(string $user, string $apiVersion, TableNode $formData = null): void {
+ public function userIsParticipantOfRooms(string $user, string $shouldOrder, string $apiVersion, TableNode $formData = null): void {
$this->setCurrentUser($user);
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room');
$this->assertStatusCode($this->response, 200);
@@ -276,16 +277,27 @@ class FeatureContext implements Context, SnippetAcceptingContext {
return;
}
- $this->assertRooms($rooms, $formData);
+ $this->assertRooms($rooms, $formData, $shouldOrder !== '');
}
/**
* @param array $rooms
* @param TableNode $formData
*/
- private function assertRooms($rooms, TableNode $formData) {
+ private function assertRooms($rooms, TableNode $formData, bool $shouldOrder = false) {
Assert::assertCount(count($formData->getHash()), $rooms, 'Room count does not match');
- Assert::assertEquals($formData->getHash(), array_map(function ($room, $expectedRoom) {
+
+ $expected = $formData->getHash();
+ if ($shouldOrder) {
+ $sorter = static function (array $roomA, array $roomB): int {
+ return $roomA['id'] < $roomB['id'] ? -1 : 1;
+ };
+
+ usort($expected, $sorter);
+ usort($rooms, $sorter);
+ }
+
+ Assert::assertEquals($expected, array_map(function ($room, $expectedRoom) {
if (!isset(self::$identifierToToken[$room['name']])) {
self::$identifierToToken[$room['name']] = $room['token'];
}
diff --git a/tests/integration/features/command/user-remove.feature b/tests/integration/features/command/user-remove.feature
index 9a9826a16..308805a2b 100644
--- a/tests/integration/features/command/user-remove.feature
+++ b/tests/integration/features/command/user-remove.feature
@@ -16,7 +16,7 @@ Feature: User remove
And the command output contains the text "Users successfully removed from all rooms"
Then the command was successful
And user "participant2" is participant of the following rooms (v4)
- And user "participant1" is participant of the following rooms (v4)
+ And user "participant1" is participant of the following unordered rooms (v4)
| id | name | type | participantType |
| room1 | participant2-displayname | 2 | 1 |
| room2 | room | 3 | 1 |