Skip to content

Commit

Permalink
Merge pull request #6972 from owncloud/search-inside-current-folder-s…
Browse files Browse the repository at this point in the history
…paces

[tests-only][full-ci] added test scenario for searching inside folder in space
  • Loading branch information
KarunAtreya authored and nabim777 committed Aug 8, 2023
2 parents 712d98e + 2238806 commit 35884fd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
23 changes: 23 additions & 0 deletions tests/acceptance/features/apiGraph/fullSearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,29 @@ Feature: full text search
| spaces |


Scenario Outline: search project space folders by tag
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "tag-space" with the default quota using the GraphApi
And user "Alice" has created a folder "spacesFolder/spacesSubFolder" in space "tag-space"
And user "Alice" has created a folder "unTagSpacesFolder/unTagSpacesSubFolder" in space "tag-space"
And user "Alice" has created the following tags for folder "spacesFolder" of the space "tag-space":
| tag1 |
And user "Alice" has created the following tags for folder "spacesFolder/spacesSubFolder" of the space "tag-space":
| tag1 |
And using <dav-path-version> DAV path
When user "Alice" searches for "Tags:tag1" using the WebDAV API
Then the HTTP status code should be "207"
And the search result of user "Alice" should contain only these files:
| spacesFolder |
| spacesSubFolder |
Examples:
| dav-path-version |
| old |
| new |
| spaces |


Scenario Outline: sharee searches shared files using a tag
Given using <dav-path-version> DAV path
And user "Brian" has been created with default attributes and without skeleton files
Expand Down
16 changes: 14 additions & 2 deletions tests/acceptance/features/apiSpaces/search.feature
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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 |
9 changes: 8 additions & 1 deletion tests/acceptance/features/bootstrap/SearchContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -66,7 +69,11 @@ public function userSearchesUsingWebDavAPI(
= "<?xml version='1.0' encoding='utf-8' ?>\n" .
" <oc:search-files xmlns:a='DAV:' xmlns:oc='http://owncloud.org/ns' >\n" .
" <oc:search>\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);
Expand Down

0 comments on commit 35884fd

Please sign in to comment.