Add acceptance tests for moving and copying selections to another folder

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2019-01-22 12:36:13 +01:00
parent f8473f4427
commit d4e1e9709f
2 changed files with 126 additions and 0 deletions

View File

@ -150,6 +150,24 @@ Feature: app-files
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"
@ -163,6 +181,27 @@ Feature: app-files
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: rename a file with the details view open
Given I am logged in
And I open the details view for "welcome.txt"

View File

@ -130,6 +130,48 @@ class FileListContext implements Context, ActorAwareInterface {
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
*/
@ -148,6 +190,26 @@ class FileListContext implements Context, ActorAwareInterface {
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
*/
@ -303,6 +365,24 @@ class FileListContext implements Context, ActorAwareInterface {
$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
*/
@ -445,6 +525,13 @@ class FileListContext implements Context, ActorAwareInterface {
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
*/