Skip to content
Closed
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
5 changes: 5 additions & 0 deletions tests/preseed-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'writable' => true,
],
],
'default_language' => 'en',
];

if (is_dir(OC::$SERVERROOT.'/apps2')) {
Expand All @@ -21,3 +22,7 @@
if (substr(strtolower(PHP_OS), 0, 3) === 'win') {
$CONFIG['openssl'] = ['config' => OC::$SERVERROOT . '/tests/data/openssl.cnf'];
}

if (getenv("TC") === "selenium") {
$CONFIG['skeletondirectory'] = OC::$SERVERROOT . '/tests/ui/skeleton';
}
6 changes: 6 additions & 0 deletions tests/ui/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ default:
default:
paths:
- %paths.base%/../features
context:
parameters:
ocPath: ./
regularUserPassword: 123456
regularUserName: regularuser
regularUserNames: user1,user2,user3,user4,user5
contexts:
- FeatureContext:
- LoginContext:
Expand Down
129 changes: 129 additions & 0 deletions tests/ui/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/**
* ownCloud
*
* @author Artur Neumann
* @copyright 2017 Artur Neumann [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*
*/

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Hook\Scope\AfterScenarioScope;
use Page\LoginPage;

require_once 'bootstrap.php';

/**
* Features context.
*/
trait BasicStructure
{
private $regularUserPassword;
private $regularUserName;
private $regularUserNames = array();
private $createdUserNames = array();
private $ocPath;

/**
* @Given I am logged in as admin
*/
public function iAmLoggedInAsAdmin()
{
$this->loginPage->open();
$this->filesPage = $this->loginPage->loginAs("admin", "admin");
$this->filesPage->waitTillPageIsloaded(10);
}

/**
* @Given I am logged in as a regular user
*/
public function iAmLoggedInAsARegularUser()
{
$this->loginPage->open();
$this->filesPage = $this->loginPage->loginAs($this->regularUserName, $this->regularUserPassword);
$this->filesPage->waitTillPageIsloaded(10);
}

/**
* @Given a regular user exists
*/
public function aRegularUserExists()
{
$user = $this->regularUserName;
$result=SetupHelper::createUser($this->ocPath, $user, $this->regularUserPassword);
if ($result["code"] != 0) {
throw new Exception("could not create user. " . $result["stdOut"] . " " . $result["stdErr"]);
}
array_push($this->createdUserNames, $user);
}

/**
* @Given regular users exist
*/
public function regularUsersExist()
{
foreach ($this->regularUserNames as $user) {
$user = trim($user);
$result=SetupHelper::createUser($this->ocPath, $user, $this->regularUserPassword);
if ($result["code"] != 0) {
throw new Exception("could not create user. " . $result["stdOut"] . " " . $result["stdErr"]);
}
array_push($this->createdUserNames, $user);
}
}

/** @BeforeScenario */
public function setUpScenarioGetRegularUsersList(BeforeScenarioScope $scope)
{
$suiteParameters = $scope->getEnvironment()->getSuite()->getSettings() ['context'] ['parameters'];
$this->regularUserNames = explode(",", $suiteParameters['regularUserNames']);
$this->regularUserName = $suiteParameters['regularUserName'];
$this->regularUserPassword = $suiteParameters['regularUserPassword'];
$this->ocPath = rtrim($suiteParameters['ocPath'], '/') . '/';
}

/** @AfterScenario */
public function tearDownScenarioDeleteCreatedUsers(AfterScenarioScope $scope)
{
foreach ($this->createdUserNames as $user) {
$result=SetupHelper::deleteUser($this->ocPath, $user);
if ($result["code"] != 0) {
throw new Exception("could not delete user. " . $result["stdOut"] . " " . $result["stdErr"]);
}
}
}

public function getRegularUserPassword ()
{
return $this->regularUserPassword;
}

public function getRegularUserName ()
{
return $this->regularUserName;
}

public function getRegularUserNames ()
{
return $this->regularUserNames;
}

public function getCreatedUserNames ()
{
return $this->createdUserNames;
}
}
79 changes: 48 additions & 31 deletions tests/ui/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
<?php
/**
* ownCloud
*
* @author Artur Neumann
* @copyright 2017 Artur Neumann [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*
*/
*
* @author Artur Neumann
* @copyright 2017 Artur Neumann [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*
*/

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode;
use Page\OwncloudPage;
use Page\LoginPage;

Expand All @@ -33,30 +34,24 @@
*/
class FeatureContext extends RawMinkContext implements Context
{
use BasicStructure;

private $owncloudPage;
private $loginPage;

public function __construct(OwncloudPage $owncloudPage, LoginPage $loginPage)
{
$this->owncloudPage = $owncloudPage;
$this->loginPage = $loginPage;
}

/** @BeforeScenario @AdminLogin*/
public function setUpScenario()
{
$this->loginPage->open();
$this->filesPage = $this->loginPage->loginAs("admin", "admin");
$this->filesPage->waitTillPageIsloaded(10);
}


/**
* @Then a notification should be displayed with the text :notificationText
*/
public function aNotificationShouldBeDisplayedWithTheText($notificationText)
{
PHPUnit_Framework_Assert::assertEquals(
$notificationText, $this->owncloudPage->getNotificationText()
$notificationText, $this->owncloudPage->getNotifications()[0]
);
}

Expand All @@ -74,4 +69,26 @@ public function getSessionId(BeforeScenarioScope $scope)
$sessionId = array_pop($parts);
return $sessionId;
}
}

/**
* @Then notifications should be displayed with the text
*/
public function notificationsShouldBeDisplayedWithTheText(TableNode $table)
{
$notifications = $this->owncloudPage->getNotifications();
$tableRows=$table->getRows();
PHPUnit_Framework_Assert::assertEquals(
count($tableRows),
count($notifications)
);

$notificationCounter=0;
foreach ($tableRows as $row) {
PHPUnit_Framework_Assert::assertEquals(
$row[0],
$notifications[$notificationCounter]
);
$notificationCounter++;
}
}
}
61 changes: 50 additions & 11 deletions tests/ui/features/bootstrap/FilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

use Behat\Behat\Context\Context;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Gherkin\Node\TableNode;

use Page\LoginPage;
use Page\FilesPage;

require_once 'bootstrap.php';
Expand All @@ -33,23 +33,21 @@
*/
class FilesContext extends RawMinkContext implements Context
{
private $loginPage;
private $filesPage;
public function __construct(LoginPage $loginPage, FilesPage $filesPage)

public function __construct(FilesPage $filesPage)
{
$this->loginPage = $loginPage;
$this->filesPage = $filesPage;
}

/**
* @Given I am on the files page
*/
public function iAmOnTheFilesPage()
{
$this->filesPage->open();
}

/**
* @Given the list of files\/folders does not fit in one browser page
*/
Expand All @@ -66,7 +64,7 @@ public function theListOfFilesFoldersDoesNotFitInOneBrowserPage()
$this->filesPage->findActionMenuByNo($itemsCount)
);
}

while ($windowHeight > $lastItemCoordinates['top']) {
$this->filesPage->createFolder();
$itemsCount = $this->filesPage->getSizeOfFileFolderList();
Expand All @@ -80,18 +78,59 @@ public function theListOfFilesFoldersDoesNotFitInOneBrowserPage()
}

/**
* @Then The filesactionmenu should be completely visible after clicking on it
* @Given I rename the file/folder :fromName to :toName
*/
public function iRenameTheFileFolderTo($fromName, $toName)
{
$this->filesPage->waitTillPageIsloaded(10);
$this->filesPage->renameFile($fromName, $toName, $this->getSession());
}

/**
* @When I rename the file/folder :fromName to one of these names
*/
public function iRenameTheFileToOneOfThisNames($fromName, TableNode $table)
{
$this->filesPage->waitTillPageIsloaded(10);
foreach ($table->getRows() as $row) {
$this->filesPage->renameFile($fromName, $row[0], $this->getSession());
}

}

/**
* @Then the file/folder :name should be listed
*/
public function theFileFolderShouldBeListed($name)
{
PHPUnit_Framework_Assert::assertNotNull(
$this->filesPage->findFileRowByName($name, $this->getSession())
);
}

/**
* @Then near the file/folder :name a tooltip with the text :toolTipText should be displayed
*/
public function nearTheFileATooltipWithTheTextShouldBeDisplayed($name, $toolTipText)
{
PHPUnit_Framework_Assert::assertEquals($toolTipText,
$this->filesPage->getTooltipOfFile($name, $this->getSession())
);
}

/**
* @Then the filesactionmenu should be completely visible after clicking on it
*/
public function theFilesactionmenuShouldBeCompletelyVisibleAfterClickingOnIt()
{
for ($i = 1; $i < $this->filesPage->getSizeOfFileFolderList(); $i ++) {
$actionMenu = $this->filesPage->findActionMenuByNo($i);
$actionMenu->click();

$windowHeight = $this->filesPage->getWindowHeight(
$this->getSession()
);

$deleteBtnCoordinates = $this->filesPage->getCoordinatesOfElement(
$this->getSession(), $this->filesPage->findDeleteByNo($i)
);
Expand Down
Loading