From be7365e291e15bd24c0fe9c5f33eec7af98b177b Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Thu, 18 Jul 2024 09:45:13 +0545 Subject: [PATCH] add test to remove versions of files from space using space id Signed-off-by: prashant-gurung899 --- .../features/bootstrap/CliContext.php | 18 +++++++++ .../cliCommands/removeFileVersions.feature | 38 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/bootstrap/CliContext.php b/tests/acceptance/features/bootstrap/CliContext.php index 43e730c4ca5..e4ffb69051c 100644 --- a/tests/acceptance/features/bootstrap/CliContext.php +++ b/tests/acceptance/features/bootstrap/CliContext.php @@ -168,6 +168,24 @@ public function theAdministratorReindexesASpaceUsingTheCli(string $spaceName): v $this->featureContext->setResponse(CliHelper::runCommand($body)); } + /** + * @When the administrator removes the file versions of space :space using the CLI + * + * @param string $space + * + * @return void + */ + public function theAdministratorRemovesTheVersionsOfFilesInSpaceUsingSpaceId(string $space):void { + $path = $this->featureContext->getStorageUsersRoot(); + $adminUsername = $this->featureContext->getAdminUsername(); + $spaceId = $this->spacesContext->getSpaceIdByName($adminUsername, $space); + $command = "revisions purge -p $path -r $spaceId --dry-run=false"; + $body = [ + "command" => $command + ]; + $this->featureContext->setResponse(CliHelper::runCommand($body)); + } + /** * @Then the command should be successful * diff --git a/tests/acceptance/features/cliCommands/removeFileVersions.feature b/tests/acceptance/features/cliCommands/removeFileVersions.feature index c4c8525b6c8..be1b57ffa01 100644 --- a/tests/acceptance/features/cliCommands/removeFileVersions.feature +++ b/tests/acceptance/features/cliCommands/removeFileVersions.feature @@ -1,10 +1,12 @@ @env-config Feature: remove file versions via CLI command + Background: + Given user "Alice" has been created with default attributes and without skeleton files + Scenario: remove all file versions - Given user "Alice" has been created with default attributes and without skeleton files - And user "Alice" has uploaded file with content "This is version 1" to "textfile.txt" + Given user "Alice" has uploaded file with content "This is version 1" to "textfile.txt" And user "Alice" has uploaded file with content "This is version 2" to "textfile.txt" And user "Alice" has uploaded file with content "This is version 3" to "textfile.txt" When the administrator removes all the file versions using the CLI @@ -16,8 +18,7 @@ Feature: remove file versions via CLI command Scenario: remove all versions of file using file-id - Given user "Alice" has been created with default attributes and without skeleton files - And user "Alice" has uploaded file with content "This is version 1" to "randomFile.txt" + Given user "Alice" has uploaded file with content "This is version 1" to "randomFile.txt" And user "Alice" has uploaded file with content "This is version 2" to "randomFile.txt" And user "Alice" has uploaded file with content "This is version 3" to "randomFile.txt" And user "Alice" has uploaded file with content "This is version 1" to "anotherFile.txt" @@ -32,3 +33,32 @@ Feature: remove file versions via CLI command When user "Alice" gets the number of versions of file "anotherFile.txt" Then the HTTP status code should be "207" And the number of versions should be "2" + + + Scenario: remove all versions of files from a space + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And using spaces DAV path + And user "Alice" has created a space "projectSpace" with the default quota using the Graph API + And user "Alice" has uploaded file with content "This is version 1" to "file.txt" + And user "Alice" has uploaded file with content "This is version 2" to "file.txt" + And user "Alice" has uploaded file with content "This is version 3" to "file.txt" + And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 1" to "lorem.txt" + And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 2" to "lorem.txt" + And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 3" to "lorem.txt" + And we save it into "FILEID" + And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 1" to "epsum.txt" + And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 2" to "epsum.txt" + And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 3" to "epsum.txt" + And we save it into "FILEID1" + When the administrator removes the file versions of space "projectSpace" using the CLI + Then the command should be successful + And the command output should contain "✅ Deleted 4 revisions (12 files / 4 blobs)" + When user "Alice" gets the number of versions of file "file.txt" + Then the HTTP status code should be "207" + And the number of versions should be "2" + When user "Alice" gets the number of versions of file "lorem.txt" using file-id path "/meta/<>/v" + Then the HTTP status code should be "207" + And the number of versions should be "0" + When user "Alice" gets the number of versions of file "epsum.txt" using file-id path "/meta/<>/v" + Then the HTTP status code should be "207" + And the number of versions should be "0"