diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 6bb5665f7..97a7aa393 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -207,6 +207,8 @@ default: - OCSContext: - TrashbinContext: - TagContext: + - SpacesTUSContext: + - TUSContext: apiReshare: paths: diff --git a/tests/acceptance/features/apiSearch/dateSearch.feature b/tests/acceptance/features/apiSearch/dateSearch.feature new file mode 100644 index 000000000..df2456c48 --- /dev/null +++ b/tests/acceptance/features/apiSearch/dateSearch.feature @@ -0,0 +1,64 @@ +Feature: date search + As a user + I want to do search resources by date + + Background: + Given user "Alice" has been created with default attributes and without skeleton files + + Scenario Outline: search resources using different dav path + Given using DAV path + And user "Alice" has created folder "uploadFolder" + When user "Alice" searches for 'Mtime:"today"' using the WebDAV API + And the search result of user "Alice" should contain these entries: + | /uploadFolder | + Examples: + | dav-path-version | + | old | + | new | + | spaces | + + + Scenario Outline: search resources using different search patterns (KQL feature) in the personal space + Given user "Alice" uploads a file "filesForUpload/textfile.txt" to "/today.txt" with mtime "today" via TUS inside of the space "Personal" using the WebDAV API + And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/yesterday.txt" with mtime "yesterday" via TUS inside of the space "Personal" using the WebDAV API + And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/lastWeek.txt" with mtime "lastWeek" via TUS inside of the space "Personal" using the WebDAV API + And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/lastMonth.txt" with mtime "lastMonth" via TUS inside of the space "Personal" using the WebDAV API + And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/lastYear.txt" with mtime "lastYear" via TUS inside of the space "Personal" using the WebDAV API + And using spaces DAV path + When user "Alice" searches for '' using the WebDAV API + Then the HTTP status code should be "207" + And the search result of user "Alice" should contain these entries: + | | + | | + But the search result of user "Alice" should not contain these entries: + | | + | | + Examples: + | pattern | search-result-1 | search-result-2 | search-result-3 | search-result-4 | + | Mtime:today | /today.txt | | /yesterday.txt | /lastWeek.txt | + | Mtime:yesterday | /yesterday.txt | | /today.txt | | + | Mtime:"this week" | /today.txt | | /lastWeek.txt | /lastMont.txt | + | Mtime:"this month" | /today.txt | | /lastMont.txt | | + | Mtime:"last month" | /lastMonth.txt | | /today.txt | | + | Mtime:"this year" | /today.txt | | /lastYear.txt | | + | Mtime:"last year" | /lastYear.txt | | /today.txt | | + | Mtime>=$today | /today.txt | | /yesterday.txt | | + | Mtime>$yesterday | /today.txt | | | | + | Mtime>=$yesterday | /today.txt | /yesterday.txt | | | + # Mtime<$today. "<" has to be escaped + | Mtime<$today | /yesterday.txt | /lastYear.txt | /today.txt | | + + + Scenario: search resources using different search patterns (KQL feature) in the shares folder + Given user "Brian" has been created with default attributes and without skeleton files + And using spaces DAV path + And user "Alice" has created folder "sharedFolder" + And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/sharedFolder/yesterday.txt" with mtime "yesterday" via TUS inside of the space "Personal" using the WebDAV API + And user "Alice" has shared folder "/sharedFolder" with user "Brian" + And user "Brian" has accepted share "/sharedFolder" offered by user "Alice" + When user "Brian" searches for "Mtime:yesterday" using the WebDAV API + Then the HTTP status code should be "207" + And the search result of user "Brian" should contain these entries: + | sharedFolder/yesterday.txt | + But the search result of user "Alice" should not contain these entries: + | sharedFolder | diff --git a/tests/acceptance/features/apiSearch/tagSearch.feature b/tests/acceptance/features/apiSearch/tagSearch.feature index 2e8db190f..301e1d25b 100644 --- a/tests/acceptance/features/apiSearch/tagSearch.feature +++ b/tests/acceptance/features/apiSearch/tagSearch.feature @@ -266,12 +266,10 @@ Feature: tag search | tag:(mathe klass10) | 2 | /exercises | /answers | | tag:klass10 AND tag:chemi | 1 | /answers | | | tag:chemi OR tag:physik | 2 | /exercises | /answers | - # why we need use quotes? it'll be fixed in future. Actual: search result gives all user content - #| (tag:klass10) NOT tag:physik | 2 | /answers | verification work | + | (tag:klass10) NOT tag:physik | 2 | /answers | verification work | | (tag:(mathe klass10)) NOT tag:chemi | 1 | /exercises | | | (tag:mathe OR tag:klass10) NOT tag:physik | 2 | /answers | /verification work | | tag:mathe NOT name:exercises | 1 | /answers | | | tag:mathe AND NOT name:exercises | 1 | /answers | | # The third finding is the personal space itself | NOT tag:mathe | 3 | /verification work | /withoutTagFolder | - diff --git a/tests/acceptance/features/bootstrap/SearchContext.php b/tests/acceptance/features/bootstrap/SearchContext.php index 2c843e2a6..78b21f681 100644 --- a/tests/acceptance/features/bootstrap/SearchContext.php +++ b/tests/acceptance/features/bootstrap/SearchContext.php @@ -64,6 +64,19 @@ class SearchContext implements Context { $user = $this->featureContext->getActualUsername($user); $baseUrl = $this->featureContext->getBaseUrl(); $password = $this->featureContext->getPasswordForUser($user); + if (str_contains($pattern, '$')) { + $date = explode("$", $pattern); + switch ($date[1]) { + case "today": + $pattern = $date[0] . date('Y-m-d', strtotime('today')); + break; + case "yesterday": + $pattern = $date[0] . date('Y-m-d', strtotime('yesterday')); + break; + default: + throw new Exception("cannot convert the date"); + } + } $body = "\n" . " \n" . diff --git a/tests/acceptance/features/bootstrap/SpacesTUSContext.php b/tests/acceptance/features/bootstrap/SpacesTUSContext.php index 9b53a0345..7890ae02b 100644 --- a/tests/acceptance/features/bootstrap/SpacesTUSContext.php +++ b/tests/acceptance/features/bootstrap/SpacesTUSContext.php @@ -195,6 +195,25 @@ class SpacesTUSContext implements Context { string $mtime, string $spaceName ): void { + switch ($mtime) { + case "today": + $mtime = date('Y-m-d', strtotime('today')); + break; + case "yesterday": + $mtime = date('Y-m-d', strtotime('yesterday')); + break; + case "lastWeek": + $mtime = date('Y-m-d', strtotime('-7 days')); + break; + case "lastMonth": + $mtime = date('Y-m' . '-01', strtotime('-1 month')); + break; + case "lastYear": + $mtime = date('Y-m' . '-01', strtotime('-1 year')); + break; + default: + $mtime; + } $this->spacesContext->setSpaceIDByName($user, $spaceName); $this->tusContext->userUploadsFileWithContentToWithMtimeUsingTUS($user, $source, $destination, $mtime); }