Skip to content

Commit

Permalink
get notification on different languages
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor committed May 9, 2023
1 parent d127954 commit 562b613
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 105 deletions.
12 changes: 6 additions & 6 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default:
ldapGroupsOU: TestGroups
ldapInitialUserFilePath: /../../config/ldap-users.ldif
contexts:
- RoleAssignmentContext:
- SettingsContext:
- GraphContext:
- SpacesContext:
- FeatureContext: &common_feature_context_params
Expand All @@ -37,7 +37,7 @@ default:
- '%paths.base%/../features/apiSpaces'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
- CapabilitiesContext:
Expand All @@ -60,7 +60,7 @@ default:
- '%paths.base%/../features/apiSpacesShares'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
- CapabilitiesContext:
Expand All @@ -82,7 +82,7 @@ default:
- '%paths.base%/../features/apiContract'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
- CapabilitiesContext:
Expand All @@ -103,7 +103,7 @@ default:
- '%paths.base%/../features/apiArchiver'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- ArchiverContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
Expand All @@ -122,7 +122,7 @@ default:
- '%paths.base%/../features/apiGraph'
context: *common_ldap_suite_context
contexts:
- RoleAssignmentContext:
- SettingsContext:
- GraphContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
Expand Down
245 changes: 148 additions & 97 deletions tests/acceptance/features/apiSpaces/notification.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@api
@api
Feature: Notification
As a user
I want to be notified of actions related to me
Expand All @@ -21,108 +21,159 @@ Feature: Notification
When user "Brian" lists all notifications
Then the HTTP status code should be "200"
And the JSON response should contain a notification message with the subject "Space shared" and the message-details should match
"""
{
"type": "object",
"required": [
"app",
"datetime",
"message",
"messageRich",
"messageRichParameters",
"notification_id",
"object_id",
"object_type",
"subject",
"subjectRich",
"user"
],
"properties": {
"app": {
"type": "string",
"enum": ["userlog"]
},
"message": {
"type": "string",
"enum": ["Alice Hansen added you to Space notification checking"]
},
"messageRich": {
"type": "string",
"enum": ["{user} added you to Space {space}"]
},
"messageRichParameters": {
"type": "object",
"required": [
"space",
"user"
],
"properties": {
"space": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
},
"name": {
"type": "string",
"enum": ["notification checking"]
"""
{
"type": "object",
"required": [
"app",
"datetime",
"message",
"messageRich",
"messageRichParameters",
"notification_id",
"object_id",
"object_type",
"subject",
"subjectRich",
"user"
],
"properties": {
"app": {
"type": "string",
"enum": [
"userlog"
]
},
"message": {
"type": "string",
"enum": [
"Alice Hansen added you to Space notification checking"
]
},
"messageRich": {
"type": "string",
"enum": [
"{user} added you to Space {space}"
]
},
"messageRichParameters": {
"type": "object",
"required": [
"space",
"user"
],
"properties": {
"space": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\$[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}![a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
},
"name": {
"type": "string",
"enum": [
"notification checking"
]
}
}
}
},
"user": {
"type": "object",
"required": [
"displayname",
"id",
"name"
],
"properties": {
"displayname": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"enim": ["%user_id%"]
},
"name": {
"type": "string",
"enum": ["Alice"]
},
"user": {
"type": "object",
"required": [
"displayname",
"id",
"name"
],
"properties": {
"displayname": {
"type": "string",
"enum": [
"Alice Hansen"
]
},
"id": {
"type": "string",
"enim": [
"%user_id%"
]
},
"name": {
"type": "string",
"enum": [
"Alice"
]
}
}
}
}
},
"notification_id": {
"type": "string"
},
"object_id": {
"type": "string"
},
"object_type": {
"type": "string",
"enum": [
"storagespace"
]
},
"subject": {
"type": "string",
"enum": [
"Space shared"
]
},
"subjectRich": {
"type": "string",
"enum": [
"Space shared"
]
},
"user": {
"type": "string",
"enum": [
"Alice"
]
}
},
"notification_id": {
"type": "string"
}
}
"""

},
"object_id": {
"type": "string"

},
"object_type": {
"type": "string",
"enum": ["storagespace"]
},
"subject": {
"type": "string",
"enum": ["Space shared"]
},
"subjectRich": {
"type": "string",
"enum": ["Space shared"]
},
"user": {
"type": "string",
"enum": ["Alice"]
Scenario Outline: user gets a notification of space sharing in different languages
Given user "Alice" has created a space "notification checking" with the default quota using the GraphApi
And user "Brian" has switched the system language to "<language>"
And user "Alice" has shared a space "notification checking" with settings:
| shareWith | Brian |
| role | editor |
When user "Brian" lists all notifications
Then the HTTP status code should be "200"
And the JSON response should contain a notification message with the subject "<subject>" and the message-details should match
"""
{
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string",
"enum": [
"<message>"
]
}
}
}
}
"""

"""
Examples:
| language | subject | message |
| de | Space freigegeben | Alice Hansen hat Sie zum Space notification checking hinzugefügt |
| en | Space shared | Alice Hansen added you to Space notification checking |
| es | Space compartido | Alice Hansen te añadió al Space notification checking |
8 changes: 7 additions & 1 deletion tests/acceptance/features/bootstrap/NotificationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
class NotificationContext implements Context {
private FeatureContext $featureContext;
private SettingsContext $settingsContext;
private string $notificationEndpointPath = '/apps/notifications/api/v1/notifications?format=json';
private array $notificationIds;

Expand Down Expand Up @@ -70,6 +71,7 @@ public function setUpScenario(BeforeScenarioScope $scope):void {
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
$this->featureContext = $environment->getContext('FeatureContext');
$this->settingsContext = $environment->getContext('SettingsContext');
}

/**
Expand All @@ -81,13 +83,17 @@ public function setUpScenario(BeforeScenarioScope $scope):void {
*/
public function userListAllNotifications(string $user):void {
$this->setUserRecipient($user);
$headers = ["accept-language" => $this->settingsContext->getSettingLanguageValue($user)];
$response = OcsApiHelper::sendRequest(
$this->featureContext->getBaseUrl(),
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
'GET',
$this->notificationEndpointPath,
$this->featureContext->getStepLineRef()
$this->featureContext->getStepLineRef(),
[],
2,
$headers
);
$this->featureContext->setResponse($response);
}
Expand Down
Loading

0 comments on commit 562b613

Please sign in to comment.