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] refactor When steps and step defns while moving, copying and renaming files and folders #10558

Merged
merged 1 commit into from
Nov 20, 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
57 changes: 41 additions & 16 deletions tests/acceptance/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1997,31 +1997,22 @@ public function copyFilesAndFoldersRequest(string $user, string $fullUrl, array
}

/**
* @When /^user "([^"]*)" (copies|moves|renames) a file "([^"]*)" into "([^"]*)" inside space "([^"]*)" using file-id "([^"]*)"$/
* @When /^user "([^"]*)" (copies|moves) 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 $toSpaceName
* @param string $fileId
*
* @throws GuzzleException
* @return void
*/
public function userCopiesMovesFileIntoInsideSpaceUsingFileId(string $user, string $actionType, string $sourceFile, string $destinationFile, string $toSpaceName, string $fileId): void {
// split the source when there are sub-folders
$sourceFile = \trim($sourceFile, "/");
$sourceFile = \explode("/", $sourceFile);
$sourceFile = \end($sourceFile);
public function userCopiesOrMovesFileWithIdAsIntoFolderInsideSpace(string $user, string $actionType, string $fileId, string $destinationFile, string $destinationFolder, string $toSpaceName): void {
$destinationFile = \trim($destinationFile, "/");
$fileDestination = '';
if ($actionType === 'copies' || $actionType === 'moves') {
$fileDestination = $this->escapePath($destinationFile) . '/' . $this->escapePath($sourceFile);
} elseif ($actionType === 'renames') {
$fileDestination = $destinationFile;
}

$destinationFolder = \trim($destinationFolder, "/");
$fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile);
$baseUrl = $this->featureContext->getBaseUrl();
$sourceDavPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
if ($toSpaceName === 'Shares') {
Expand All @@ -2034,11 +2025,45 @@ public function userCopiesMovesFileIntoInsideSpaceUsingFileId(string $user, stri
$fullUrl = "$baseUrl/$sourceDavPath/$fileId";
if ($actionType === 'copies') {
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
} elseif ($actionType === 'moves' || $actionType === 'renames') {
} else {
$this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers));
}
}

/**
* @Given /^user "([^"]*)" renames file with id "([^"]*)" to "([^"]*)" inside space "([^"]*)"$/
*
* @param string $user
* @param string $fileId
* @param string $destinationFile
* @param string $spaceName
*
* @throws GuzzleException
* @return void
*/
public function userRenamesFileWithIdToInsideSpace(
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";
$this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers));
}

