Add acceptance tests for moving and copying files to another folder

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-12-21 13:44:41 +01:00
parent dbc184c859
commit 4fcabf167e
4 changed files with 178 additions and 0 deletions

View File

@ -15,6 +15,7 @@ default:
- DialogContext - DialogContext
- FeatureContext - FeatureContext
- FileListContext - FileListContext
- FilePickerContext
- FilesAppContext - FilesAppContext
- FilesAppSharingContext - FilesAppSharingContext
- LoginPageContext - LoginPageContext
@ -43,6 +44,7 @@ default:
- DialogContext - DialogContext
- FeatureContext - FeatureContext
- FileListContext - FileListContext
- FilePickerContext
- FilesAppContext - FilesAppContext
- FilesAppSharingContext - FilesAppSharingContext
- LoginPageContext - LoginPageContext

View File

@ -140,6 +140,29 @@ Feature: app-files
Then I see that the current section is "Deleted files" Then I see that the current section is "Deleted files"
Then I see that the file list contains a file named "welcome.txt" 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: 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: rename a file with the details view open Scenario: rename a file with the details view open
Given I am logged in Given I am logged in
And I open the details view for "welcome.txt" And I open the details view for "welcome.txt"

View File

@ -265,6 +265,13 @@ class FileListContext implements Context, ActorAwareInterface {
return self::fileActionsMenuItemFor("Rename"); return self::fileActionsMenuItemFor("Rename");
} }
/**
* @return Locator
*/
public static function moveOrCopyMenuItem() {
return self::fileActionsMenuItemFor("Move or copy");
}
/** /**
* @return Locator * @return Locator
*/ */
@ -325,6 +332,15 @@ class FileListContext implements Context, ActorAwareInterface {
$this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2 . "\r"); $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 * @Given I mark :fileName as favorite
*/ */
@ -410,6 +426,18 @@ class FileListContext implements Context, ActorAwareInterface {
PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10)); 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 * @Then I see that :fileName1 precedes :fileName2 in the file list
*/ */

View File

@ -0,0 +1,125 @@
<?php
/**
*
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
use Behat\Behat\Context\Context;
class FilePickerContext implements Context, ActorAwareInterface {
use ActorAware;
/**
* @return Locator
*/
public static function dialog() {
return Locator::forThe()->css(".oc-dialog")->
describedAs("File picker dialog");
}
/**
* @return Locator
*/
public static function fileListContainer() {
return Locator::forThe()->css("#oc-dialog-filepicker-content")->
descendantOf(self::dialog())->
describedAs("File list container in the file picker dialog");
}
/**
* @return Locator
*/
public static function rowForFile($fileName) {
return Locator::forThe()->xpath("//*[@id = 'picker-filestable']//*[contains(concat(' ', normalize-space(@class), ' '), ' filename ') and normalize-space() = '$fileName']/ancestor::tr")->
descendantOf(self::fileListContainer())->
describedAs("Row for file $fileName in the file picker dialog");
}
/**
* @return Locator
*/
public static function buttonRow() {
return Locator::forThe()->css(".oc-dialog-buttonrow")->
descendantOf(self::dialog())->
describedAs("Button row in the file picker dialog");
}
/**
* @return Locator
*/
private static function buttonFor($buttonText) {
// "Copy" and "Move" buttons text is set to "Copy to XXX" and "Move to
// XXX" when a folder is selected.
return Locator::forThe()->xpath("//button[starts-with(normalize-space(), '$buttonText')]")->
descendantOf(self::buttonRow())->
describedAs($buttonText . " button in the file picker dialog");
}
/**
* @return Locator
*/
public static function copyButton() {
return self::buttonFor("Copy");
}
/**
* @return Locator
*/
public static function moveButton() {
return self::buttonFor("Move");
}
/**
* @return Locator
*/
public static function chooseButton() {
return self::buttonFor("Choose");
}
/**
* @When I select :fileName in the file picker
*/
public function iSelectInTheFilePicker($fileName) {
$this->actor->find(self::rowForFile($fileName), 10)->click();
}
/**
* @When I copy to the last selected folder in the file picker
*/
public function iCopyToTheLastSelectedFolderInTheFilePicker() {
$this->actor->find(self::copyButton(), 10)->click();
}
/**
* @When I move to the last selected folder in the file picker
*/
public function iMoveToTheLastSelectedFolderInTheFilePicker() {
$this->actor->find(self::moveButton(), 10)->click();
}
/**
* @When I choose the last selected file in the file picker
*/
public function iChooseTheLastSelectedFileInTheFilePicker() {
$this->actor->find(self::chooseButton(), 10)->click();
}
}