Skip to content
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
2 changes: 2 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ default:
- DialogContext
- FeatureContext
- FileListContext
- FilePickerContext
- FilesAppContext
- FilesAppSharingContext
- LoginPageContext
Expand Down Expand Up @@ -43,6 +44,7 @@ default:
- DialogContext
- FeatureContext
- FileListContext
- FilePickerContext
- FilesAppContext
- FilesAppSharingContext
- LoginPageContext
Expand Down
95 changes: 95 additions & 0 deletions tests/acceptance/features/app-files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,101 @@ Feature: app-files
Then I see that the current section is "Deleted files"
Then I see that the file list contains a file named "welcome.txt"

Scenario: move a file to another folder
Given I am logged in
And I create a new folder named "Destination"
When I start the move or copy operation for "welcome.txt"
And I select "Destination" in the file picker
And I move to the last selected folder in the file picker
Then I see that the file list does not contain a file named "welcome.txt"
And I enter in the folder named "Destination"
And I see that the file list contains a file named "welcome.txt"

Scenario: move a selection to another folder
Given I am logged in
And I create a new folder named "Folder"
And I create a new folder named "Not selected folder"
And I create a new folder named "Destination"
When I select "welcome.txt"
And I select "Folder"
And I start the move or copy operation for the selected files
And I select "Destination" in the file picker
And I move to the last selected folder in the file picker
Then I see that the file list does not contain a file named "welcome.txt"
And I see that the file list does not contain a file named "Folder"
And I see that the file list contains a file named "Not selected folder"
And I enter in the folder named "Destination"
And I see that the file list contains a file named "welcome.txt"
And I see that the file list contains a file named "Folder"
And I see that the file list does not contain a file named "Not selected folder"

Scenario: copy a file to another folder
Given I am logged in
And I create a new folder named "Destination"
When I start the move or copy operation for "welcome.txt"
And I select "Destination" in the file picker
And I copy to the last selected folder in the file picker
Then I enter in the folder named "Destination"
# The file will appear in the destination once the copy operation finishes
And I see that the file list contains a file named "welcome.txt"
# The Files app is open again to reload the file list in the root folder
And I open the Files app
And I see that the file list contains a file named "welcome.txt"

Scenario: copy a selection to another folder
Given I am logged in
And I create a new folder named "Folder"
And I create a new folder named "Not selected folder"
And I create a new folder named "Destination"
When I select "welcome.txt"
And I select "Folder"
And I start the move or copy operation for the selected files
And I select "Destination" in the file picker
And I copy to the last selected folder in the file picker
Then I enter in the folder named "Destination"
# The files will appear in the destination once the copy operation finishes
And I see that the file list contains a file named "welcome.txt"
And I see that the file list contains a file named "Folder"
And I see that the file list does not contain a file named "Not selected folder"
# The Files app is open again to reload the file list in the root folder
And I open the Files app
And I see that the file list contains a file named "welcome.txt"
And I see that the file list contains a file named "Folder"
And I see that the file list contains a file named "Not selected folder"

Scenario: copy a file in its same folder
Given I am logged in
When I start the move or copy operation for "welcome.txt"
# No folder was explicitly selected, so the last selected folder is the
# current folder.
And I copy to the last selected folder in the file picker
Then I see that the file list contains a file named "welcome.txt"
And I see that the file list contains a file named "welcome (copy).txt"

Scenario: copy a file twice in its same folder
Given I am logged in
And I start the move or copy operation for "welcome.txt"
# No folder was explicitly selected, so the last selected folder is the
# current folder.
And I copy to the last selected folder in the file picker
When I start the move or copy operation for "welcome.txt"
And I copy to the last selected folder in the file picker
Then I see that the file list contains a file named "welcome.txt"
And I see that the file list contains a file named "welcome (copy).txt"
And I see that the file list contains a file named "welcome (copy 2).txt"

Scenario: copy a copy of a file in its same folder
Given I am logged in
And I start the move or copy operation for "welcome.txt"
# No folder was explicitly selected, so the last selected folder is the
# current folder.
And I copy to the last selected folder in the file picker
When I start the move or copy operation for "welcome (copy).txt"
And I copy to the last selected folder in the file picker
Then I see that the file list contains a file named "welcome.txt"
And I see that the file list contains a file named "welcome (copy).txt"
And I see that the file list contains a file named "welcome (copy 2).txt"

Scenario: rename a file with the details view open
Given I am logged in
And I open the details view for "welcome.txt"
Expand Down
115 changes: 115 additions & 0 deletions tests/acceptance/features/bootstrap/FileListContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,48 @@ public static function createNewFolderMenuItemNameInput($fileListAncestor) {
describedAs("Name input in create new folder menu item in file list");
}