/**
* @Given /^user "([^"]*)" has (copied|moved) file with id "([^"]*)" as "([^"]*)" into folder "([^"]*)" inside space "([^"]*)"$/
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: copying file using file id
Given user "Alice" has created folder "/folder"
And user "Alice" has uploaded file with content "some data" to "/textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "/textfile.txt" into "/folder" inside space "Personal" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "/textfile.txt" into folder "/folder" inside space "Personal"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "Personal" should contain these files:
| textfile.txt |
Expand All @@ -25,7 +25,7 @@ Feature: copying file using file id
And user "Alice" has created folder "folder/sub-folder"
And user "Alice" has uploaded file with content "some data" to "/textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "/textfile.txt" into "/folder/sub-folder" inside space "Personal" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "textfile.txt" into folder "/folder/sub-folder" inside space "Personal"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "Personal" should contain these files:
| textfile.txt |
Expand All @@ -37,7 +37,7 @@ Feature: copying file using file id
Given user "Alice" has created folder "/folder"
And user "Alice" has uploaded file with content "some data" to "folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "folder/textfile.txt" into "/" inside space "Personal" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "textfile.txt" into folder "/" inside space "Personal"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "Personal" should contain these files:
| textfile.txt |
Expand All @@ -50,7 +50,7 @@ Feature: copying file using file id
And user "Alice" has created folder "folder/sub-folder"
And user "Alice" has uploaded file with content "some data" to "folder/sub-folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "folder/sub-folder/textfile.txt" into "/" inside space "Personal" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "/textfile.txt" into folder "/" inside space "Personal"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "Personal" should contain these files:
| textfile.txt |
Expand All @@ -64,7 +64,7 @@ Feature: copying file using file id
And user "Alice" has created a folder "/folder" in space "project-space"
And user "Alice" has uploaded a file inside space "project-space" with content "some data" to "textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "/textfile.txt" into "/folder" inside space "project-space" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "/textfile.txt" into folder "/folder" inside space "project-space"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand All @@ -78,7 +78,7 @@ Feature: copying file using file id
And user "Alice" has created a folder "folder/sub-folder" in space "project-space"
And user "Alice" has uploaded a file inside space "project-space" with content "some data" to "textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "/textfile.txt" into "/folder/sub-folder" inside space "project-space" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "/textfile.txt" into folder "/folder/sub-folder" inside space "project-space"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand All @@ -92,7 +92,7 @@ Feature: copying file using file id
And user "Alice" has created a folder "folder" in space "project-space"
And user "Alice" has uploaded a file inside space "project-space" with content "some data" to "folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "folder/textfile.txt" into "/" inside space "project-space" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "textfile.txt" into folder "/" inside space "project-space"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand All @@ -106,7 +106,7 @@ Feature: copying file using file id
And user "Alice" has created a folder "folder/sub-folder" in space "project-space"
And user "Alice" has uploaded a file inside space "project-space" with content "some data" to "folder/sub-folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "folder/sub-folder/textfile.txt" into "/" inside space "project-space" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "textfile.txt" into folder "/" inside space "project-space"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand All @@ -119,7 +119,7 @@ Feature: copying file using file id
And user "Alice" has created a space "project-space" with the default quota using the Graph API
And user "Alice" has uploaded file with content "some data" to "textfile.txt"
And we save it into "FILEID"
When user "Alice" copies a file "/textfile.txt" into "/" inside space "project-space" using file-id "<<FILEID>>"
When user "Alice" copies file with id "<<FILEID>>" as "/textfile.txt" into folder "/" inside space "project-space"
Then the HTTP status code should be "201"
And for user "Alice" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand All @@ -140,7 +140,7 @@ Feature: copying file using file id
| shareType | user |
| permissionsRole | Editor |
And user "Brian" has a share "folder" synced
When user "Brian" copies a file "Shares/folder/sub-folder/test.txt" into "Shares/folder" inside space "Shares" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "test.txt" into folder "Shares/folder" inside space "Shares"
Then the HTTP status code should be "201"
And for user "Brian" folder "folder" of the space "Shares" should contain these files:
| test.txt |
Expand All @@ -165,7 +165,7 @@ Feature: copying file using file id
And user "Brian" has uploaded file with content "some data" to "/test.txt"
And we save it into "FILEID"
And user "Brian" has a share "folder" synced
When user "Brian" copies a file "/test.txt" into "Shares/folder" inside space "Shares" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "/test.txt" into folder "Shares/folder" inside space "Shares"
Then the HTTP status code should be "201"
And for user "Brian" folder "folder" of the space "Shares" should contain these files:
| test.txt |
Expand All @@ -187,7 +187,7 @@ Feature: copying file using file id
| shareType | user |
| permissionsRole | <permission-role> |
And user "Brian" has a share "folder" synced
When user "Brian" copies a file "/test.txt" into "/" inside space "Personal" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "/test.txt" into folder "/" inside space "Personal"
Then the HTTP status code should be "201"
And for user "Brian" folder "folder" of the space "Shares" should contain these files:
| test.txt |
Expand Down Expand Up @@ -215,7 +215,7 @@ Feature: copying file using file id
| shareType | user |
| permissionsRole | Secure Viewer |
And user "Brian" has a share "folder" synced
When user "Brian" copies a file "/test.txt" into "/" inside space "Personal" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "/test.txt" into folder "/" inside space "Personal"
Then the HTTP status code should be "403"
And for user "Brian" folder "folder" of the space "Shares" should contain these files:
| test.txt |
Expand All @@ -242,7 +242,7 @@ Feature: copying file using file id
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
When user "Brian" copies a file "Shares/folder/test.txt" into "/" inside space "project-space" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "test.txt" into folder "/" inside space "project-space"
Then the HTTP status code should be "201"
And for user "Brian" folder "folder" of the space "Shares" should contain these files:
| test.txt |
Expand Down Expand Up @@ -280,7 +280,7 @@ Feature: copying file using file id
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
When user "Brian" copies a file "Shares/folder/test.txt" into "/" inside space "project-space" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "/test.txt" into folder "/" inside space "project-space"
Then the HTTP status code should be "403"
And for user "Brian" folder "folder" of the space "Shares" should contain these files:
| test.txt |
Expand Down Expand Up @@ -318,7 +318,7 @@ Feature: copying file using file id
| shareType | user |
| permissionsRole | <to-share-role> |
And user "Brian" has a share "share2" synced
When user "Brian" copies a file "Shares/share1/test.txt" into "share2" inside space "Shares" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "/test.txt" into folder "share2" inside space "Shares"
Then the HTTP status code should be "201"
And for user "Brian" folder "share1" of the space "Shares" should contain these files:
| test.txt |
Expand Down Expand Up @@ -359,7 +359,7 @@ Feature: copying file using file id
| shareType | user |
| permissionsRole | <to-share-role> |
And user "Brian" has a share "share2" synced
When user "Brian" copies a file "Shares/share1/test.txt" into "share2" inside space "Shares" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "test.txt" into folder "share2" inside space "Shares"
Then the HTTP status code should be "403"
And for user "Brian" folder "share1" of the space "Shares" should contain these files:
| test.txt |
Expand Down Expand Up @@ -394,7 +394,7 @@ Feature: copying file using file id
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
When user "Brian" copies a file "/textfile.txt" into "/" inside space "Personal" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "/textfile.txt" into folder "/" inside space "Personal"
Then the HTTP status code should be "201"
And for user "Brian" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand Down Expand Up @@ -424,7 +424,7 @@ Feature: copying file using file id
| sharee | Brian |
| shareType | user |
| permissionsRole | <to-space-role> |
When user "Brian" copies a file "textfile.txt" into "/" inside space "second-project-space" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "textfile.txt" into folder "/" inside space "second-project-space"
Then the HTTP status code should be "201"
And for user "Brian" the space "second-project-space" should contain these entries:
| textfile.txt |
Expand Down Expand Up @@ -459,7 +459,7 @@ Feature: copying file using file id
| sharee | Brian |
| shareType | user |
| permissionsRole | <to-space-role> |
When user "Brian" copies a file "textfile.txt" into "/" inside space "second-project-space" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "textfile.txt" into folder "/" inside space "second-project-space"
Then the HTTP status code should be "403"
And for user "Brian" the space "second-project-space" should not contain these entries:
| textfile.txt |
Expand Down Expand Up @@ -493,7 +493,7 @@ Feature: copying file using file id
| shareType | user |
| permissionsRole | <permissions> |
And user "Brian" has a share "testshare" synced
When user "Brian" copies a file "textfile.txt" into "testshare" inside space "Shares" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "textfile.txt" into folder "testshare" inside space "Shares"
Then the HTTP status code should be "201"
And for user "Brian" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand Down Expand Up @@ -531,7 +531,7 @@ Feature: copying file using file id
| shareType | user |
| permissionsRole | <permissions> |
And user "Brian" has a share "testshare" synced
When user "Brian" copies a file "textfile.txt" into "testshare" inside space "Shares" using file-id "<<FILEID>>"
When user "Brian" copies file with id "<<FILEID>>" as "textfile.txt" into folder "testshare" inside space "Shares"
Then the HTTP status code should be "403"
And for user "Brian" folder "/" of the space "project-space" should contain these files:
| textfile.txt |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Feature: checking file versions using file id
And user "Alice" has uploaded file with content "some data - edited" to "<source>textfile.txt"
And we save it into "FILEID"
And using spaces DAV path
When user "Alice" moves a file "<source>textfile.txt" into "<destination>" inside space "Personal" using file-id "<<FILEID>>"
When user "Alice" moves file with id "<<FILEID>>" as "textfile.txt" into folder "<destination>" inside space "Personal"
Then the HTTP status code should be "201"
When user "Alice" gets the number of versions of file "<destination>textfile.txt" using file-id "<<FILEID>>"
Then the HTTP status code should be "207"
Expand Down Expand Up @@ -156,7 +156,7 @@ Feature: checking file versions using file id
And user "Alice" has uploaded a file inside space "Project1" with content "some data" to "<source>textfile.txt"
And user "Alice" has uploaded a file inside space "Project1" with content "some data - edited" to "<source>textfile.txt"
And we save it into "FILEID"
When user "Alice" moves a file "<source>textfile.txt" into "<destination>" inside space "Project1" using file-id "<<FILEID>>"
When user "Alice" moves file with id "<<FILEID>>" as "textfile.txt" into folder "<destination>" inside space "Project1"
Then the HTTP status code should be "201"
When user "Alice" gets the number of versions of file "<destination>textfile.txt" using file-id "<<FILEID>>"
Then the HTTP status code should be "207"
Expand Down
Loading