From 49cc77376f764f83b9000a2184e27ea169f50ce6 Mon Sep 17 00:00:00 2001 From: Karun Atreya <33852651+KarunAtreya@users.noreply.github.com> Date: Tue, 8 Aug 2023 12:14:27 +0545 Subject: [PATCH] [tests-only][full-ci] Backport searching inside folder in personal space(#6949) (#6980) * added test scenario for searching inside particular folder only * added skip on stabl3.0 --- .../features/apiGraph/fullSearch.feature | 21 ++++++++++++++++++ .../features/bootstrap/SearchContext.php | 22 ++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/features/apiGraph/fullSearch.feature b/tests/acceptance/features/apiGraph/fullSearch.feature index c1c1307654b..5ab8e2bbad6 100644 --- a/tests/acceptance/features/apiGraph/fullSearch.feature +++ b/tests/acceptance/features/apiGraph/fullSearch.feature @@ -155,3 +155,24 @@ Feature: full text search | old | | new | | spaces | + + @skipOnStable3.0 + Scenario Outline: search files inside the folder + Given using DAV path + And user "Alice" has uploaded file with content "hello world inside root" to "file1.txt" + And user "Alice" has created folder "/Folder" + And user "Alice" has uploaded file with content "hello world inside folder" to "/Folder/file2.txt" + And user "Alice" has created folder "/Folder/SubFolder" + And user "Alice" has uploaded file with content "hello world inside sub-folder" to "/Folder/SubFolder/file3.txt" + When user "Alice" searches for "file" inside folder "/Folder" using the WebDAV API + Then the HTTP status code should be "207" + And the search result of user "Alice" should contain only these entries: + | file2.txt | + | file3.txt | + But the search result of user "Alice" should not contain these entries: + | file1.txt | + Examples: + | dav-path-version | + | old | + | new | + | spaces | diff --git a/tests/acceptance/features/bootstrap/SearchContext.php b/tests/acceptance/features/bootstrap/SearchContext.php index f850f2161a9..2fe7dfcc5e9 100644 --- a/tests/acceptance/features/bootstrap/SearchContext.php +++ b/tests/acceptance/features/bootstrap/SearchContext.php @@ -39,18 +39,21 @@ class SearchContext implements Context { * @When user :user searches for :pattern and limits the results to :limit items using the WebDAV API * @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 * * @param string $user * @param string $pattern * @param string|null $limit + * @param string|null $scope * @param TableNode|null $properties * * @return void */ public function userSearchesUsingWebDavAPI( - string $user, - string $pattern, - ?string $limit = null, + string $user, + string $pattern, + ?string $limit = null, + ?string $scope = 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. @@ -61,8 +64,17 @@ public function userSearchesUsingWebDavAPI( $body = "\n" . " \n" . - " \n" . - " $pattern\n"; + " \n"; + if ($scope !== null) { + $scope = \trim($scope, "/"); + if ($this->featureContext->getDavPathVersion() === 3) { + $rootPath = $this->featureContext->getPersonalSpaceIdForUser($user); + } else { + $rootPath = $this->featureContext->getUserIdByUserName($user); + } + $pattern .= " scope:$rootPath/$scope"; + } + $body .= "$pattern\n"; if ($limit !== null) { $body .= " $limit\n"; }