Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adjust acceptance tests to changes in new folder creation
Before, to create a new folder, the name of the folder was set in the
menu item and then the folder was created. Now the new folder is created
with a default name and, once it appears in the file list, its name is
in editable mode to set the desired one.

The default folder name is not "New folder" but "New folder (X)" if
there was already a folder named "New folder", so "New folder" can not
be used to look for the new entry. However, there will be only one file
list entry with an editable name at each time, so that is used instead
to look for the new entry after the new folder is created.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and szaimen committed Apr 19, 2022
commit 4d0e9d559fbea60ec3cababd73709f2a0911417d
53 changes: 33 additions & 20 deletions tests/acceptance/features/bootstrap/FileListContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,6 @@ public static function createNewFolderMenuItem($fileListAncestor) {
return self::createMenuItemFor($fileListAncestor, "New folder");
}

/**
* @return Locator
*/
public static function createNewFolderMenuItemNameInput($fileListAncestor) {
return Locator::forThe()->css(".filenameform input[type=text]")->
descendantOf(self::createNewFolderMenuItem($fileListAncestor))->
describedAs("Name input in create new folder menu item in file list");
}

/**
* @return Locator
*/
public static function createNewFolderMenuItemConfirmButton($fileListAncestor) {
return Locator::forThe()->css(".filenameform input[type=submit]")->
descendantOf(self::createNewFolderMenuItem($fileListAncestor))->
describedAs("Confirm button in create new folder menu item in file list");
}

/**
* @return Locator
*/
Expand Down Expand Up @@ -200,6 +182,15 @@ public static function rowForFilePreceding($fileListAncestor, $fileName1, $fileN
describedAs("Row for file $fileName1 preceding $fileName2 in file list");
}

/**
* @return Locator
*/
public static function rowForFileWithEditableName($fileListAncestor) {
return Locator::forThe()->xpath("//*[@id = 'fileList']//input[contains(concat(' ', normalize-space(@class), ' '), ' filename ')]/ancestor::tr")->
descendantOf($fileListAncestor)->
describedAs("Row for file with editable name in file list");
}

/**
* @return Locator
*/
Expand Down Expand Up @@ -265,6 +256,15 @@ public static function renameInputForFile($fileListAncestor, $fileName) {
describedAs("Rename input for file $fileName in file list");
}

/**
* @return Locator
*/
public static function renameInputForFileWithEditableName($fileListAncestor) {
return Locator::forThe()->css("input.filename")->
descendantOf(self::rowForFileWithEditableName($fileListAncestor))->
describedAs("Rename input for file with editable name in file list");
}

/**
* @return Locator
*/
Expand Down Expand Up @@ -365,8 +365,21 @@ public function iCreateANewFolderNamed($folderName) {
$this->actor->find(self::createMenuButton($this->fileListAncestor), 10)->click();

$this->actor->find(self::createNewFolderMenuItem($this->fileListAncestor), 2)->click();
$this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName);
$this->actor->find(self::createNewFolderMenuItemConfirmButton($this->fileListAncestor), 2)->click();

// The name of the new folder is not guaranteed to be "New folder" (it
// could be "New folder (2)" if there is another folder with that name),
// so the row to be used is the one currently with an editable name.
//
// For reference, due to a bug in the Firefox driver of Selenium and/or
// maybe in Firefox itself, as a range is selected in the rename input
// (the name of the file, without its extension) when the value is set
// the window must be in the foreground. Otherwise, if the window is in
// the background, instead of setting the value in the whole field it
// would be set only in the selected range.
// This should not be a problem, though, as the default behaviour is to
// bring the browser window to the foreground when switching to a
// different actor.
$this->actor->find(self::renameInputForFileWithEditableName($this->fileListAncestor), 10)->setValue($folderName);
}

/**
Expand Down