diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 86cb3b7c812..ecb6df0d441 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -2040,14 +2040,14 @@ public function userCopiesMovesFileIntoInsideSpaceUsingFileId(string $user, stri } /** - * @Given /^user "([^"]*)" has (copied|moved|renamed) file "([^"]*)" into "([^"]*)" inside space "([^"]*)" using file-id "([^"]*)"$/ + * @Given /^user "([^"]*)" has (copied|moved) file with id "([^"]*)" as "([^"]*)" into folder "([^"]*)" inside space "([^"]*)"$/ * * @param string $user * @param string $actionType - * @param string $sourceFile + * @param string $fileId * @param string $destinationFile + * @param string $destinationFolder * @param string $spaceName - * @param string $fileId * * @throws GuzzleException * @return void @@ -2055,21 +2055,15 @@ public function userCopiesMovesFileIntoInsideSpaceUsingFileId(string $user, stri public function userHasCopiedOrMovedFileInsideSpaceUsingFileId( string $user, string $actionType, - string $sourceFile, + string $fileId, string $destinationFile, + string $destinationFolder, string $spaceName, - string $fileId ): void { - // split the source when there are sub-folders - $sourceFile = \trim($sourceFile, "/"); - $sourceFile = \explode("/", $sourceFile); - $sourceFile = \end($sourceFile); $destinationFile = \trim($destinationFile, "/"); - if ($actionType === 'copied') { - $fileDestination = $this->escapePath($destinationFile) . '/' . $this->escapePath($sourceFile); - } elseif ($actionType === 'renamed' || $actionType === 'moved') { - $fileDestination = $destinationFile; - } + $destinationFolder = \trim($destinationFolder, "/"); + + $fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile); $baseUrl = $this->featureContext->getBaseUrl(); $sourceDavPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion()); @@ -2093,6 +2087,45 @@ public function userHasCopiedOrMovedFileInsideSpaceUsingFileId( ); } + /** + * @Given /^user "([^"]*)" has renamed file with id "([^"]*)" to "([^"]*)" inside space "([^"]*)"$/ + * + * @param string $user + * @param string $fileId + * @param string $destinationFile + * @param string $spaceName + * + * @throws GuzzleException + * @return void + */ + public function userHasRenamedFileInsideSpaceUsingFileId( + string $user, + string $fileId, + string $destinationFile, + string $spaceName + ): void { + $destinationFile = \trim($destinationFile, "/"); + + $fileDestination = $this->escapePath($destinationFile); + + $baseUrl = $this->featureContext->getBaseUrl(); + $sourceDavPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion()); + if ($spaceName === 'Shares') { + $sharesPath = $this->featureContext->getSharesMountPath($user, $fileDestination); + $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); + $headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; + } else { + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId); + } + $fullUrl = "$baseUrl/$sourceDavPath/$fileId"; + $response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers); + Assert::assertEquals( + 201, + $response->getStatusCode(), + "Expected response status code should be 201" + ); + } + /** * @When /^user "([^"]*)" tries to move (?:file|folder) "([^"]*)" of space "([^"]*)" to (space|folder) "([^"]*)" using its id in destination path$/ * @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" of space "([^"]*)" to (folder) "([^"]*)" using its id in destination path$/ @@ -3656,7 +3689,7 @@ public function userHasStoredIdOfPathOfTheSpace(string $user, string $path, stri /** * @Then /^user "([^"]*)" (folder|file) "([^"]*)" of the space "([^"]*)" should have the previously stored id$/ * - * @param string|null $user + * @param string $user * @param string $fileOrFolder * @param string $path * @param string $spaceName @@ -3664,6 +3697,7 @@ public function userHasStoredIdOfPathOfTheSpace(string $user, string $path, stri * @return void * * @throws GuzzleException + * @throws JsonException */ public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(string $user, string $fileOrFolder, string $path, string $spaceName): void { $this->getSpaceIdByName($user, $spaceName); diff --git a/tests/acceptance/features/apiActivities/activitiesByFileId.feature b/tests/acceptance/features/apiActivities/activitiesByFileId.feature index 11037dbe950..8874483ff48 100644 --- a/tests/acceptance/features/apiActivities/activitiesByFileId.feature +++ b/tests/acceptance/features/apiActivities/activitiesByFileId.feature @@ -12,7 +12,7 @@ Feature: check activities Given user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" And we save it into "FILEID" And user "Alice" has created folder "newFolder" - And user "Alice" has copied file "textfile.txt" into "newFolder" inside space "Personal" using file-id "<>" + And user "Alice" has copied file with id "<>" as "textfile.txt" into folder "newFolder" inside space "Personal" When user "Alice" lists the activities of folder "newFolder" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -249,7 +249,7 @@ Feature: check activities Scenario: check rename activity Given user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" And we save it into "FILEID" - And user "Alice" has renamed file "textfile.txt" into "renamed.txt" inside space "Personal" using file-id "<>" + And user "Alice" has renamed file with id "<>" to "renamed.txt" inside space "Personal" When user "Alice" lists the activities of file "renamed.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -365,7 +365,7 @@ Feature: check activities Given user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" And we save it into "FILEID" And user "Alice" has created folder "New Folder" - And user "Alice" has moved file "textfile.txt" into "New Folder/textfile.txt" inside space "Personal" using file-id "<>" + And user "Alice" has moved file with id "<>" as "textfile.txt" into folder "New Folder" inside space "Personal" When user "Alice" lists the activities of file "New Folder/textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -472,14 +472,7 @@ Feature: check activities } } """ - - - Scenario: check activities of destination folder after moving a file into it using file-id - Given user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" - And we save it into "FILEID" - And user "Alice" has created folder "FOLDER" - And user "Alice" has moved file "textfile.txt" into "FOLDER/textfile.txt" inside space "Personal" using file-id "<>" - When user "Alice" lists the activities of file "FOLDER" from space "Personal" using the Graph API + When user "Alice" lists the activities of folder "New Folder" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -504,6 +497,25 @@ Feature: check activities "properties": { "message": { "const": "{user} added {resource} to {folder}" + }, + "variables": { + "type": "object", + "required": ["resource"], + "properties": { + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "New Folder" + } + } + } + } } } } @@ -533,7 +545,7 @@ Feature: check activities "required": ["name"], "properties": { "name": { - "const": "FOLDER" + "const": "New Folder" } } }, @@ -587,11 +599,11 @@ Feature: check activities """ - Scenario: check activities of destinaton file and folder after moving a 0 byte file using file-id + Scenario: check activities of destination file and folder after moving a 0 byte file using file-id Given user "Alice" has uploaded file "filesForUpload/zerobyte.txt" to "zerobyte.txt" And we save it into "FILEID" And user "Alice" has created folder "FOLDER" - And user "Alice" has moved file "zerobyte.txt" into "FOLDER/zerobyte.txt" inside space "Personal" using file-id "<>" + And user "Alice" has moved file with id "<>" as "zerobyte.txt" into folder "FOLDER" inside space "Personal" When user "Alice" lists the activities of file "FOLDER/zerobyte.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -698,7 +710,7 @@ Feature: check activities } } """ - When user "Alice" lists the activities of file "FOLDER" from space "Personal" using the Graph API + When user "Alice" lists the activities of folder "FOLDER" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -806,11 +818,11 @@ Feature: check activities """ - Scenario: check activities of destinaton file and folder after moving a file by renaming destination file using file-id + Scenario: check activities of destination file and folder after moving a file by renaming destination file using file-id Given user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" And we save it into "FILEID" And user "Alice" has created folder "/FOLDER" - And user "Alice" has moved file "textfile.txt" into "FOLDER/renamed.txt" inside space "Personal" using file-id "<>" + And user "Alice" has moved file with id "<>" as "renamed.txt" into folder "FOLDER" inside space "Personal" When user "Alice" lists the activities of file "FOLDER/renamed.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -926,7 +938,7 @@ Feature: check activities } } """ - When user "Alice" lists the activities of file "FOLDER" from space "Personal" using the Graph API + When user "Alice" lists the activities of folder "FOLDER" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -1043,11 +1055,11 @@ Feature: check activities """ - Scenario: check activities of destinaton file and folder after moving a 0 byte file by renaming destination file using file-id + Scenario: check activities of destination file and folder after moving a 0 byte file by renaming destination file using file-id Given user "Alice" has uploaded file "filesForUpload/zerobyte.txt" to "/zerobyte.txt" And we save it into "FILEID" And user "Alice" has created folder "/FOLDER" - And user "Alice" has moved file "zerobye.txt" into "FOLDER/renamed.txt" inside space "Personal" using file-id "<>" + And user "Alice" has moved file with id "<>" as "renamed.txt" into folder "FOLDER" inside space "Personal" When user "Alice" lists the activities of file "FOLDER/renamed.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -1163,7 +1175,7 @@ Feature: check activities } } """ - When user "Alice" lists the activities of file "FOLDER" from space "Personal" using the Graph API + When user "Alice" lists the activities of folder "FOLDER" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """