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] add test to check activities of destination file and folder by moving a file using file-id #10409

Merged
merged 2 commits into from
Nov 14, 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
64 changes: 49 additions & 15 deletions tests/acceptance/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2040,36 +2040,30 @@ 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
*/
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' || $actionType === 'moved') {
$fileDestination = $this->escapePath($destinationFile) . '/' . $this->escapePath($sourceFile);
} else {
$fileDestination = $destinationFile;
}
$destinationFolder = \trim($destinationFolder, "/");

$fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile);

$baseUrl = $this->featureContext->getBaseUrl();
$sourceDavPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
Expand All @@ -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$/
Expand Down Expand Up @@ -3656,14 +3689,15 @@ 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
*
* @return void
*
* @throws GuzzleException
* @throws JsonException
*/
public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(string $user, string $fileOrFolder, string $path, string $spaceName): void {
$this->getSpaceIdByName($user, $spaceName);
Expand Down
Loading