summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-05-04 19:14:15 +0200
committerGitHub <noreply@github.com>2023-05-04 19:14:15 +0200
commit1df06dc6d22a683e0ac77c3ee67196468d35ea9d (patch)
tree3723f5c98f3eb0df9b675a4621b17d6bf806456a /tests
parent69459fb90e24dfc84379885157e5e4b3e8dbc0f6 (diff)
parentdaf65ac410643db3ff2ecacacf31c8d288a6b3c2 (diff)
Merge pull request #9443 from nextcloud/feat/ivan/emoji-with-color
feat(avatar): Allow to select an emoji + color as avatar
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php47
-rw-r--r--tests/integration/features/conversation/avatar.feature29
2 files changed, 65 insertions, 11 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 43ed29135..97c842e9f 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -3221,25 +3221,43 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
+ * @When /^user "([^"]*)" sets emoji "([^"]*)" with color "([^"]*)" as avatar of room "([^"]*)" with (\d+)(?: \((v1)\))?$/
+ */
+ public function userSetsEmojiAsAvatarOfRoom(string $user, string $emoji, string $color, string $identifier, int $statusCode, string $apiVersion = 'v1'): void {
+ $this->setCurrentUser($user);
+ $options = [
+ 'emoji' => $emoji,
+ 'color' => $color,
+ ];
+
+ if ($color === 'null') {
+ unset($options['color']);
+ }
+ $this->sendRequest('POST', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/avatar/emoji', $options);
+ $this->assertStatusCode($this->response, $statusCode);
+ }
+
+ /**
* @When /^the room "([^"]*)" has an avatar with (\d+)(?: \((v1)\))?$/
*/
- public function theRoomHasAnAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1'): void {
- $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/avatar');
+ public function theRoomHasAnAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1', bool $darkTheme = false): void {
+ $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/avatar' . ($darkTheme ? '/dark' : ''));
$this->assertStatusCode($this->response, $statusCode);
}
/**
- * @When /^the room "([^"]*)" has an svg as avatar with (\d+)(?: \((v1)\))?$/
+ * @When /^the room "([^"]*)" has an svg as (dark avatar|avatar) with (\d+)(?: \((v1)\))?$/
*/
- public function theRoomHasASvgAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1'): void {
- $this->theRoomHasNoSvgAvatarWithStatusCode($identifier, $statusCode, $apiVersion, true);
+ public function theRoomHasASvgAvatarWithStatusCode(string $identifier, string $darkOrBright, int $statusCode, string $apiVersion = 'v1'): void {
+ $darkTheme = $darkOrBright === 'dark avatar';
+ $this->theRoomHasNoSvgAvatarWithStatusCode($identifier, $statusCode, $apiVersion, true, $darkTheme);
}
/**
* @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);
+ public function theRoomHasNoSvgAvatarWithStatusCode(string $identifier, int $statusCode, string $apiVersion = 'v1', bool $expectedToBeSvg = false, bool $darkTheme = false): void {
+ $this->theRoomHasAnAvatarWithStatusCode($identifier, $statusCode, $apiVersion, $darkTheme);
$content = $this->response->getBody()->getContents();
try {
simplexml_load_string($content);
@@ -3255,17 +3273,24 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
- * @When /^the avatar svg of room "([^"]*)" contains the string "([^"]*)"(?: \((v1)\))?$/
+ * @When /^the (dark avatar|avatar) svg of room "([^"]*)" (not contains|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');
+ public function theAvatarSvgOfRoomContainsTheString(string $darkOrBright, string $identifier, string $contains, string $string, string $apiVersion = 'v1'): void {
+ $darkTheme = $darkOrBright === 'dark avatar';
+ $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/avatar' . ($darkTheme ? '/dark' : ''));
$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);
+
+ if ($contains === 'contains') {
+ Assert::assertStringContainsString($string, $content);
+ } else {
+ Assert::assertStringNotContainsString($string, $content);
+ }
}
/**
diff --git a/tests/integration/features/conversation/avatar.feature b/tests/integration/features/conversation/avatar.feature
index 81030f279..97904d44b 100644
--- a/tests/integration/features/conversation/avatar.feature
+++ b/tests/integration/features/conversation/avatar.feature
@@ -61,6 +61,10 @@ Feature: conversation/avatar
And user "participant1" gets room "one2one" with 200 (v4)
| avatarVersion | NOT_EMPTY |
| isCustomAvatar | 0 |
+ Then user "participant1" sets emoji "👋" with color "123456" as avatar of room "one2one" with 400 (v1)
+ 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)
@@ -94,3 +98,28 @@ Feature: conversation/avatar
Then user "participant1" sees the following shared other in room "public room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| public room | users | participant1 | participant1-displayname | {object} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"object":{"name":"Another room","call-type":"group","type":"call","id":"R4nd0mT0k3n","icon-url":"{VALIDATE_ICON_URL_PATTERN}"}} |
+
+ Scenario: User sets emoji as avatar
+ Given user "participant1" creates room "room" (v4)
+ | roomType | 3 |
+ | roomName | public room |
+ Then user "participant1" sets emoji "👋🚀" with color "123456" as avatar of room "room" with 400 (v1)
+ And user "participant1" sets emoji "👋" with color "1234567" as avatar of room "room" with 400 (v1)
+ And user "participant1" sets emoji "👋" with color "GGGGGG" as avatar of room "room" with 400 (v1)
+ And user "participant1" gets room "room" with 200 (v4)
+ | avatarVersion | NOT_EMPTY |
+ | isCustomAvatar | 0 |
+ Then user "participant1" sets emoji "👩🏽‍🚀" with color "123456" as avatar of room "room" with 200 (v1)
+ And user "participant1" gets room "room" with 200 (v4)
+ | avatarVersion | NOT_EMPTY |
+ | isCustomAvatar | 1 |
+ And the room "room" has an svg as avatar with 200
+ And the avatar svg of room "room" contains the string "👩🏽‍🚀"
+ And the avatar svg of room "room" contains the string "123456"
+ Then user "participant1" sets emoji "🍏" with color "null" as avatar of room "room" with 200 (v1)
+ And the avatar svg of room "room" contains the string "🍏"
+ And the avatar svg of room "room" contains the string "DBDBDB"
+ And the avatar svg of room "room" not contains the string "3B3B3B"
+ And the dark avatar svg of room "room" contains the string "🍏"
+ And the dark avatar svg of room "room" not contains the string "DBDBDB"
+ And the dark avatar svg of room "room" contains the string "3B3B3B"