From 0cec819e450ff89a4105c9cb65b462c4282a2ca6 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Mon, 27 Jun 2016 01:17:08 +0530 Subject: [PATCH] Fix the issue_#29 and issue_#31 --- tests/_support/AcceptanceTester.php | 17 ++- .../Step/Acceptance/Administrator/Content.php | 24 +-- .../Step/Acceptance/Administrator/User.php | 143 +++++++++++++----- tests/acceptance/content.feature | 10 +- tests/acceptance/users.feature | 52 ++++--- 5 files changed, 165 insertions(+), 81 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 872a35ce60..4b8a896cb1 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -60,7 +60,7 @@ public function iSeeAdministratorDashboard() * * @return void */ - public function waitForPageTitle($title, $timeout = 60) + public function waitForPageTitle($title, $timeout = 20) { $I = $this; $I->waitForText($title, $timeout, AdminPage::$pageTitle); @@ -235,4 +235,19 @@ public function doAdministratorLogout() $I->waitForText('Log in', 60, ['xpath' => "//fieldset[@class='loginform']//button"]); } + + /** + * Selects an option in a Joomla Radio Field based on its label + * + * @return void + */ + public function selectOptionInRadioField($label, $option) + { + $I = $this; + $I->comment("Trying to select the $option from the $label"); + $label = $webDriver->findField(['xpath' => "//label[contains(normalize-space(string(.)), '" . $label . "')]"]); + $radioId = $label->getAttribute('for'); + + $I->click(['xpath' => "//fieldset[@id='$radioId']/label[contains(normalize-space(string(.)), '$option')]"]); + } } diff --git a/tests/_support/Step/Acceptance/Administrator/Content.php b/tests/_support/Step/Acceptance/Administrator/Content.php index 50cb09b03f..4290a648ce 100644 --- a/tests/_support/Step/Acceptance/Administrator/Content.php +++ b/tests/_support/Step/Acceptance/Administrator/Content.php @@ -37,12 +37,12 @@ public function iSaveAnArticle() } /** - * @Then I should see the :arg1 message + * @Then I wait for the title :title and see the message :message */ - public function iShouldSeeTheMessage($message) + public function iShouldSeeTheMessage($title, $message) { $I = $this; - $I->waitForPageTitle('Articles'); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } @@ -70,12 +70,12 @@ public function iFeatureTheContentWithTitle() /** * @Then I save and see the :arg1 message */ - public function iSaveAndSeeTheMessage($message) + /*public function iSaveAndSeeTheMessage($message) { $I = $this; - $I->waitForPageTitle('Articles'); + $I->waitForPageTitle($message, AdminPage::$systemMessageContainer); $I->see($message, AdminPage::$systemMessageContainer); - } + }*/ /** * @Given I select the content article with title :arg1 @@ -129,12 +129,12 @@ public function iUnpublish() $I->clickToolbarButton('unpublish'); } /** - * @Then I see article unpublish message :arg1 + * @Then I wait for title :title and see the unpublish message :message */ - public function iSeeArticleUnpublishMessage($message) + public function iSeeArticleUnpublishMessage($title, $message) { $I = $this; - $I->waitForPageTitle('Articles'); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } @@ -161,12 +161,12 @@ public function iTrashTheArticleWithName() } /** - * @Then I see article trash message :arg1 + * @Then I wait for the title :title and see article trash message :message */ - public function iSeeArticleTrashMessage($message) + public function iSeeArticleTrashMessage($title, $message) { $I = $this; - $I->waitForPageTitle('Articles'); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } } \ No newline at end of file diff --git a/tests/_support/Step/Acceptance/Administrator/User.php b/tests/_support/Step/Acceptance/Administrator/User.php index b089774d1b..1c341dfe34 100644 --- a/tests/_support/Step/Acceptance/Administrator/User.php +++ b/tests/_support/Step/Acceptance/Administrator/User.php @@ -31,7 +31,7 @@ public function iCreateNewUser($name, $username, $password, $email) } /** - * @Then I Save the user + * @When I Save the user */ public function iSaveTheUser() { @@ -40,13 +40,13 @@ public function iSaveTheUser() } /** - * @Then I see the :arg1 message + * @Then I should wait for the title :title and see the message :message */ - public function iSeeTheMessage($message) + public function iSeeTheMessage($title, $message) { $I = $this; - $I->waitForPageTitle('Users'); - $I->see($message,AdminPage::$systemMessageContainer); + $I->waitForPageTitle($title); + $I->see($message, AdminPage::$systemMessageContainer); } /** @@ -63,7 +63,7 @@ public function iSearchAndSelectTheUserWithUserName($username) } /** - * @When I set name as an :name and User Group as :arg1 + * @When I set name as an :name and User Group as :usergroup */ public function iAssignedNameAndUserGroup($name, $userGroup) { @@ -76,18 +76,18 @@ public function iAssignedNameAndUserGroup($name, $userGroup) } /** - * @Then I should display the :arg1 message + * @Then I should wait for :arg1 title and see the :arg2 message */ - public function iShouldDisplayTheMessage($message) + public function iShouldDisplayTheMessage($title, $message) { $I = $this; $I->clickToolbarButton('Save & Close'); - $I->waitForPageTitle('Users'); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } /** - * @Given I have a user with user name :arg1 + * @Given I have a user with user name :username */ public function iHaveAUserWithUserName($username) { @@ -108,17 +108,17 @@ public function iBlockTheUser() } /** - * @Then I should see the user block message :arg1 + * @Then I wait for the title :title and see the message :message */ - public function iShouldSeeTheUserBlockMessage($message) + public function iShouldSeeTheUserBlockMessage($title, $message) { $I = $this; - $I->waitForPageTitle('Users'); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } /** - * @Given I have a blocked user with user name :arg1 + * @Given I have a blocked user with user name :username */ public function iHaveABlockedUserWithUserName($username) { @@ -140,17 +140,17 @@ public function iUnblockTheUser() } /** - * @Then I should see the user unblock message :arg1 + * @Then I should see the user unblock message :message */ - public function iShouldSeeTheUserUnblockMessage($message) + /*public function iShouldSeeTheUserUnblockMessage($message) { $I = $this; - $I->waitForPageTitle('Users'); + $I->waitForPageTitle($message, AdminPage::$systemMessageContainer); $I->see($message, AdminPage::$systemMessageContainer); - } + }*/ /** - * @When I Delete the user :arg1 + * @When I Delete the user :username */ public function iDeleteTheUser($username) { @@ -164,13 +164,14 @@ public function iDeleteTheUser($username) } /** - * @Then I confirm the user should have been deleted by getting the message :arg1 + * @Then I confirm the user should have been deleted by getting the title :title and see the message :message */ - public function iConfirmTheUserDeleteSucessfully($message) + public function iConfirmTheUserDeleteSucessfully($title, $message) { $I = $this; $I->checkForPhpNoticesOrWarnings(); - $I->see($message, AdminPage::$systemMessageContainer);; + $I->waitForPageTitle($title); + $I->see($message, AdminPage::$systemMessageContainer); } /** @@ -202,7 +203,7 @@ public function iCheckAvailableTabs($tab1, $tab2, $tab3) } /** - * @When I create a super admin with fields Name :name, Login Name :username, Password :password, and Email :email + * @Given I fill a super admin with fields Name :name, Login Name :username, Password :password, and Email :email */ public function iCreateASuperAdmin($name, $username, $password, $email) { @@ -249,12 +250,21 @@ public function iDontFillLoginName($name, $password, $email) } /** - * @Then I see the :error alert error + * @Then I see the title :title + */ + public function iSeeTheTitle($title) + { + $I = $this; + $I->waitForPageTitle($title); + } + + /** + * @Then I see the alert error :error */ public function iSeeTheAlertError($error) { $I = $this; - $I->see($error,AdminPage::$systemMessageContainer); + $I->see($error, AdminPage::$systemMessageContainer); } @@ -269,7 +279,7 @@ public function thereIsAAddNewGroupLink() } /** - * @When I fill Group Title as a :arg1 + * @When I fill Group Title as a :grouptitle */ public function iFillGroupTitleAsA($GroupTitle) { @@ -287,17 +297,17 @@ public function iSaveTheGroup() } /** - * @Then I should see the :arg1 message + * @Then I should wait for :title title and see the message :message */ - public function iShouldSeeTheMessage($message) + public function iShouldSeeTheMessage($title, $message) { $I = $this; - $I->waitForPageTitle('Users: Groups'); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } /** - * @Given I search and select the Group with name :arg1 + * @Given I search and select the Group with name :grouptitle */ public function iSearchAndSelectTheGroupWithName($GroupTitle) { @@ -310,13 +320,14 @@ public function iSearchAndSelectTheGroupWithName($GroupTitle) } /** - * @Given I set group Title as a :arg1 + * @Given I set group Title as a :grouptitle */ public function iSetGroupTitleAsA($GroupTitle) { $I = $this; $I->fillField(UserManagerPage::$title, $GroupTitle); } + /** * @When I Delete the Group :arg1 @@ -333,12 +344,13 @@ public function iDeleteTheGroup($GroupTitle) } /** - * @Then I confirm the group should have been deleted by getting the message :arg1 + * @Then I confirm the group should have been deleted by getting the title :title and see the message :message */ - public function iDeleteUserGroup($message) + public function iDeleteUserGroup($title, $message) { $I = $this; $I->checkForPhpNoticesOrWarnings(); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } @@ -372,17 +384,17 @@ public function iSaveTheAccessLevel() } /** - * @Then I should be see the :arg1 message + * @Then I wait for the title :title see the message :message */ - public function iShouldBeSeeTheMessage($message) + public function iShouldBeSeeTheMessage($title, $message) { $I = $this; - $I->waitForPageTitle('Users: Viewing Access Levels'); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } /** - * @Given I search and select the Access Level with name :arg1 + * @Given I search and select the Access Level with name :leveltitle */ public function iSearchAndSelectTheAccessLevelWithName($LevelTitle) { @@ -395,7 +407,7 @@ public function iSearchAndSelectTheAccessLevelWithName($LevelTitle) } /** - * @Given I set Access Level title as a :arg1 + * @Given I set Access Level title as a :leveltitle */ public function iSetAccessLevelTitleAsA($LevelTitle) { @@ -413,7 +425,7 @@ public function iSaveAccessLevel() } /** - * @When I Delete the Access level :arg1 + * @When I Delete the Access level :leveltitle */ public function iDeleteTheAccessLeVel($LevelTitle) { @@ -427,12 +439,61 @@ public function iDeleteTheAccessLeVel($LevelTitle) } /** - * @Then I confirm the Access Level have been deleted by getting the message :arg1 + * @Then I confirm the Access Level have been deleted by getting the title :title and see the message :message */ - public function iDeleteAccessLevel($message) + public function iDeleteAccessLevel($title, $message) { $I = $this; $I->checkForPhpNoticesOrWarnings(); + $I->waitForPageTitle($title); $I->see($message, AdminPage::$systemMessageContainer); } + /** + * @Given There is a User link + */ + public function thereIsAUserLink() + { + $I = $this; + $I->amOnPage(UserManagerPage::$pageURL); + } + + /** + * @Given I goto the option setting + */ + public function iGotoTheOptionSetting() + { + $I = $this; + $I->clickToolbarButton('options'); + } + + /** + * @When I set Allow User Registration as a yes + */ + public function iSetAllowUserRegistrationAsAYes() + { + $I = $this; + $I->selectOptionInRadioField('Allow User Registration', 'Yes'); + } + + /** + * @When I save the setting + */ + public function iSaveTheSetting() + { + $I = $this; + $I->clickToolbarButton('Save'); + + } + + + /** + * @Then I should be see the link Create an account in frontend + */ + public function iShouldBeSeeTheLinkCreateAnAccountInFrontend() + { + $I = $this; + $I->click(['class' => 'brand visible-desktop visible-tablet']); + } + + } diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index b7ee1010d0..439275b2fe 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -12,26 +12,26 @@ Feature: content Given There is a add content link When I create new content with field title as "My_Article" and content as a "This is my first article" And I save an article - Then I should see the "Article successfully saved." message + Then I wait for the title "Articles" and see the message "Article successfully saved." Scenario: Feature an Article Given I search and select content article with title "My_Article" When I featured the article - Then I save and see the "1 article featured." message + Then I wait for the title "Articles" and see the message "1 article featured." Scenario: Modify an article Given I select the content article with title "My_Article" And I set access level as a "Registered" When I save the article - Then I should see the "Article successfully saved" message + Then I wait for the title "Articles" and see the message "Article successfully saved." Scenario: Unpublish an article Given I have article with name "My_Article" When I unpublish the article - Then I see article unpublish message "1 article unpublished." + Then I wait for title "Articles" and see the unpublish message "1 article unpublished." Scenario: Trash an article Given I have "My_Article" content article which needs to be Trash When I Trash the article - Then I see article trash message "1 article trashed." + Then I wait for the title "Articles" and see article trash message "1 article trashed." diff --git a/tests/acceptance/users.feature b/tests/acceptance/users.feature index 2f12c79204..4d95435c17 100644 --- a/tests/acceptance/users.feature +++ b/tests/acceptance/users.feature @@ -13,76 +13,84 @@ Feature: users When I see the user edit view tabs Then I check available tabs "Account Details", "Assigned User Groups" and "Basic Settings" - Scenario: perform a add new user + Scenario: Create a add new user Given There is a add user link When I create new user with fields Name "register", Login Name "register", Password "register" and Email "register@gmail.com" - Then I Save the user - And I see the "User successfully saved." message + And I Save the user + Then I should wait for the title "Users" and see the message "User successfully saved." Scenario: Edit user Given I search and select the user with user name "register" When I set name as an "Editor" and User Group as "Editor" - Then I Save the user - And I see the "User successfully saved." message + And I Save the user + Then I should wait for the title "Users" and see the message "User successfully saved." Scenario: Block a User Given I have a user with user name "register" When I block the user - Then I should see the user block message "User blocked." + Then I wait for the title "Users" and see the message "User blocked." Scenario: Unblock user Given I have a blocked user with user name "register" When I unblock the user - Then I should see the user unblock message "User enabled." + Then I wait for the title "Users" and see the message "User enabled." Scenario: Delete user Given I have a user with user name "Editor" When I Delete the user "Editor" - Then I confirm the user should have been deleted by getting the message "1 user successfully deleted." + Then I confirm the user should have been deleted by getting the title "Users" and see the message "1 user successfully deleted." Scenario: Create super admin and login into the backend Given There is a add user link - When I create a super admin with fields Name "prital", Login Name "prital", Password "prital", and Email "prital@gmail.com" - And I set assigned user group as an Administrator - Then I Save the user - And Login in backend with username "prital" and password "prital" + And I fill a super admin with fields Name "prital", Login Name "prital", Password "prital", and Email "prital@gmail.com" + When I set assigned user group as an Administrator + And I Save the user + Then Login in backend with username "prital" and password "prital" - Scenario:create User without username fails + Scenario: Create User without username fails Given There is a add user link When I don't fill Login Name but fulfill remaining mandatory fields: Name "piyu", Password "piyu" and Email "piyu@gmail.com" - Then I Save the user - And I see the "Invalid field: Login Name" alert error + And I Save the user + Then I see the title "Users: New" + But I see the alert error "Invalid field: Login Name" Scenario: Create group Given There is a add new group link When I fill Group Title as a "Gsoc" And I save the Group - Then I should see the "Group successfully saved." message + Then I should wait for "Users: Groups" title and see the message "Group successfully saved." Scenario: Edit group Given I search and select the Group with name "Gsoc" And I set group Title as a "Gsoc_admin" When I save the Group - Then I should see the "Group successfully saved." message + Then I should wait for "Users: Groups" title and see the message "Group successfully saved." Scenario: Delete Group Given I search and select the Group with name "Gsoc_admin" When I Delete the Group "Gsoc_admin" - Then I confirm the group should have been deleted by getting the message "1 User Group successfully deleted." + Then I confirm the group should have been deleted by getting the title "Users: Groups" and see the message "1 User Group successfully deleted." Scenario: Create ACL level Given There is a add viewing access level link When I fill Level Title as a "joomla" and set Access as a public And I save the Access Level - Then I should be see the "Access level successfully saved." message + Then I wait for the title "Users: Viewing Access Levels" see the message "Access level successfully saved." - Scenario: Edit ACL + Scenario: Edit ACL Given I search and select the Access Level with name "joomla" And I set Access Level title as a "Gsoc_joomla" When I save Access Level - Then I should be see the "Access level successfully saved." message + Then I wait for the title "Users: Viewing Access Levels" and see the message "Access level successfully saved." Scenario: Delete ACL Given I search and select the Access Level with name "Gsoc_joomla" When I Delete the Access level "Gsoc_joomla" - Then I confirm the Access Level have been deleted by getting the message "1 View Access Level successfully removed." + Then I confirm the Access Level have been deleted by getting the title "Users: Viewing Access Levels" and see the message "1 View Access Level successfully removed." + + Scenario: User settings (Allow user registration) + Given There is a User link + And I goto the option setting + When I set Allow User Registration as a yes + And I save the setting + Then I should be see the link Create an account in frontend