Skip to content

Commit

Permalink
add test for activity limit filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Salipa-Gurung committed Aug 26, 2024
1 parent a9895a9 commit 2214377
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 199 deletions.
13 changes: 7 additions & 6 deletions tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ public static function getPermissionRoleDefinition(
* @param string $user
* @param string $password
* @param string $resourceId
* @param string $depth
* @param array|null $filterParams
*
* @return ResponseInterface
*/
Expand All @@ -2336,14 +2336,15 @@ public static function getActivities(
string $user,
string $password,
string $resourceId,
?string $depth = null
?array $filterParams = []
): ResponseInterface {
// 'kql=itemId' filter is required for the current implementation but it might change in future
// See: https://github.com/owncloud/ocis/issues/9194
if ($depth !== null) {
$fullUrl = self::getBetaFullUrl($baseUrl, "extensions/org.libregraph/activities?kql=itemid%3A$resourceId+AND+depth%3A$depth");
} else {
$fullUrl = self::getBetaFullUrl($baseUrl, "extensions/org.libregraph/activities?kql=itemid%3A$resourceId");
$fullUrl = self::getBetaFullUrl($baseUrl, "extensions/org.libregraph/activities?kql=itemid%3A$resourceId");
if (!empty($filterParams)) {
foreach ($filterParams as $filter => $value) {
$fullUrl .= "+AND+$filter%3A$value";
}
}
return HttpRequestHelper::get(
$fullUrl,
Expand Down
95 changes: 95 additions & 0 deletions tests/acceptance/features/apiActivities/activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1421,3 +1421,98 @@ Feature: check activities
}
}
"""

@issue-9712
Scenario: check activity with limit filter
Given user "Alice" has created folder "/New Folder"
And user "Alice" has created folder "/New Folder/Sub Folder"
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/New Folder/Sub Folder/textfile0.txt"
When user "Alice" lists the activities for folder "New Folder" of space "Personal" with limit "2" 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 {space}"
},
"variables": {
"type": "object",
"required": ["resource", "space", "user"],
"properties": {
"resource": {
"type": "object",
"required": ["id", "name"],
"properties": {
"name": {
"const": "New Folder"
}
}
}
}
}
}
},
"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 {space}"
},
"variables": {
"type": "object",
"required": ["resource", "space", "user"],
"properties": {
"resource": {
"type": "object",
"required": ["id", "name"],
"properties": {
"name": {
"const": "Sub Folder"
}
}
}
}
}
}
},
"times": {
"type": "object",
"required": ["recordedTime"]
}
}
}
]
}
}
}
}
"""
187 changes: 0 additions & 187 deletions tests/acceptance/features/apiActivities/activityFilter.feature

This file was deleted.

13 changes: 7 additions & 6 deletions tests/acceptance/features/bootstrap/GraphContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2840,24 +2840,25 @@ public function userListsTheActivitiesOfSpaceUsingTheGraphApi(string $user, stri
}

/**
* @When /^user "([^"]*)" lists the activities for (?:folder|file) "([^"]*)" of space "([^"]*)" with depth "([^"]*)" using the Graph API/
* @When /^user "([^"]*)" lists the activities for (?:folder|file) "([^"]*)" of space "([^"]*)" with (depth|limit) "([^"]*)" using the Graph API/
*
* @param string $user
* @param string $resource
* @param string $spaceName
* @param string $folderDepth
* @param string $filterType
* @param string $filter
*
* @return void
*/
public function userListsTheActivitiesForFolderOfSpaceWithDepthUsingTheGraphApi(string $user, string $resource, string $spaceName, string $folderDepth): void {
public function userListsTheActivitiesForFolderOfSpaceWithDepthUsingTheGraphApi(string $user, string $resource, string $spaceName, string $filterType, string $filter): void {
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$resourceId,
$folderDepth
[$filterType => $filter]
);
$this->featureContext->setResponse($response);
}
Expand All @@ -2872,7 +2873,7 @@ public function userListsTheActivitiesForFolderOfSpaceWithDepthUsingTheGraphApi(
*/
public function theUserGetsFederatedUsersUsingTheGraphApi(?string $user = null): void {
$credentials = $this->getAdminOrUserCredentials($user);

$response = GraphHelper::getFederatedUsers(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
Expand All @@ -2893,7 +2894,7 @@ public function theUserGetsFederatedUsersUsingTheGraphApi(?string $user = null):
*/
public function theUserGetsAllUsersUsingTheGraphApi(?string $user = null): void {
$credentials = $this->getAdminOrUserCredentials($user);

$response = GraphHelper::getAllUsers(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
Expand Down

0 comments on commit 2214377

Please sign in to comment.