diff --git a/tests/acceptance/features/apiSpaces/search.feature b/tests/acceptance/features/apiSpaces/search.feature index 47cbe77ffd4..8cd221807e9 100644 --- a/tests/acceptance/features/apiSpaces/search.feature +++ b/tests/acceptance/features/apiSpaces/search.feature @@ -1,6 +1,6 @@ -@api +@api Feature: Search - As a user + As a user I want to search for resources in the space So that I can get them quickly @@ -109,3 +109,15 @@ Feature: Search Then the HTTP status code should be "207" And the search result should contain "1" entries And for user "Alice" the search result should contain space "find data" + + + Scenario: user can search inside folder in space + When user "Alice" searches for "folder" inside folder "/folderMain" in space "find data" using the WebDAV API + Then the HTTP status code should be "207" + And the search result should contain "3" entries + And the search result of user "Alice" should contain only these entries: + | /SubFolder1 | + | /SubFolder1/subFOLDER2 | + | /SubFolder1/subFOLDER2/insideTheFolder.txt | + But the search result of user "Alice" should not contain these entries: + | /folderMain | diff --git a/tests/acceptance/features/bootstrap/SearchContext.php b/tests/acceptance/features/bootstrap/SearchContext.php index 2557bafcc97..f67a1d894d5 100644 --- a/tests/acceptance/features/bootstrap/SearchContext.php +++ b/tests/acceptance/features/bootstrap/SearchContext.php @@ -40,11 +40,13 @@ class SearchContext implements Context { * @When user :user searches for :pattern using the WebDAV API requesting these properties: * @When user :user searches for :pattern and limits the results to :limit items using the WebDAV API requesting these properties: * @When user :user searches for :pattern inside folder :scope using the WebDAV API + * @When user :user searches for :pattern inside folder :scope in space :spaceName using the WebDAV API * * @param string $user * @param string $pattern * @param string|null $limit * @param string|null $scope + * @param string|null $spaceName * @param TableNode|null $properties * * @return void @@ -54,6 +56,7 @@ public function userSearchesUsingWebDavAPI( string $pattern, ?string $limit = null, ?string $scope = null, + ?string $spaceName = null, TableNode $properties = null ):void { // Because indexing of newly uploaded files or directories with ocis is decoupled and occurs asynchronously, a short wait is necessary before searching files or folders. @@ -66,7 +69,11 @@ public function userSearchesUsingWebDavAPI( = "\n" . " \n" . " \n"; - if ($scope !== null) { + if ($scope !== null && $spaceName !== null) { + $scope = \trim($scope, "/"); + $spaceId = $this->featureContext->spacesContext->getSpaceIdByName($user, $spaceName); + $pattern .= " scope:$spaceId/$scope"; + } elseif ($scope !== null) { $scope = \trim($scope, "/"); if ($this->featureContext->getDavPathVersion() === 3) { $rootPath = $this->featureContext->getPersonalSpaceIdForUser($user);