test(refactor): search files in specific spaces and globally

This commit is contained in:
pradip
2024-09-30 14:15:09 +05:45
parent c05e1b2809
commit 97f6fa045a
2 changed files with 69 additions and 109 deletions

View File

@@ -43,6 +43,7 @@ class SearchContext implements Context {
* @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
* @When user :user searches for :pattern within space :spaceName using the WebDAV API
*
* @param string $user
* @param string $pattern
@@ -84,9 +85,11 @@ class SearchContext implements Context {
= "<?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) {
$scope = \trim($scope, "/");
$resourceID = $this->featureContext->spacesContext->getResourceId($user, $spaceName ?? "Personal", $scope);
if ($spaceName !== null) {
$resourceID = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $scope ?? "");
$pattern .= " scope:$resourceID";
} elseif ($scope !== null) {
$resourceID = $this->featureContext->spacesContext->getResourceId($user, "Personal", $scope);
$pattern .= " scope:$resourceID";
}
$body .= "<oc:pattern>$pattern</oc:pattern>\n";

View File

@@ -15,17 +15,27 @@ Feature: Search
And user "Alice" has uploaded a file inside space "project101" with content "some content" to "folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt"
Scenario Outline: user can search items from the project space
Scenario Outline: user can search items within project space
Given using <dav-path-version> DAV path
When user "Alice" searches for "*SUB*" using the WebDAV API
And user "Alice" has created a folder "AlicePersonal" in space "Personal"
And user "Alice" has uploaded a file inside space "Personal" with content "inside Alice personal space" to "AlicePersonal/insideAlicePersonal.txt"
And user "Brian" has created a folder "BrianPersonal" in space "Personal"
And user "Brian" has uploaded file with content "inside Brian personal space" to "BrianPersonal/insideBrianPersonal.txt"
And user "Brian" has sent the following resource share invitation:
| resource | BrianPersonal |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has a share "BrianPersonal" synced
When user "Alice" searches for "*inside*" within space "project101" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "2" entries
And the search result should contain "1" entries
And the search result of user "Alice" should contain these entries:
| /folderMain/SubFolder1 |
| /folderMain/SubFolder1/subFOLDER2 |
| folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
But the search result of user "Alice" should not contain these entries:
| /folderMain |
| /folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
| /AlicePersonal/insideAlicePersonal.txt |
| /BrianPersonal/insideBrianPersonal.txt |
Examples:
| dav-path-version |
| old |
@@ -33,23 +43,54 @@ Feature: Search
| spaces |
Scenario Outline: user can search items from the shares
Scenario Outline: user can search items within personal space
Given using <dav-path-version> DAV path
And user "Alice" has sent the following resource share invitation:
| resource | folderMain |
| space | project101 |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
And user "Brian" has a share "folderMain" synced
When user "Brian" searches for "*folder*" using the WebDAV API
And user "Alice" has created a folder "AlicePersonal" in space "Personal"
And user "Alice" has uploaded a file inside space "Personal" with content "inside Alice personal space" to "AlicePersonal/insideAlicePersonal.txt"
And user "Brian" has created a folder "BrianPersonal" in space "Personal"
And user "Brian" has uploaded file with content "inside Brian personal space" to "BrianPersonal/insideBrianPersonal.txt"
And user "Brian" has sent the following resource share invitation:
| resource | BrianPersonal |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has a share "BrianPersonal" synced
When user "Alice" searches for "*inside*" within space "Personal" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "4" entries
And the search result of user "Brian" should contain these entries:
| folderMain/SubFolder1 |
| folderMain/SubFolder1/subFOLDER2 |
And the search result should contain "1" entries
And the search result of user "Alice" should contain only these entries:
| AlicePersonal/insideAlicePersonal.txt |
But the search result of user "Alice" should not contain these entries:
| BrianPersonal/insideBrianPersonal.txt |
| folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
Examples:
| dav-path-version |
| old |
| new |
| spaces |
Scenario Outline: user cannot search items within shares space
Given using <dav-path-version> DAV path
And user "Alice" has created a folder "AlicePersonal" in space "Personal"
And user "Alice" has uploaded a file inside space "Personal" with content "inside Alice personal space" to "AlicePersonal/insideAlicePersonal.txt"
And user "Brian" has created a folder "BrianPersonal" in space "Personal"
And user "Brian" has uploaded file with content "inside Brian personal space" to "BrianPersonal/insideBrianPersonal.txt"
And user "Brian" has sent the following resource share invitation:
| resource | BrianPersonal |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has a share "BrianPersonal" synced
When user "Alice" searches for "*inside*" within space "Shares" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "0" entries
And the search result of user "Alice" should not contain these entries:
| BrianPersonal/insideBrianPersonal.txt |
| AlicePersonal/insideAlicePersonal.txt |
| folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
And for user "Brian" the search result should contain space "mountpoint/folderMain"
Examples:
| dav-path-version |
| old |
@@ -293,7 +334,7 @@ Feature: Search
And the value of the item "/d:error/s:message" in the response should be "error: bad request: the expression can't begin from a binary operator: 'AND'"
Scenario Outline: search a file globally (in all drives)
Scenario Outline: search a file globally (in all spaces)
Given using <dav-path-version> DAV path
And user "Alice" has created a folder "AlicePersonal" in space "Personal"
And user "Alice" has uploaded a file inside space "Personal" with content "inside Alice personal space" to "AlicePersonal/insideAlicePersonal.txt"
@@ -318,87 +359,3 @@ Feature: Search
| old |
| new |
| spaces |
Scenario Outline: search a file within Personal drive
Given using <dav-path-version> DAV path
And user "Alice" has created a folder "AlicePersonal" in space "Personal"
And user "Alice" has uploaded a file inside space "Personal" with content "inside Alice personal space" to "AlicePersonal/insideAlicePersonal.txt"
And user "Brian" has created a folder "BrianPersonal" in space "Personal"
And user "Brian" has uploaded file with content "inside Brian personal space" to "BrianPersonal/insideBrianPersonal.txt"
And user "Brian" has sent the following resource share invitation:
| resource | BrianPersonal |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has a share "BrianPersonal" synced
When user "Alice" searches for "*inside*" inside folder "AlicePersonal" in space "Personal" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "1" entries
And the search result of user "Alice" should contain only these entries:
| AlicePersonal/insideAlicePersonal.txt |
But the search result of user "Alice" should not contain these entries:
| folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
| BrianPersonal/insideBrianPersonal.txt |
Examples:
| dav-path-version |
| old |
| new |
| spaces |
Scenario Outline: search a file within Project drive
Given using <dav-path-version> DAV path
And user "Alice" has created a folder "AlicePersonal" in space "Personal"
And user "Alice" has uploaded a file inside space "Personal" with content "inside Alice personal space" to "AlicePersonal/insideAlicePersonal.txt"
And user "Brian" has created a folder "BrianPersonal" in space "Personal"
And user "Brian" has uploaded file with content "inside Brian personal space" to "BrianPersonal/insideBrianPersonal.txt"
And user "Brian" has sent the following resource share invitation:
| resource | BrianPersonal |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has a share "BrianPersonal" synced
When user "Alice" searches for "*inside*" inside folder "folderMain" in space "project101" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "1" entries
And the search result of user "Alice" should contain only these entries:
| folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
But the search result of user "Alice" should not contain these entries:
| AlicePersonal/insideAlicePersonal.txt |
| BrianPersonal/insideBrianPersonal.txt |
Examples:
| dav-path-version |
| old |
| new |
| spaces |
Scenario Outline: search a file within Shares drive
Given using <dav-path-version> DAV path
And user "Alice" has created a folder "AlicePersonal" in space "Personal"
And user "Alice" has uploaded a file inside space "Personal" with content "inside Alice personal space" to "AlicePersonal/insideAlicePersonal.txt"
And user "Brian" has created a folder "BrianPersonal" in space "Personal"
And user "Brian" has uploaded file with content "inside Brian personal space" to "BrianPersonal/insideBrianPersonal.txt"
And user "Brian" has sent the following resource share invitation:
| resource | BrianPersonal |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
And user "Alice" has a share "BrianPersonal" synced
When user "Alice" searches for "*inside*" inside folder "BrianPersonal" in space "Shares" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "1" entries
And the search result of user "Alice" should contain only these entries:
| BrianPersonal/insideBrianPersonal.txt |
But the search result of user "Alice" should not contain these entries:
| AlicePersonal/insideAlicePersonal.txt |
| folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
Examples:
| dav-path-version |
| old |
| new |
| spaces |