Skip to content

Commit

Permalink
fix(settings): Add tests for setting integers
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Nov 6, 2024
1 parent 4e0bc40 commit 0a67ab1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
16 changes: 14 additions & 2 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3643,7 +3643,7 @@ public function userRequestsOrCancelsAssistanceInBreakoutRooms(string $user, str
}

/**
* @Then /^user "([^"]*)" sets setting "([^"]*)" to "([^"]*)" with (\d+)(?: \((v1)\))?$/
* @Then /^user "([^"]*)" sets setting "([^"]*)" to ("[^"]*"|\d) with (\d+)(?: \((v1)\))?$/
*
* @param string $user
* @param string $setting
Expand All @@ -3652,6 +3652,12 @@ public function userRequestsOrCancelsAssistanceInBreakoutRooms(string $user, str
* @param string $apiVersion
*/
public function userSetting($user, $setting, $value, $statusCode, $apiVersion = 'v1') {
if (str_starts_with($value, '"') && str_ends_with($value, '"')) {
$value = substr($value, 1, -1);
} else {
$value = (int)$value;
}

$this->setCurrentUser($user);
$this->sendRequest(
'POST', '/apps/spreed/api/' . $apiVersion . '/settings/user',
Expand All @@ -3661,13 +3667,19 @@ public function userSetting($user, $setting, $value, $statusCode, $apiVersion =
}

/**
* @Then /^user "([^"]*)" has capability "([^"]*)" set to "([^"]*)"$/
* @Then /^user "([^"]*)" has capability "([^"]*)" set to ("[^"]*"|\d)$/
*
* @param string $user
* @param string $capability
* @param string $value
*/
public function userCheckCapability($user, $capability, $value) {
if (str_starts_with($value, '"') && str_ends_with($value, '"')) {
$value = substr($value, 1, -1);
} else {
$value = (int)$value;
}

$this->setCurrentUser($user);
$this->sendRequest(
'GET', '/cloud/capabilities'
Expand Down
60 changes: 36 additions & 24 deletions tests/integration/features/chat-3/read-status.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,33 @@ Feature: chat-2/read-status
| roomType | 3 |
| roomName | room |

# Private
# Check type safety
When user "participant1" sets setting "read_status_privacy" to "1" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "1"
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 1
When user "participant1" sets setting "read_status_privacy" to "0abcdef" with 400 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 1
When user "participant1" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 0
When user "participant1" sets setting "read_status_privacy" to 1 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 1
When user "participant1" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 0

# Private
When user "participant1" sets setting "read_status_privacy" to 1 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 1
When user "participant1" sends message "Message 1" to room "chatting" with 201
Then last response has no last common read message header

# Public
When user "participant1" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant1" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 0
When user "participant1" reads message "Message 1" in room "chatting" with 200
Then last response has last common read message header set to "Message 1"

# Private again
When user "participant1" sets setting "read_status_privacy" to "1" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "1"
When user "participant1" sets setting "read_status_privacy" to 1 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 1
When user "participant1" reads message "Message 1" in room "chatting" with 200
Then last response has no last common read message header

Expand All @@ -34,18 +46,18 @@ Feature: chat-2/read-status
| roomName | room |
And user "participant1" adds user "participant2" to room "chatting" with 200 (v4)

When user "participant1" sets setting "read_status_privacy" to "1" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "1"
When user "participant2" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant2" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant1" sets setting "read_status_privacy" to 1 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 1
When user "participant2" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant2" has capability "spreed=>config=>chat=>read-privacy" set to 0

When user "participant1" sends message "Message 1" to room "chatting" with 201
Then last response has no last common read message header
When user "participant2" sends message "Message 2" to room "chatting" with 201
Then last response has last common read message header set to "Message 2"

When user "participant1" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant1" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 0

When user "participant2" sends message "Message 3" to room "chatting" with 201
Then last response has last common read message header set to "Message 1"
Expand Down Expand Up @@ -85,10 +97,10 @@ Feature: chat-2/read-status
| roomName | room |
And user "participant1" adds user "participant2" to room "chatting" with 200 (v4)

When user "participant1" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant2" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant2" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant1" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 0
When user "participant2" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant2" has capability "spreed=>config=>chat=>read-privacy" set to 0

When user "participant1" sends message "Message 1" to room "chatting" with 201
Then last response has last common read message header less than "Message 1"
Expand All @@ -100,8 +112,8 @@ Feature: chat-2/read-status
When user "participant2" reads message "Message 2" in room "chatting" with 200
Then last response has last common read message header set to "Message 1"

When user "participant1" sets setting "read_status_privacy" to "1" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "1"
When user "participant1" sets setting "read_status_privacy" to 1 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 1

When user "participant2" reads message "Message 2" in room "chatting" with 200
Then last response has last common read message header set to "Message 2"
Expand All @@ -113,12 +125,12 @@ Feature: chat-2/read-status
| roomName | room |
And user "participant1" adds user "participant2" to room "chatting" with 200 (v4)

When user "participant1" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant2" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant2" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant3" sets setting "read_status_privacy" to "0" with 200 (v1)
Then user "participant3" has capability "spreed=>config=>chat=>read-privacy" set to "0"
When user "participant1" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>read-privacy" set to 0
When user "participant2" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant2" has capability "spreed=>config=>chat=>read-privacy" set to 0
When user "participant3" sets setting "read_status_privacy" to 0 with 200 (v1)
Then user "participant3" has capability "spreed=>config=>chat=>read-privacy" set to 0

When user "participant1" sends message "Message 1" to room "chatting" with 201
Then last response has last common read message header less than "Message 1"
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/features/chat-4/typing-privacy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Feature: chat-2/typing-privacy
Given user "participant1" exists
Scenario: User toggles the typing privacy
# Private
When user "participant1" sets setting "typing_privacy" to "1" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>typing-privacy" set to "1"
When user "participant1" sets setting "typing_privacy" to 1 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>typing-privacy" set to 1

# Public
When user "participant1" sets setting "typing_privacy" to "0" with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>typing-privacy" set to "0"
When user "participant1" sets setting "typing_privacy" to 0 with 200 (v1)
Then user "participant1" has capability "spreed=>config=>chat=>typing-privacy" set to 0

0 comments on commit 0a67ab1

Please sign in to comment.