Skip to content

Commit

Permalink
added test scenario for searching inside particular folder only
Browse files Browse the repository at this point in the history
  • Loading branch information
KarunAtreya committed Aug 4, 2023
1 parent c99908f commit c9180c0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
21 changes: 21 additions & 0 deletions tests/acceptance/features/apiGraph/fullSearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,24 @@ Feature: full text search
| old |
| new |
| spaces |


Scenario Outline: search files inside the current folder
Given using <dav-path-version> 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 SubFolder" 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 |
22 changes: 17 additions & 5 deletions tests/acceptance/features/bootstrap/SearchContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -62,8 +65,17 @@ public function userSearchesUsingWebDavAPI(
$body
= "<?xml version='1.0' encoding='utf-8' ?>\n" .
" <oc:search-files xmlns:a='DAV:' xmlns:oc='http://owncloud.org/ns' >\n" .
" <oc:search>\n" .
" <oc:pattern>$pattern</oc:pattern>\n";
" <oc:search>\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 .= "<oc:pattern>$pattern</oc:pattern>\n";
if ($limit !== null) {
$body .= " <oc:limit>$limit</oc:limit>\n";
}
Expand Down

0 comments on commit c9180c0

Please sign in to comment.