diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-05-04 10:35:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 10:35:11 +0200 |
commit | 31082f955381c3ce7b551f69f149be00a3c3748f (patch) | |
tree | 866c59fc89c9f64ca8b5e192ad62216f50e2280a /tests/integration | |
parent | 6a39316274b3dab5cda025f054000da634d79920 (diff) | |
parent | 602ff9625547118a6963b132e08e42c030a8a5bc (diff) |
Merge pull request #9423 from nextcloud/bugfix/9320/expose-if-is-custom-avatar
Expose if the room has a custom avatar
Diffstat (limited to 'tests/integration')
4 files changed, 99 insertions, 14 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 6276e1bba..27537c1c3 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -1197,9 +1197,13 @@ class FeatureContext implements Context, SnippetAcceptingContext { $this->assertStatusCode($this->response, $statusCode); if ($formData instanceof TableNode) { - $xpectedAttributes = $formData->getColumnsHash()[0]; + $xpectedAttributes = $formData->getRowsHash(); $actual = $this->getDataFromResponse($this->response); foreach ($xpectedAttributes as $attribute => $expectedValue) { + if ($expectedValue === 'NOT_EMPTY') { + Assert::assertNotEmpty($actual[$attribute]); + continue; + } Assert::assertEquals($expectedValue, $actual[$attribute]); } } @@ -1942,6 +1946,10 @@ class FeatureContext implements Context, SnippetAcceptingContext { $item['iconUrl'] = str_replace('{$BASE_URL}', $this->baseUrl, $item['iconUrl']); $item['iconUrl'] = str_replace('{token}', $token, $item['iconUrl']); + Assert::assertMatchesRegularExpression('/\?v=\w{8}$/', $data[$widgetId][$key]['iconUrl']); + preg_match('/(?<version>\?v=\w{8})$/', $data[$widgetId][$key]['iconUrl'], $matches); + $item['iconUrl'] = str_replace('{version}', $matches['version'], $item['iconUrl']); + Assert::assertEquals($item, $data[$widgetId][$key], 'Wrong details for item #' . $key); } } @@ -3222,12 +3230,52 @@ class FeatureContext implements Context, SnippetAcceptingContext { /** * @When /^the room "([^"]*)" has an avatar with (\d+)(?: \((v1)\))?$/ */ - public function theRoomNeedToHaveAnAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1'): void { + public function theRoomHasAnAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1'): void { $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/avatar'); $this->assertStatusCode($this->response, $statusCode); } /** + * @When /^the room "([^"]*)" has an svg as avatar with (\d+)(?: \((v1)\))?$/ + */ + public function theRoomHasASvgAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1'): void { + $this->theRoomHasNoSvgAvatarWithStatusCode($identifier, $statusCode, $apiVersion, true); + } + + /** + * @When /^the room "([^"]*)" has not an svg as avatar with (\d+)(?: \((v1)\))?$/ + */ + public function theRoomHasNoSvgAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1', bool $expectedToBeSvg = false): void { + $this->theRoomHasAnAvatarWithStatusCode($identifier, $statusCode, $apiVersion); + $content = $this->response->getBody()->getContents(); + try { + simplexml_load_string($content); + $actualIsSvg = true; + } catch (\Throwable $th) { + $actualIsSvg = false; + } + if ($expectedToBeSvg) { + Assert::assertEquals($expectedToBeSvg, $actualIsSvg, 'The room avatar needs to be a XML file'); + } else { + Assert::assertEquals($expectedToBeSvg, $actualIsSvg, 'The room avatar can not be a XML file'); + } + } + + /** + * @When /^the avatar svg of room "([^"]*)" contains the string "([^"]*)"(?: \((v1)\))?$/ + */ + public function theAvatarSvgOfRoomContainsTheString(string $identifier, string $string, string $apiVersion = 'v1'): void { + $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/avatar'); + $content = $this->response->getBody()->getContents(); + try { + simplexml_load_string($content); + } catch (\Throwable $th) { + throw new Exception('The avatar needs to be a XML'); + } + Assert::stringContains($content, $string); + } + + /** * @When /^user "([^"]*)" delete the avatar of room "([^"]*)" with (\d+)(?: \((v1)\))?$/ */ public function userDeleteTheAvatarOfRoom(string $user, string $identifier, int $statusCode, string $apiVersion = 'v1'): void { @@ -3485,4 +3533,5 @@ class FeatureContext implements Context, SnippetAcceptingContext { Assert::assertEquals($statusCode, $response->getStatusCode(), $message); } } + } diff --git a/tests/integration/features/chat/one-to-one.feature b/tests/integration/features/chat/one-to-one.feature index 2d1782d89..ef3baf12a 100644 --- a/tests/integration/features/chat/one-to-one.feature +++ b/tests/integration/features/chat/one-to-one.feature @@ -74,13 +74,10 @@ Feature: chat/one-to-one | invite | participant2 | When user "participant2" set status to "online" with 200 (v1) Then user "participant1" gets room "one-to-one room" with 200 (v4) - | status | - | online | + | status | online | When user "participant2" set status to "offline" with 200 (v1) Then user "participant1" gets room "one-to-one room" with 200 (v4) - | status | - | offline | + | status | offline | Then user "participant2" set status to "away" with 200 (v1) Then user "participant1" gets room "one-to-one room" with 200 (v4) - | status | - | away | + | status | away | diff --git a/tests/integration/features/conversation/avatar.feature b/tests/integration/features/conversation/avatar.feature index 00965c6e5..81030f279 100644 --- a/tests/integration/features/conversation/avatar.feature +++ b/tests/integration/features/conversation/avatar.feature @@ -16,35 +16,74 @@ Feature: conversation/avatar | roomType | 3 | | roomName | room2 | When user "participant1" uploads file "/img/favicon.png" as avatar of room "room2" with 200 - Then the room "room2" has an avatar with 200 + Then user "participant1" gets room "room2" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 1 | + And the room "room2" has not an svg as avatar with 200 And user "participant1" sees the following system messages in room "room2" with 200 | room | actorType | actorId | systemMessage | message | | room2 | users | participant1 | avatar_set | You set the conversation picture | | room2 | users | participant1 | conversation_created | You created the conversation | - And user "participant1" delete the avatar of room "room2" with 200 - And user "participant1" sees the following system messages in room "room2" with 200 + When user "participant1" delete the avatar of room "room2" with 200 + Then user "participant1" sees the following system messages in room "room2" with 200 | room | actorType | actorId | systemMessage | message | | room2 | users | participant1 | avatar_removed | You removed the conversation picture | | room2 | users | participant1 | avatar_set | You set the conversation picture | | room2 | users | participant1 | conversation_created | You created the conversation | + And user "participant1" gets room "room2" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 0 | + Then the room "room2" has an avatar with 200 Scenario: Get avatar of conversation without custom avatar (fallback) Given user "participant1" creates room "room3" (v4) | roomType | 3 | | roomName | room3 | Then the room "room3" has an avatar with 200 + And user "participant1" gets room "room3" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 0 | Scenario: Get avatar of one2one without custom avatar (fallback) When user "participant1" creates room "one2one" (v4) | roomType | 1 | | invite | participant2 | Then the room "one2one" has an avatar with 200 + And user "participant1" gets room "one2one" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 0 | Scenario: Try to change avatar of one2one without success When user "participant1" creates room "one2one" (v4) | roomType | 1 | | invite | participant2 | Then user "participant1" uploads file "/img/favicon.png" as avatar of room "one2one" with 400 + And user "participant1" gets room "one2one" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 0 | + + Scenario: Conversation that the name start with emoji dont need to have custom avatar + Given user "participant1" creates room "room1" (v4) + | roomType | 3 | + | roomName | room1 | + And the room "room1" has an svg as avatar with 200 + And user "participant1" gets room "room1" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 0 | + | displayName | room1 | + And user "participant1" renames room "room1" to "💙room2" with 200 (v4) + Then user "participant1" gets room "room1" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 0 | + | displayName | 💙room2 | + And the room "room1" has an svg as avatar with 200 + And the avatar svg of room "room1" contains the string "💙" + When user "participant1" renames room "room1" to "room1" with 200 (v4) + Then user "participant1" gets room "room1" with 200 (v4) + | avatarVersion | NOT_EMPTY | + | isCustomAvatar | 0 | + | displayName | room1 | + And the room "room1" has an svg as avatar with 200 Scenario: User should receive the room avatar when see a rich object at media tab Given user "participant1" creates room "public room" (v4) diff --git a/tests/integration/features/integration/dashboard.feature b/tests/integration/features/integration/dashboard.feature index 2120bbbef..8730bedd0 100644 --- a/tests/integration/features/integration/dashboard.feature +++ b/tests/integration/features/integration/dashboard.feature @@ -37,6 +37,6 @@ Feature: integration/dashboard And user "participant2" broadcasts message "@participant1 hello" to room "breakout room parent" with 201 (v1) Then user "participant1" sees the following entries for dashboard widgets "spreed" (v1) | title | subtitle | link | iconUrl | sinceId | - | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar | | - | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar | | - | participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar | | + | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | + | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | + | participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |