Skip to content

Commit

Permalink
Merge pull request #34253 from owncloud/fix-theUserOpensTheFileOrFold…
Browse files Browse the repository at this point in the history
…erUsingTheWebUI

Fix theUserOpensTheFileOrFolderUsingTheWebUI so it opens a file
  • Loading branch information
Vincent Petry authored Jan 25, 2019
2 parents cdce56b + d2a288b commit 55c4b78
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1195,40 +1195,62 @@ public function theUserOpensFolderNamedUsingTheWebUI(
) {
// The capturing groups of the regex include the quotes at each
// end of the captured string, so trim them.
$this->theUserOpensTheFolderUsingTheWebUI(
$this->theUserOpensTheFileOrFolderUsingTheWebUI(
$typeOfFilesPage, $fileOrFolder, \trim($name, $name[0])
);
}

/**
* Open a file or folder in the current folder, or in a path down from the
* current folder.
*
* @param string $typeOfFilesPage
* @param string $fileOrFolder
* @param string|array $name
* @param string $fileOrFolder "file" or "folder" - the type of the final item
* to open
* @param string|array $relativePath the path from the currently open folder
* down to and including the file or folder
* to open
*
* @return void
* @throws \Exception
*/
public function theUserOpensTheFolderUsingTheWebUI(
$typeOfFilesPage, $fileOrFolder, $name
public function theUserOpensTheFileOrFolderUsingTheWebUI(
$typeOfFilesPage, $fileOrFolder, $relativePath
) {
if ($typeOfFilesPage === "trashbin") {
$this->theUserBrowsesToTheTrashbinPage();
}

$pageObject = $this->getCurrentPageObject();
if ($fileOrFolder === "folder") {
if (\is_array($name)) {
$this->currentFolder .= "/" . \implode($name);
$pageObject->openFile($name, $this->getSession());
$pageObject->waitTillPageIsLoaded($this->getSession());
} else {
$name = \ltrim($name, '/');
$this->currentFolder .= "/$name";
$folderBreadCrumbs = \explode('/', $name);
foreach ($folderBreadCrumbs as $folder) {
$pageObject->openFile($folder, $this->getSession());
$pageObject->waitTillPageIsLoaded($this->getSession());
}
}

if (\is_array($relativePath)) {
// Store the single full concatenated file or folder name.
$breadCrumbs[] = \implode($relativePath);
// The passed-in path is itself an array of pieces of a single file
// or folder name. That is done when the file or folder name contains
// both single and double quotes. The pieces of the file or folder
// name need to be passed through to openFile still in array form.
$breadCrumbsForOpenFile[] = $relativePath;
} else {
// The passed-in path is a single string representing the path to
// the item to be opened. Each folder along the way is delimited
// by "/". Explode it into an array of items to be opened.
$breadCrumbs = \explode('/', \ltrim($relativePath, '/'));
$breadCrumbsForOpenFile = $breadCrumbs;
}

foreach ($breadCrumbsForOpenFile as $breadCrumb) {
$pageObject->openFile($breadCrumb, $this->getSession());
$pageObject->waitTillPageIsLoaded($this->getSession());
}

if ($fileOrFolder !== "folder") {
// Pop the file name off the end of the array of breadcrumbs
\array_pop($breadCrumbs);
}

if (\count($breadCrumbs)) {
$this->currentFolder .= "/" . \implode('/', $breadCrumbs);
}
}

Expand Down Expand Up @@ -1345,7 +1367,7 @@ public function checkIfFileFolderIsListedOnTheWebUI(
$pageObject = $this->getCurrentPageObject();
$pageObject->waitTillPageIsLoaded($this->getSession());
if ($folder !== "") {
$this->theUserOpensTheFolderUsingTheWebUI(
$this->theUserOpensTheFileOrFolderUsingTheWebUI(
$typeOfFilesPage, "folder", $folder
);
}
Expand Down Expand Up @@ -1436,7 +1458,7 @@ public function checkIfFileFolderIsListedOnTheWebUI(
public function theMovedElementsShouldBeListedInFolderOnTheWebUI(
$shouldOrNot, $folderName
) {
$this->theUserOpensTheFolderUsingTheWebUI("", "folder", $folderName);
$this->theUserOpensTheFileOrFolderUsingTheWebUI("", "folder", $folderName);
$this->getCurrentPageObject()->waitTillPageIsLoaded($this->getSession());
$this->theDeletedMovedElementsShouldBeListedOnTheWebUI($shouldOrNot);
}
Expand All @@ -1460,7 +1482,7 @@ public function theFollowingFileFolderShouldBeListedInTheFollowingFolderOnTheWeb
$folderNameParts[] = $namePartsRow['folder-name-parts'];
$toBeListedTableArray[] = [$namePartsRow['item-name-parts']];
}
$this->theUserOpensTheFolderUsingTheWebUI("", "folder", $folderNameParts);
$this->theUserOpensTheFileOrFolderUsingTheWebUI("", "folder", $folderNameParts);
$this->getCurrentPageObject()->waitTillPageIsLoaded($this->getSession());

$toBeListedTable = new TableNode($toBeListedTableArray);
Expand Down

0 comments on commit 55c4b78

Please sign in to comment.