Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] cli test for delete empty trash bin directory #9617

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ default:
- SharingNgContext:
- SearchContext:
- TagContext:
- TrashbinContext:

extensions:
rdx\behatvars\BehatVariablesExtension: ~
Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/features/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $statu
$this->featureContext->updateUserPassword($user, $password);
}

/**
* @When the administrator deletes the empty trashbin folders using the CLI
*
* @return void
*/
public function theAdministratorDeletesEmptyTrashbinFoldersUsingTheCli():void {
$path = $this->featureContext->getStorageUsersRoot();
$command = "trash purge-empty-dirs -p $path --dry-run=false";
$body = [
"command" => $command
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @When the administrator checks the backup consistency using the CLI
*
Expand Down
22 changes: 22 additions & 0 deletions tests/acceptance/features/bootstrap/TrashbinContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,28 @@ public function deleteFileFromTrashbin(string $user, string $originalPath):void
$this->featureContext->pushToLastStatusCodesArrays();
}

/**
* @Given /^user "([^"]*)" has deleted the (?:file|folder|entry) with original path "([^"]*)" from the trashbin$/
*
* @param string $user
* @param string $originalPath
*
* @return void
* @throws Exception
*/
public function userHasDeletedTheFolderWithOriginalPathFromTheTrashbin(string $user, string $originalPath):void {
$responseArray = $this->tryToDeleteFileFromTrashbin($user, $originalPath);
$numItemDeleted = \count($responseArray);
Assert::assertEquals(
1,
$numItemDeleted,
"Expected to delete exactly one item from the trashbin but $numItemDeleted were deleted"
);
foreach ($responseArray as $response) {
$this->featureContext->theHTTPStatusCodeShouldBe(204, '', $response);
}
}

/**
* @When /^user "([^"]*)" deletes the following (?:files|folders|entries) with original path from the trashbin$/
*
Expand Down
24 changes: 24 additions & 0 deletions tests/acceptance/features/cliCommands/cleanupEmptyTrashBin.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@env-config
Feature: delete empty trash bin folder via CLI command


Scenario: delete empty trashbin folders
Given the user "Admin" has created a new user with the following attributes:
| userName | Alice |
| displayName | Alice Hansen |
| password | %alt1% |
And user "Alice" has created the following folders
| path |
| folder-to-delete |
| folder-to-restore |
And user "Alice" has uploaded file with content "test file" to "testfile.txt"
And user "Alice" has deleted the following resources
| path |
| folder-to-delete |
| folder-to-restore |
| testfile.txt |
And user "Alice" has restored the folder with original path "folder-to-restore"
And user "Alice" has deleted the folder with original path "folder-to-delete" from the trashbin
And the administrator has stopped the server
When the administrator deletes the empty trashbin folders using the CLI
Then the command should be successful