Skip to content

Commit

Permalink
add test to check api activities with sort filter
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Oct 7, 2024
1 parent ddfed73 commit 960d77a
Show file tree
Hide file tree
Showing 3 changed files with 298 additions and 3 deletions.
9 changes: 7 additions & 2 deletions tests/acceptance/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,8 @@ public static function getPermissionRoleDefinition(
* @param string $user
* @param string $password
* @param string $resourceId
* @param array $filterParams
* @param array|null $filterParams
* @param string|null $sortValue
*
* @return ResponseInterface
*/
Expand All @@ -2354,7 +2355,8 @@ public static function getActivities(
string $user,
string $password,
string $resourceId,
?array $filterParams = []
?array $filterParams = [],
?string $sortValue = null
): ResponseInterface {
// 'kql=itemId' filter is required for the current implementation but it might change in future
// See: https://github.com/owncloud/ocis/issues/9194
Expand All @@ -2364,6 +2366,9 @@ public static function getActivities(
$fullUrl .= "+AND+$filter%3A$value";
}
}
if (!empty($sortValue)) {
$fullUrl .= "+AND+sort%3A$sortValue";
}
return HttpRequestHelper::get(
$fullUrl,
$requestId,
Expand Down
25 changes: 24 additions & 1 deletion tests/acceptance/bootstrap/GraphContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,30 @@ public function userListsTheActivitiesForFolderOfSpaceWithDepthOrLimitUsingTheGr
$user,
$this->featureContext->getPasswordForUser($user),
$resourceId,
[$filterType => $filterValue]
[$filterType => $filterValue],
);
$this->featureContext->setResponse($response);
}

/**
* @When /^user "([^"]*)" lists the activities of (?:folder|file) "([^"]*)" from space "([^"]*)" with sort "([^"]*)" using the Graph API/
*
* @param string $user
* @param string $resource
* @param string $spaceName
* @param string $sortValue
*
* @return void
*/
public function userListsTheActivitiesForFolderOfSpaceWithSortUsingTheGraphApi(string $user, string $resource, string $spaceName, string $sortValue): void {
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource),
[],
$sortValue
);
$this->featureContext->setResponse($response);
}
Expand Down
267 changes: 267 additions & 0 deletions tests/acceptance/features/apiActivities/activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,273 @@ Feature: check activities
}
"""


Scenario: check activity with sort filter
Given user "Alice" has created folder "/New Folder"
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/New Folder/textfile.txt"
When user "Alice" lists the activities of folder "New Folder" from space "Personal" with sort "asc" using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["value"],
"properties": {
"value": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": ["id", "template", "times"],
"properties": {
"template": {
"type": "object",
"required": ["message", "variables"],
"properties": {
"message": {
"const": "{user} added {resource} to {folder}"
},
"variables": {
"type": "object",
"required": ["folder", "resource", "user"],
"properties": {
"folder": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"const": "Alice Hansen"
}
}
},
"resource": {
"type": "object",
"required": ["id", "name"],
"properties": {
"name": {
"const": "New Folder"
}
}
},
"user": {
"type": "object",
"required": ["id","displayName"],
"properties": {
"id": {
"type": "string",
"pattern": "%user_id_pattern%"
},
"displayName": {
"const": "Alice Hansen"
}
}
}
}
}
}
},
"times": {
"type": "object",
"required": ["recordedTime"]
}
}
},
{
"type": "object",
"required": ["id", "template", "times"],
"properties": {
"template": {
"type": "object",
"required": ["message", "variables"],
"properties": {
"message": {
"const": "{user} added {resource} to {folder}"
},
"variables": {
"type": "object",
"required": ["folder", "resource", "user"],
"properties": {
"folder": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"const": "New Folder"
}
}
},
"resource": {
"type": "object",
"required": ["id", "name"],
"properties": {
"name": {
"const": "textfile.txt"
}
}
},
"user": {
"type": "object",
"required": ["id","displayName"],
"properties": {
"id": {
"type": "string",
"pattern": "%user_id_pattern%"
},
"displayName": {
"const": "Alice Hansen"
}
}
}
}
}
}
},
"times": {
"type": "object",
"required": ["recordedTime"]
}
}
}
]
}
}
}
}
"""
When user "Alice" lists the activities of folder "New Folder" from space "Personal" with sort "desc" using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["value"],
"properties": {
"value": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": ["id", "template", "times"],
"properties": {
"template": {
"type": "object",
"required": ["message", "variables"],
"properties": {
"message": {
"const": "{user} added {resource} to {folder}"
},
"variables": {
"type": "object",
"required": ["folder", "resource", "user"],
"properties": {
"folder": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"const": "New Folder"
}
}
},
"resource": {
"type": "object",
"required": ["id", "name"],
"properties": {
"name": {
"const": "textfile.txt"
}
}
},
"user": {
"type": "object",
"required": ["id","displayName"],
"properties": {
"id": {
"type": "string",
"pattern": "%user_id_pattern%"
},
"displayName": {
"const": "Alice Hansen"
}
}
}
}
}
}
}
}
},
{
"type": "object",
"required": ["id", "template", "times"],
"properties": {
"template": {
"type": "object",
"required": ["message", "variables"],
"properties": {
"message": {
"const": "{user} added {resource} to {folder}"
},
"variables": {
"type": "object",
"required": ["folder", "resource", "user"],
"properties": {
"folder": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"const": "Alice Hansen"
}
}
},
"resource": {
"type": "object",
"required": ["id", "name"],
"properties": {
"name": {
"const": "New Folder"
}
}
},
"user": {
"type": "object",
"required": ["id","displayName"],
"properties": {
"id": {
"type": "string",
"pattern": "%user_id_pattern%"
},
"displayName": {
"const": "Alice Hansen"
}
}
}
}
}
}
},
"times": {
"type": "object",
"required": ["recordedTime"]
}
}
}
]
}
}
}
}
"""

@issue-9860
Scenario: user tries to check activities of another user's file
Given user "Brian" has been created with default attributes and without skeleton files
Expand Down

0 comments on commit 960d77a

Please sign in to comment.