From 417294e520c2cc8934da3dd84c6e7ade4af0a4a0 Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Wed, 18 Sep 2024 14:23:43 +0545 Subject: [PATCH] add test to download preview with preview set to zero Signed-off-by: prashant-gurung899 --- tests/acceptance/bootstrap/WebDav.php | 32 +++++++++++++++++++ .../coreApiWebdavPreviews/previews.feature | 29 +++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/tests/acceptance/bootstrap/WebDav.php b/tests/acceptance/bootstrap/WebDav.php index d2c9e2555d..78496558d5 100644 --- a/tests/acceptance/bootstrap/WebDav.php +++ b/tests/acceptance/bootstrap/WebDav.php @@ -3691,6 +3691,38 @@ trait WebDav { $this->setResponse($response); } + /** + * @When user :user tries to download the preview of :path with width :width and height :height and preview set to 0 using the WebDAV API + * + * @param string $user + * @param string $path + * @param string $width + * @param string $height + * + * @return void + */ + public function userDownloadsThePreviewOfWithPreviewZero(string $user, string $path, string $width, string $height) { + $user = $this->getActualUsername($user); + $urlParameter = [ + 'x' => $width, + 'y' => $height, + 'preview' => '0' + ]; + $response = $this->makeDavRequest( + $user, + "GET", + $path, + [], + null, + "files", + null, + false, + null, + $urlParameter, + ); + $this->setResponse($response); + } + /** * @When user :user downloads the preview of shared resource :path with width :width and height :height using the WebDAV API * diff --git a/tests/acceptance/features/coreApiWebdavPreviews/previews.feature b/tests/acceptance/features/coreApiWebdavPreviews/previews.feature index 1fc265dc2e..dcb2807a9b 100644 --- a/tests/acceptance/features/coreApiWebdavPreviews/previews.feature +++ b/tests/acceptance/features/coreApiWebdavPreviews/previews.feature @@ -315,3 +315,32 @@ Feature: previews of files downloaded through the webdav API | old | | new | | spaces | + + + Scenario Outline: try to download preview of an image with preview set to 0 + Given using DAV path + And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "/testavatar.jpg" + When user "Alice" tries to download the preview of "/testavatar.jpg" with width "32" and height "32" and preview set to 0 using the WebDAV API + Then the HTTP status code should be "200" + And the downloaded image should be "1240" pixels wide and "648" pixels high + Examples: + | dav-path-version | + | old | + | new | + | spaces | + + + Scenario Outline: try to download preview of a text file with preview set to 0 + Given using DAV path + And user "Alice" has uploaded file with content "to preview" to "textfile.txt" + When user "Alice" tries to download the preview of "textfile.txt" with width "32" and height "32" and preview set to 0 using the WebDAV API + Then the HTTP status code should be "200" + And the content in the response should match the following content: + """ + to preview + """ + Examples: + | dav-path-version | + | old | + | new | + | spaces |