diff --git a/tests/ui/features/bootstrap/LoginContext.php b/tests/ui/features/bootstrap/LoginContext.php index 5f0fc25c0747..646b31a18e30 100644 --- a/tests/ui/features/bootstrap/LoginContext.php +++ b/tests/ui/features/bootstrap/LoginContext.php @@ -35,6 +35,7 @@ class LoginContext extends RawMinkContext implements Context { private $loginPage; private $filesPage; + private $expectedPage; private $featureContext; public function __construct(LoginPage $loginPage) @@ -59,6 +60,24 @@ public function iLoginWithUsernameAndPassword($username, $password) $this->filesPage->waitTillPageIsLoaded($this->getSession()); } + /** + * @When I login with username :username and invalid password :password + */ + public function iLoginWithUsernameAndInvalidPassword($username, $password) + { + $this->loginPage->loginAs($username, $password, 'LoginPage'); + $this->loginPage->waitTillPageIsLoaded($this->getSession()); + } + + /** + * @When I login with username :username and password :password after a redirect from the :page page + */ + public function iLoginWithUsernameAndPasswordAfterRedirectFromThePage($username, $password, $page) + { + $this->expectedPage = $this->loginPage->loginAs($username, $password, str_replace(' ', '', ucwords($page)) . 'Page'); + $this->expectedPage->waitTillPageIsLoaded($this->getSession()); + } + /** * @When I login as a regular user with a correct password */ diff --git a/tests/ui/features/bootstrap/PersonalGeneralSettingsContext.php b/tests/ui/features/bootstrap/PersonalGeneralSettingsContext.php index e5fe1348917b..fdd55764e435 100644 --- a/tests/ui/features/bootstrap/PersonalGeneralSettingsContext.php +++ b/tests/ui/features/bootstrap/PersonalGeneralSettingsContext.php @@ -47,6 +47,15 @@ public function iAmOnThePersonalGeneralSettingsPage() $this->personalGeneralSettingsPage->waitForOutstandingAjaxCalls($this->getSession()); } + /** + * @Given I go to the personal general settings page + */ + public function iGoToThePersonalGeneralSettingsPage() + { + $this->visitPath($this->personalGeneralSettingsPage->getPagePath()); + $this->personalGeneralSettingsPage->waitForOutstandingAjaxCalls($this->getSession()); + } + /** * @When I change the language to :language */ diff --git a/tests/ui/features/lib/LoginPage.php b/tests/ui/features/lib/LoginPage.php index 350d5cd4af84..d292641fac09 100644 --- a/tests/ui/features/lib/LoginPage.php +++ b/tests/ui/features/lib/LoginPage.php @@ -23,6 +23,7 @@ namespace Page; use SensioLabs\Behat\PageObjectExtension\PageObject\Page; +use Behat\Mink\Session; class LoginPage extends OwncloudPage { @@ -30,12 +31,31 @@ class LoginPage extends OwncloudPage * @var string $path */ protected $path = '/index.php/login'; + protected $userInputId = "user"; + protected $passwordInputId = "password"; - public function loginAs($username, $password) + public function loginAs($username, $password, $target='FilesPage') { - $this->fillField("user", $username); - $this->fillField("password", $password); + $this->fillField($this->userInputId, $username); + $this->fillField($this->passwordInputId, $password); $this->findById("submit")->click(); - return $this->getPage('FilesPage'); + return $this->getPage($target); + } + + //there is no reliable loading indicator on the login page, so just wait for + //the user and password to be there. + public function waitTillPageIsLoaded(Session $session, $timeout_msec=STANDARDUIWAITTIMEOUTMILLISEC) + { + $currentTime = microtime(true); + $end = $currentTime + ($timeout_msec / 1000); + while ($currentTime <= $end) { + if (($this->findById($this->userInputId) !== null) && + ($this->findById($this->passwordInputId) !== null)) { + break; + } + usleep(STANDARDSLEEPTIMEMICROSEC); + $currentTime = microtime(true); + } + $this->waitForOutstandingAjaxCalls($session); } } \ No newline at end of file diff --git a/tests/ui/features/lib/OwncloudPage.php b/tests/ui/features/lib/OwncloudPage.php index cffe6ada1a9e..10a8204f68df 100644 --- a/tests/ui/features/lib/OwncloudPage.php +++ b/tests/ui/features/lib/OwncloudPage.php @@ -38,11 +38,13 @@ public function waitTillPageIsLoaded(Session $session, $timeout_msec=STANDARDUIW $end = $currentTime + ($timeout_msec / 1000); while ($currentTime <= $end) { $loadingIndicator=$this->find("css", '.loading'); - $visibility = $this->elementHasCSSValue( - $loadingIndicator, 'visibility', 'visible' - ); - if ($visibility===FALSE) { - break; + if (!is_null($loadingIndicator)) { + $visibility = $this->elementHasCSSValue( + $loadingIndicator, 'visibility', 'visible' + ); + if ($visibility===FALSE) { + break; + } } usleep(STANDARDSLEEPTIMEMICROSEC); $currentTime = microtime(true); @@ -118,6 +120,14 @@ public function getMyUsername() { return $this->findById($this->userNameDispayId)->getText(); } + /** + * return the path to the relevant page + * @return string + */ + public function getPagePath() { + return $this->getPath(); + } + /** * Gets the Coordinates of a Mink Element * diff --git a/tests/ui/features/lib/PersonalGeneralSettingsPage.php b/tests/ui/features/lib/PersonalGeneralSettingsPage.php index 9239937ad3d0..17efb8b3c901 100644 --- a/tests/ui/features/lib/PersonalGeneralSettingsPage.php +++ b/tests/ui/features/lib/PersonalGeneralSettingsPage.php @@ -23,6 +23,7 @@ namespace Page; use SensioLabs\Behat\PageObjectExtension\PageObject\Page; +use Behat\Mink\Session; class PersonalGeneralSettingsPage extends OwncloudPage { @@ -32,9 +33,26 @@ class PersonalGeneralSettingsPage extends OwncloudPage */ protected $path = '/index.php/settings/personal?sectionid=general'; protected $languageSelectId = "languageinput"; + protected $personalProfilePanelId = "OC\Settings\Panels\Personal\Profile"; public function changeLanguage($language) { $this->selectFieldOption($this->languageSelectId, $language); } + + //there is no reliable loading indicator on the personal general settings page, so just wait for + //the personal profile panel to be there. + public function waitTillPageIsLoaded(Session $session, $timeout_msec=STANDARDUIWAITTIMEOUTMILLISEC) + { + $currentTime = microtime(true); + $end = $currentTime + ($timeout_msec / 1000); + while ($currentTime <= $end) { + if ($this->findById($this->personalProfilePanelId) !== null) { + break; + } + usleep(STANDARDSLEEPTIMEMICROSEC); + $currentTime = microtime(true); + } + $this->waitForOutstandingAjaxCalls($session); + } } \ No newline at end of file diff --git a/tests/ui/features/login.feature b/tests/ui/features/login.feature index 949e6a7f64c5..c69c68fb9b97 100644 --- a/tests/ui/features/login.feature +++ b/tests/ui/features/login.feature @@ -9,4 +9,24 @@ Feature: login Scenario: admin login Given I am on the login page When I login with username "admin" and password "admin" - Then I should be redirected to a page with the title "Files - ownCloud" \ No newline at end of file + Then I should be redirected to a page with the title "Files - ownCloud" + + Scenario: admin login with invalid password + Given I am on the login page + When I login with username "admin" and invalid password "invalidpassword" + Then I should be redirected to a page with the title "ownCloud" + + Scenario: access the personal general settings page when not logged in + Given I go to the personal general settings page + Then I should be redirected to a page with the title "ownCloud" + When I login with username "admin" and password "admin" after a redirect from the "personal general settings" page + Then I should be redirected to a page with the title "Settings - ownCloud" + + @skip @entering-the-wrong-password-breaks-the-redirect-issue-28129 + Scenario: access the personal general settings page when not logged in using incorrect then correct password + Given I go to the personal general settings page + Then I should be redirected to a page with the title "ownCloud" + When I login with username "admin" and invalid password "qwerty" + Then I should be redirected to a page with the title "ownCloud" + When I login with username "admin" and password "admin" after a redirect from the "personal general settings" page + Then I should be redirected to a page with the title "Settings - ownCloud"