/**
* @return Locator
*/
public static function fileListHeader($fileListAncestor) {
return Locator::forThe()->css("thead")->
descendantOf($fileListAncestor)->
describedAs("Header in file list");
}

/**
* @return Locator
*/
public static function selectedFilesActionsMenuButton($fileListAncestor) {
return Locator::forThe()->css(".actions-selected")->
descendantOf(self::fileListHeader($fileListAncestor))->
describedAs("Selected files actions menu button in file list");
}

/**
* @return Locator
*/
public static function selectedFilesActionsMenu() {
return Locator::forThe()->css(".filesSelectMenu")->
describedAs("Selected files actions menu in file list");
}

/**
* @return Locator
*/
private static function selectedFilesActionsMenuItemFor($itemText) {
return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")->
descendantOf(self::selectedFilesActionsMenu())->
describedAs($itemText . " item in selected files actions menu in file list");
}

/**
* @return Locator
*/
public static function moveOrCopySelectedFilesMenuItem() {
return self::selectedFilesActionsMenuItemFor("Move or copy");
}

/**
* @return Locator
*/
Expand All @@ -148,6 +190,26 @@ public static function rowForFilePreceding($fileListAncestor, $fileName1, $fileN
describedAs("Row for file $fileName1 preceding $fileName2 in file list");
}

/**
* @return Locator
*/
public static function selectionCheckboxForFile($fileListAncestor, $fileName) {
// Note that the element that the user interacts with is the label, not
// the checbox itself.
return Locator::forThe()->css(".selection label")->
descendantOf(self::rowForFile($fileListAncestor, $fileName))->
describedAs("Selection checkbox for file $fileName in file list");
}

/**
* @return Locator
*/
public static function selectionCheckboxInputForFile($fileListAncestor, $fileName) {
return Locator::forThe()->css(".selection input[type=checkbox]")->
descendantOf(self::rowForFile($fileListAncestor, $fileName))->
describedAs("Selection checkbox input for file $fileName in file list");
}

/**
* @return Locator
*/
Expand Down Expand Up @@ -265,6 +327,13 @@ public static function renameMenuItem() {
return self::fileActionsMenuItemFor("Rename");
}

/**
* @return Locator
*/
public static function moveOrCopyMenuItem() {
return self::fileActionsMenuItemFor("Move or copy");
}

/**
* @return Locator
*/
Expand Down Expand Up @@ -296,6 +365,24 @@ public function iEnterInTheFolderNamed($folderName) {
$this->actor->find(self::mainLinkForFile($this->fileListAncestor, $folderName), 10)->click();
}

/**
* @Given I select :fileName
*/
public function iSelect($fileName) {
$this->iSeeThatIsNotSelected($fileName);

$this->actor->find(self::selectionCheckboxForFile($this->fileListAncestor, $fileName), 10)->click();
}

/**
* @Given I start the move or copy operation for the selected files
*/
public function iStartTheMoveOrCopyOperationForTheSelectedFiles() {
$this->actor->find(self::selectedFilesActionsMenuButton($this->fileListAncestor), 10)->click();

$this->actor->find(self::moveOrCopySelectedFilesMenuItem(), 2)->click();
}

/**
* @Given I open the details view for :fileName
*/
Expand Down Expand Up @@ -325,6 +412,15 @@ public function iRenameTo($fileName1, $fileName2) {
$this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2 . "\r");
}

/**
* @Given I start the move or copy operation for :fileName
*/
public function iStartTheMoveOrCopyOperationFor($fileName) {
$this->actor->find(self::fileActionsMenuButtonForFile($this->fileListAncestor, $fileName), 10)->click();

$this->actor->find(self::moveOrCopyMenuItem(), 2)->click();
}

/**
* @Given I mark :fileName as favorite
*/
Expand Down Expand Up @@ -410,13 +506,32 @@ public function iSeeThatTheFileListContainsAFileNamed($fileName) {
PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10));
}

/**
* @Then I see that the file list does not contain a file named :fileName
*/
public function iSeeThatTheFileListDoesNotContainAFileNamed($fileName) {
if (!WaitFor::elementToBeEventuallyNotShown(
$this->actor,
self::rowForFile($this->fileListAncestor, $fileName),
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
PHPUnit_Framework_Assert::fail("The file list still contains a file named $fileName after $timeout seconds");
}
}

/**
* @Then I see that :fileName1 precedes :fileName2 in the file list
*/
public function iSeeThatPrecedesInTheFileList($fileName1, $fileName2) {
PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFilePreceding($this->fileListAncestor, $fileName1, $fileName2), 10));
}

/**
* @Then I see that :fileName is not selected
*/
public function iSeeThatIsNotSelected($fileName) {
PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::selectionCheckboxInputForFile($this->fileListAncestor, $fileName), 10)->isChecked());
}

/**
* @Then I see that :fileName is marked as favorite
*/
Expand Down
Loading