From 12f416a18e958257b16c56ef78f915ae54a5173b Mon Sep 17 00:00:00 2001 From: Prajwol Amatya <83579989+PrajwolAmatya@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:42:32 +0545 Subject: [PATCH] add tests for search files using media type (#7836) --- .../apiSearch/mediaTypeSearch.feature | 121 ++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 22 ++++ 2 files changed, 143 insertions(+) create mode 100644 tests/acceptance/features/apiSearch/mediaTypeSearch.feature diff --git a/tests/acceptance/features/apiSearch/mediaTypeSearch.feature b/tests/acceptance/features/apiSearch/mediaTypeSearch.feature new file mode 100644 index 000000000..f261c5737 --- /dev/null +++ b/tests/acceptance/features/apiSearch/mediaTypeSearch.feature @@ -0,0 +1,121 @@ +Feature: media type search + As a user + I want to search files using media type + So that I can find the files with specific media type + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + And using spaces DAV path + + + Scenario Outline: search for files using media type + Given user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/lorem.txt" + And user "Alice" has uploaded file "filesForUpload/simple.pdf" to "/simple.pdf" + And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "/testavatar.jpg" + And user "Alice" has uploaded file "filesForUpload/testavatar.png" to "/testavatar.png" + And user "Alice" has uploaded file "filesForUpload/data.tar.gz" to "/data.tar.gz" + When user "Alice" searches for "mediatype:" 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 these entries: + | | + Examples: + | pattern | search-result | + | *text* | /lorem.txt | + | *pdf* | /simple.pdf | + | *jpeg* | /testavatar.jpg | + | *png* | /testavatar.png | + | *gzip* | /data.tar.gz | + + + Scenario Outline: search for files inside sub folders using media type + Given user "Alice" has created folder "/uploadFolder" + And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/uploadFolder/lorem.txt" + And user "Alice" has uploaded file "filesForUpload/simple.pdf" to "/uploadFolder/simple.pdf" + And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "/uploadFolder/testavatar.jpg" + And user "Alice" has uploaded file "filesForUpload/testavatar.png" to "/uploadFolder/testavatar.png" + And user "Alice" has uploaded file "filesForUpload/data.tar.gz" to "/uploadFolder/data.tar.gz" + When user "Alice" searches for "mediatype:" 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 these entries: + | | + Examples: + | pattern | search-result | + | *text* | /uploadFolder/lorem.txt | + | *pdf* | /uploadFolder/simple.pdf | + | *jpeg* | /uploadFolder/testavatar.jpg | + | *png* | /uploadFolder/testavatar.png | + | *gzip* | /uploadFolder/data.tar.gz | + + + Scenario Outline: search for file inside project space using media type + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "find data" with the default quota using the Graph API + And user "Alice" has uploaded a file "filesForUpload/lorem.txt" to "/lorem.txt" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/simple.pdf" to "/simple.pdf" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/testavatar.jpg" to "/testavatar.jpg" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/testavatar.png" to "/testavatar.png" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/data.tar.gz" to "/data.tar.gz" in space "find data" + When user "Alice" searches for "mediatype:" 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 these entries: + | | + Examples: + | pattern | search-result | + | *text* | /lorem.txt | + | *pdf* | /simple.pdf | + | *jpeg* | /testavatar.jpg | + | *png* | /testavatar.png | + | *gzip* | /data.tar.gz | + + + Scenario Outline: sharee searches for shared files using media type + Given user "Alice" has created folder "/uploadFolder" + And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/uploadFolder/lorem.txt" + And user "Alice" has uploaded file "filesForUpload/simple.pdf" to "/uploadFolder/simple.pdf" + And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "/uploadFolder/testavatar.jpg" + And user "Alice" has uploaded file "filesForUpload/testavatar.png" to "/uploadFolder/testavatar.png" + And user "Alice" has uploaded file "filesForUpload/data.tar.gz" to "/uploadFolder/data.tar.gz" + And user "Alice" has shared folder "uploadFolder" with user "Brian" + When user "Brian" searches for "mediatype:" 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 these entries: + | | + Examples: + | pattern | search-result | + | *text* | /uploadFolder/lorem.txt | + | *pdf* | /uploadFolder/simple.pdf | + | *jpeg* | /uploadFolder/testavatar.jpg | + | *png* | /uploadFolder/testavatar.png | + | *gzip* | /uploadFolder/data.tar.gz | + + + Scenario Outline: sharee searches for files inside shared space using media type + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "find data" with the default quota using the Graph API + And user "Alice" has uploaded a file "filesForUpload/lorem.txt" to "/lorem.txt" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/simple.pdf" to "/simple.pdf" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/testavatar.jpg" to "/testavatar.jpg" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/testavatar.png" to "/testavatar.png" in space "find data" + And user "Alice" has uploaded a file "filesForUpload/data.tar.gz" to "/data.tar.gz" in space "find data" + And user "Alice" has shared a space "find data" with settings: + | shareWith | Brian | + | role | viewer | + When user "Brian" searches for "mediatype:" 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 these entries: + | | + Examples: + | pattern | search-result | + | *text* | /lorem.txt | + | *pdf* | /simple.pdf | + | *jpeg* | /testavatar.jpg | + | *png* | /testavatar.png | + | *gzip* | /data.tar.gz | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 3fcc05d63..80fcb4b6a 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1306,6 +1306,28 @@ class SpacesContext implements Context { $this->featureContext->setResponse($response); } + /** + * @Given user :user has uploaded a file :source to :destination in space :spaceName + * + * @param string $user + * @param string $source + * @param string $destination + * @param string $spaceName + * + * @return void + * @throws GuzzleException + * @throws Exception + */ + public function userHasUploadedAFileToInSpaceUsingTheWebdavApi(string $user, string $source, string $destination, string $spaceName): void { + $this->setSpaceIDByName($user, $spaceName); + $response = $this->featureContext->uploadFile($user, $source, $destination); + $this->featureContext->theHTTPStatusCodeShouldBe( + 201, + "Expected response status code should be 201", + $response + ); + } + /** * @When /^user "([^"]*)" uploads a file inside space "([^"]*)" owned by the user "([^"]*)" with content "([^"]*)" to "([^"]*)" using the WebDAV API$/ *