From bb8766ebbde8d33ba54ae7685478696cd287a2b4 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Wed, 24 Aug 2016 22:56:52 +0530 Subject: [PATCH 1/5] Using alternative of system message container for assurance in article feature --- .../Acceptance/Administrator/AdminPage.php | 19 ++-- .../Administrator/ArticleManagerPage.php | 32 +++++++ .../Administrator/UserManagerPage.php | 4 +- .../Step/Acceptance/Administrator/Content.php | 87 +++++++++++++++---- tests/codeception/acceptance/content.feature | 10 +-- 5 files changed, 124 insertions(+), 28 deletions(-) diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php index fdfbdf44df..bf3a0051db 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php @@ -35,7 +35,7 @@ class AdminPage extends \AcceptanceTester public static $pageTitle = ['class' => 'page-title']; /** - * Locator for user's page title + * Locator for page title * * @var array * @since __DEPLOY_VERSION__ @@ -43,7 +43,7 @@ class AdminPage extends \AcceptanceTester public static $title = ['id' => 'jform_title']; /** - * Locator for user's search input field + * Locator for search input field * * @var array * @since __DEPLOY_VERSION__ @@ -51,7 +51,15 @@ class AdminPage extends \AcceptanceTester public static $filterSearch = ['id' => 'filter_search']; /** - * Locator for user's search button icon + * Locator for status filter under search tool + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $filterPublished = 'filter_published'; + + /** + * Locator for search button icon * * @var array * @since __DEPLOY_VERSION__ @@ -75,7 +83,7 @@ class AdminPage extends \AcceptanceTester public static $checkAll = ['xpath' => "//thead//input[@name='checkall-toggle' or @name='toggle']"]; /** - * Method to search using user's name + * Method to search using given keyword * * @param string $keyword The keyword to search * @@ -87,6 +95,7 @@ public function search($keyword) { $I = $this; + $I->amGoingTo('search for "' . $keyword . '"'); $I->fillField(static::$filterSearch, $keyword); $I->click(static::$iconSearch); } @@ -128,7 +137,7 @@ public function seeSystemMessage($title, $message) } /** - * Method is to Wait for page title untill default timeout. + * Method is to Wait for page title until default timeout. * * @param string $title Page Title text * diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php index bb95f4f7b5..cde1fbff69 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php @@ -42,6 +42,38 @@ class ArticleManagerPage extends AdminPage */ public static $url = "/administrator/index.php?option=com_content&view=articles"; + /** + * Locator for article's name field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeName = ['xpath' => "//table[@id='articleList']//tr[1]//td[4]"]; + + /** + * Locator for article's featured icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeFeatured = ['xpath' => "//table[@id='articleList']//*//span[@class='icon-featured']"]; + + /** + * Locator for article's name field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeAccessLevel = ['xpath' => "//table[@id='articleList']//tr[1]//td[5]"]; + + /** + * Locator for article's featured icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeUnpublished = ['xpath' => "//table[@id='articleList']//*//span[@class='icon-unpublish']"]; + /** * Method to create new article * diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php index 2d484574c5..d8c3465e69 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php @@ -99,7 +99,7 @@ class UserManagerPage extends AdminPage public static $email2Field = ['id' => 'jform_email2']; /** - * Locator for user's username field in frontend + * Locator for user's username field * * @var array * @since __DEPLOY_VERSION__ @@ -107,7 +107,7 @@ class UserManagerPage extends AdminPage public static $seeUserName = ['xpath' => "//table[@id='userList']//tr[1]/td[3]"]; /** - * Locator for user's name field in frontend + * Locator for user's name field * * @var array * @since __DEPLOY_VERSION__ diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php index b6ac4dcdda..d6bcf4caa0 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php @@ -70,6 +70,26 @@ public function iSaveAnArticle() $I->adminPage->clickToolbarButton('Save'); } + /** + * Method to save an article + * + * @param string $text The article Name + * + * @Then I should see the :text is created + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheIsCreated($text) + { + $I = $this; + + $I->amOnPage(ArticleManagerPage::$url); + $I->adminPage->search($text); + $I->see($text, ArticleManagerPage::$seeName); + } + /** * Method to search and select article * @@ -102,6 +122,22 @@ public function iFeatureTheContentWithTitle() $I->adminPage->clickToolbarButton('featured'); } + /** + * Method to assure that article is featured + * + * @Then I should see the article is now featured + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheArticleIsFeatured() + { + $I = $this; + + $I->seeNumberOfElements(ArticleManagerPage::$seeFeatured, 1); + } + /** * Method to select an article * @@ -117,10 +153,7 @@ public function iSelectTheContentArticleWithTitle($title) { $I = $this; - $I->amOnPage(ArticleManagerPage::$url); - $I->fillField(ArticleManagerPage::$filterSearch, $title); - $I->click(ArticleManagerPage::$iconSearch); - $I->adminPage->checkAllResults(); + $I->articleManagerPage->haveItemUsingSearch($title); $I->adminPage->clickToolbarButton('edit'); } @@ -158,6 +191,24 @@ public function iSaveTheArticle() $I->adminPage->clickToolbarButton('Save & Close'); } + /** + * Method to set access level + * + * @param string $accessLevel The name of access level which needs to be verify + * + * @Then I should see the :accessLevel as the access level + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheAsTheAccessLevel($accessLevel) + { + $I = $this; + + $I->see($accessLevel, ArticleManagerPage::$seeAccessLevel); + } + /** * Method to get an article * @@ -191,20 +242,19 @@ public function iUnpublish() } /** - * Confirm the article unpublish message + * Confirm the article is unpublished * - * @param string $title The webpage title - * @param string $message The unpublish successful message - * - * @Then I wait for title :title and see the unpublish message :message + * @Then I should see the article is now unpublished * * @since __DEPLOY_VERSION__ * * @return void */ - public function iSeeArticleUnpublishMessage($title, $message) + public function iShouldSeeTheArticleIsNowUnpublished() { - $this->adminPage->seeSystemMessage($title, $message); + $I = $this; + + $I->seeNumberOfElements(ArticleManagerPage::$seeUnpublished, 1); } /** @@ -242,17 +292,22 @@ public function iTrashTheArticleWithName() /** * Assure the article is trashed. * - * @param string $title The webpage title. - * @param string $message The article trashed successful message + * @param string $article The article name * - * @Then I wait for the title :title and see article trash message :message + * @Then I should see the :article in trash * * @since __DEPLOY_VERSION__ * * @return void */ - public function iSeeArticleTrashMessage($title, $message) + public function iShouldSeeTheInTrash($article) { - $this->adminPage->seeSystemMessage($title, $message); + $I = $this; + + $I->click('Search Tools'); + $I->wait(2); + $I->adminPage->selectOptionInChosenById(ArticleManagerPage::$filterPublished, 'Trashed'); + $I->articleManagerPage->waitForPageTitle('Articles'); + $I->see($article, ArticleManagerPage::$seeName); } } diff --git a/tests/codeception/acceptance/content.feature b/tests/codeception/acceptance/content.feature index 69b2a36a9e..8f28f7f050 100644 --- a/tests/codeception/acceptance/content.feature +++ b/tests/codeception/acceptance/content.feature @@ -11,25 +11,25 @@ Feature: content Given There is a add content link When I create new content with field title as "Article One" 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 should see the "Article One" is created Scenario: Feature an Article Given I search and select content article with title "Article One" When I featured the article - Then I should see the "1 article featured." message + Then I should see the article is now featured Scenario: Modify an article Given I select the content article with title "Article One" When I set access level as a "Registered" And I save the article - Then I should see the "Article successfully saved." message + Then I should see the "Registered" as the access level Scenario: Unpublish an article Given I have article with name "Article One" When I unpublish the article - Then I should see the "1 article unpublished." message + Then I should see the article is now unpublished Scenario: Trash an article Given I have "Article One" content article which needs to be Trash When I Trash the article - Then I should see the "1 article trashed." message + Then I should see the "Article One" in trash From e55603bc123b544e22e2ae27c97ab33328104bd5 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Wed, 24 Aug 2016 23:34:47 +0530 Subject: [PATCH 2/5] Improve code and convert into page object --- .../Acceptance/Administrator/AdminPage.php | 41 ++++++++++++++++++- .../Step/Acceptance/Administrator/Content.php | 16 +++----- tests/codeception/acceptance/content.feature | 4 +- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php index bf3a0051db..8769cb3110 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php @@ -313,7 +313,7 @@ public function doAdministratorLogout() * * @return void */ - public function verifyAvailableTabs($expectedTabs, $tabsLocator = NULL) + public function verifyAvailableTabs($expectedTabs, $tabsLocator = null) { $I = $this; @@ -330,4 +330,43 @@ public function verifyAvailableTabs($expectedTabs, $tabsLocator = NULL) $I->comment('Verify the Tabs'); } + + /** + * Method to see that item is saved + * + * @param string $item The item Name + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function seeItemIsCreated($item) + { + $I = $this; + + $I->amOnPage(static::$url); + $I->search($item); + $I->see($item, static::$seeName); + } + + /** + * Assure the item is trashed. + * + * @param string $item The item name + * @param string $pageTitle The page title + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function seeItemInTrash($item, $pageTitle) + { + $I = $this; + + $I->click('Search Tools'); + $I->wait(2); + $I->selectOptionInChosenById(static::$filterPublished, 'Trashed'); + $I->waitForPageTitle($pageTitle); + $I->see($item, static::$seeName); + } } diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php index d6bcf4caa0..e32ced6452 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php @@ -75,19 +75,17 @@ public function iSaveAnArticle() * * @param string $text The article Name * - * @Then I should see the :text is created + * @Then I should see the article :text is created * * @since __DEPLOY_VERSION__ * * @return void */ - public function iShouldSeeTheIsCreated($text) + public function seeTheArticleIsCreated($text) { $I = $this; - $I->amOnPage(ArticleManagerPage::$url); - $I->adminPage->search($text); - $I->see($text, ArticleManagerPage::$seeName); + $I->articleManagerPage->seeItemIsCreated($text); } /** @@ -294,7 +292,7 @@ public function iTrashTheArticleWithName() * * @param string $article The article name * - * @Then I should see the :article in trash + * @Then I should see the article :article in trash * * @since __DEPLOY_VERSION__ * @@ -304,10 +302,6 @@ public function iShouldSeeTheInTrash($article) { $I = $this; - $I->click('Search Tools'); - $I->wait(2); - $I->adminPage->selectOptionInChosenById(ArticleManagerPage::$filterPublished, 'Trashed'); - $I->articleManagerPage->waitForPageTitle('Articles'); - $I->see($article, ArticleManagerPage::$seeName); + $I->articleManagerPage->seeItemInTrash($article, 'Articles'); } } diff --git a/tests/codeception/acceptance/content.feature b/tests/codeception/acceptance/content.feature index 8f28f7f050..42ccf3d198 100644 --- a/tests/codeception/acceptance/content.feature +++ b/tests/codeception/acceptance/content.feature @@ -11,7 +11,7 @@ Feature: content Given There is a add content link When I create new content with field title as "Article One" and content as a "This is my first article" And I save an article - Then I should see the "Article One" is created + Then I should see the article "Article One" is created Scenario: Feature an Article Given I search and select content article with title "Article One" @@ -32,4 +32,4 @@ Feature: content Scenario: Trash an article Given I have "Article One" content article which needs to be Trash When I Trash the article - Then I should see the "Article One" in trash + Then I should see the article "Article One" in trash From 7d3db1457a67d19af80fe3653821300dee91a28e Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Thu, 25 Aug 2016 00:33:07 +0530 Subject: [PATCH 3/5] Convert system message checks in category feature --- .../Administrator/ArticleManagerPage.php | 2 +- .../Administrator/CategoryManagerPage.php | 32 +++++ .../Administrator/MenuManagerPage.php | 10 +- .../Acceptance/Administrator/Category.php | 115 +++++++++++++++++- .../Step/Acceptance/Administrator/Content.php | 12 +- tests/codeception/acceptance/category.feature | 17 +-- tests/codeception/acceptance/content.feature | 2 +- 7 files changed, 168 insertions(+), 22 deletions(-) diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php index cde1fbff69..f7e003db9c 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/ArticleManagerPage.php @@ -67,7 +67,7 @@ class ArticleManagerPage extends AdminPage public static $seeAccessLevel = ['xpath' => "//table[@id='articleList']//tr[1]//td[5]"]; /** - * Locator for article's featured icon + * Locator for article's unpublish icon * * @var array * @since __DEPLOY_VERSION__ diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/CategoryManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/CategoryManagerPage.php index b1fba4e6ce..823bfbd6c7 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/CategoryManagerPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/CategoryManagerPage.php @@ -26,6 +26,38 @@ class CategoryManagerPage extends AdminPage */ public static $url = '/administrator/index.php?option=com_categories&view=categories&extension=com_content'; + /** + * Locator for category name field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeName = ['xpath' => "//table[@id='categoryList']//tr[1]//td[4]"]; + + /** + * Locator for category unpublished icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeUnpublished = ['xpath' => "//table[@id='categoryList']//*//span[@class='icon-unpublish']"]; + + /** + * Locator for category access level field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeAccessLevel = ['xpath' => "//table[@id='categoryList']//tr[1]//td[9]"]; + + /** + * Locator for category language field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeLanguage = ['xpath' => "//table[@id='categoryList']//tr[1]//td[10]"]; + /** * Locator for invalid category alert * diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php index 966771516f..7f71aaf947 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php @@ -24,7 +24,15 @@ class MenuManagerPage extends AdminPage * @var string * @since __DEPLOY_VERSION__ */ - public static $url = 'administrator/index.php?option=com_menus&view=item&layout=edit&menutype=mainmenu'; + public static $url = 'administrator/index.php?option=com_menus&view=items&menutype=mainmenu'; + + /** + * Locator for menu item name field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeName = ['xpath' => "//table[@id='itemList']//tr[1]//td[4]"]; /** * Locator for select article for menu item diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Category.php b/tests/codeception/_support/Step/Acceptance/Administrator/Category.php index 7c0572db86..192552cc0d 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/Category.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Category.php @@ -116,6 +116,24 @@ public function iFillMandatoryFieldsForCreatingCategory(TableNode $title) } } + /** + * Method to confirm that category is created + * + * @param string $category The category Name + * + * @Then I should see the category :category is created + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheCategoryIsCreated($category) + { + $I = $this; + + $I->categoryManagerPage->seeItemIsCreated($category); + } + /** * Save category form * @@ -147,10 +165,7 @@ public function iSearchAndSelectCategoryWithTitle($title) { $I = $this; - $I->amOnPage(CategoryManagerPage::$url); - $I->fillField(CategoryManagerPage::$filterSearch, $title); - $I->click(CategoryManagerPage::$iconSearch); - $I->adminPage->checkAllResults(); + $I->categoryManagerPage->haveItemUsingSearch($title); $I->adminPage->clickToolbarButton('edit'); } @@ -204,6 +219,22 @@ public function iUnpublishTheCategory() $I->adminPage->clickToolbarButton('unpublish'); } + /** + * Confirm the category is unpublished + * + * @Then I should see the category is now unpublished + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheCategoryIsNowUnpublished() + { + $I = $this; + + $I->seeNumberOfElements(CategoryManagerPage::$seeUnpublished, 1); + } + /** * Method to trash the category * @@ -236,6 +267,24 @@ public function iTrashTheCategory() $I->adminPage->clickToolbarButton('trash'); } + /** + * Assure the category is trashed. + * + * @param string $category The article name + * + * @Then I should see the category :category in trash + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheInTrash($category) + { + $I = $this; + + $I->categoryManagerPage->seeItemInTrash($category, 'Articles: Categories'); + } + /** * Method to create new category without title * @@ -374,7 +423,25 @@ public function iSaveTheMenuItem() $I = $this; $I->adminPage->waitForPageTitle('Menus: New Item'); - $I->adminPage->clickToolbarButton('Save'); + $I->adminPage->clickToolbarButton('save & close'); + } + + /** + * Method to confirm that menu item is created + * + * @param string $item The menu item Name + * + * @Then I should see the menu item :item is created + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheMenuItemIsCreated($item) + { + $I = $this; + + $I->menuManagerPage->seeItemIsCreated($item); } /** @@ -413,6 +480,25 @@ public function iSelectATopLevelCategory($name) $I->adminPage->selectOptionInChosenById('jform_request_id', $name); } + /** + * Method to set access level + * + * @param string $accessLevel The name of access level which needs to be verify + * + * @Then I should see the :accessLevel as category access level + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheCategoryAsTheAccessLevel($accessLevel) + { + $I = $this; + + $I->amOnPage(CategoryManagerPage::$url); + $I->see($accessLevel, CategoryManagerPage::$seeAccessLevel); + } + /** * Method to set language * @@ -431,6 +517,25 @@ public function iSetLanguageAsA($name) $I->adminPage->selectOptionInChosenById('jform_language', $name); } + /** + * Method to check language is saved + * + * @param string $title The name of access level which needs to be verify + * + * @Then I should see the category language as :title + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iSeeTheCategoryLanguage($title) + { + $I = $this; + + $I->amOnPage(CategoryManagerPage::$url); + $I->see($title, CategoryManagerPage::$seeLanguage); + } + /** * Method go to joomla home page * diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php index e32ced6452..9e786e68bb 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/Content.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Content.php @@ -73,19 +73,19 @@ public function iSaveAnArticle() /** * Method to save an article * - * @param string $text The article Name + * @param string $article The article Name * - * @Then I should see the article :text is created + * @Then I should see the article :article is created * * @since __DEPLOY_VERSION__ * * @return void */ - public function seeTheArticleIsCreated($text) + public function seeTheArticleIsCreated($article) { $I = $this; - $I->articleManagerPage->seeItemIsCreated($text); + $I->articleManagerPage->seeItemIsCreated($article); } /** @@ -194,13 +194,13 @@ public function iSaveTheArticle() * * @param string $accessLevel The name of access level which needs to be verify * - * @Then I should see the :accessLevel as the access level + * @Then I should see the :accessLevel as article access level * * @since __DEPLOY_VERSION__ * * @return void */ - public function iShouldSeeTheAsTheAccessLevel($accessLevel) + public function iShouldSeeTheArticleAsTheAccessLevel($accessLevel) { $I = $this; diff --git a/tests/codeception/acceptance/category.feature b/tests/codeception/acceptance/category.feature index 29d68db69e..6202deea89 100644 --- a/tests/codeception/acceptance/category.feature +++ b/tests/codeception/acceptance/category.feature @@ -18,24 +18,25 @@ Feature: category | Title | | Category_1 | | Category_2 | - Then I should see the "Category successfully saved." message + Then I should see the category "Category_1" is created + And I should see the category "Category_2" is created Scenario: Modify category Given There is an article category link When I search and select category with title "Category_1" And I set the title as a "GSoc_category" And I save the category - Then I should see the "Category successfully saved." message + Then I should see the category "GSoc_category" is created Scenario: Unpublish category Given I have a category with title "GSoc_category" which needs to be unpublish When I unpublish the category - Then I should see the "1 category successfully unpublished." message + Then I should see the category is now unpublished Scenario: Trash category Given I have a category with title "GSoc_category" which needs to be trash When I trash the category - Then I should see the "1 category successfully trashed." message + Then I should see the category "GSoc_category" in trash Scenario: Create category without Title fails Given There is an article category link @@ -51,7 +52,7 @@ Feature: category And I choose menu item type "Articles" and select "Single Article" And I select an article "Test_article" And I save the menu item - Then I should see the "Menu item successfully saved." message + Then I should see the menu item "Article" is created Scenario: Create menu item for articles belonging to a specific Category Given There is a add content link @@ -62,21 +63,21 @@ Feature: category And I choose menu item type "Articles" and select "List All Categories" And I select a top level category "Category_2" And I save the menu item - Then I should see the "Menu item successfully saved." message + Then I should see the menu item "All Categories" is created Scenario: Category ACL Settings Given There is an article category link When I search and select category with title "Category_2" And I set access level as a "Registered" And I save the category - Then I should see the "Category successfully saved." message + Then I should see the "Registered" as category access level Scenario: Category Language settings Given There is an article category link When I search and select category with title "Category_2" And I set language as a "English (UK)" And I save the category - Then I should see the "Category successfully saved." message + Then I should see the category language as "English (UK)" Scenario: Check article if exist in frontend Given There is joomla home page diff --git a/tests/codeception/acceptance/content.feature b/tests/codeception/acceptance/content.feature index 42ccf3d198..04262a14a8 100644 --- a/tests/codeception/acceptance/content.feature +++ b/tests/codeception/acceptance/content.feature @@ -22,7 +22,7 @@ Feature: content Given I select the content article with title "Article One" When I set access level as a "Registered" And I save the article - Then I should see the "Registered" as the access level + Then I should see the "Registered" as article access level Scenario: Unpublish an article Given I have article with name "Article One" From c246b339815a9b01db48d5bf1fbb033e2319f4ca Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Thu, 25 Aug 2016 01:46:12 +0530 Subject: [PATCH 4/5] Convert system message container in user feature --- .../Acceptance/Administrator/AdminPage.php | 1 + .../Acceptance/Administrator/UserAclPage.php | 8 ++ .../Administrator/UserGroupPage.php | 8 ++ .../Administrator/UserManagerPage.php | 24 ++++ .../Step/Acceptance/Administrator/User.php | 107 ++++++++++++++++++ tests/codeception/acceptance/users.feature | 22 ++-- 6 files changed, 159 insertions(+), 11 deletions(-) diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php index 8769cb3110..bb4fe32a55 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/AdminPage.php @@ -116,6 +116,7 @@ public function haveItemUsingSearch($keyword) $I->amOnPage(static::$url); $I->search($keyword); $I->checkAllResults(); + $I->wait(1); } /** diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/UserAclPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/UserAclPage.php index 3053de97d1..e6701248a4 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/UserAclPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/UserAclPage.php @@ -25,4 +25,12 @@ class UserAclPage extends AdminPage * @since __DEPLOY_VERSION__ */ public static $url = 'administrator/index.php?option=com_users&view=levels'; + + /** + * Locator for user's acl name field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeName = ['xpath' => "//table[@id='levelList']//tr[1]/td[3]"]; } diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/UserGroupPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/UserGroupPage.php index 8c72a8a234..f93291ec4f 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/UserGroupPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/UserGroupPage.php @@ -25,4 +25,12 @@ class UserGroupPage extends AdminPage * @since __DEPLOY_VERSION__ */ public static $url = 'administrator/index.php?option=com_users&view=groups'; + + /** + * Locator for user's group name field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeName = ['xpath' => "//table[@id='groupList']//tr[1]/td[2]"]; } diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php index d8c3465e69..c512abcf61 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/UserManagerPage.php @@ -122,6 +122,30 @@ class UserManagerPage extends AdminPage */ public static $lastLoginDate = ['xpath' => "//table[@id='userList']//tr[1]/td[8]"]; + /** + * Locator for user is blocked + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeBlocked = ['xpath' => "//table[@id='userList']//*//td[4]//span[@class='icon-unpublish']"]; + + /** + * Locator for user is unblocked + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeUnblocked = ['xpath' => "//table[@id='userList']//*//td[4]//span[@class='icon-publish']"]; + + /** + * Locator for user is deleted and not found + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $noItems = ['class' => 'alert-no-items']; + /** * Method is a page object to fill user form with given information and prepare to save user. * diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/User.php b/tests/codeception/_support/Step/Acceptance/Administrator/User.php index 4cebd37915..b550f3f2a4 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/User.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/User.php @@ -78,6 +78,24 @@ public function iSaveTheUser() $I->adminPage->clickToolbarButton('Save & Close'); } + /** + * Method to see user is saved + * + * @param string $name The user's Name + * + * @Then I should see the user :name is created + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function seeTheUserIsCreated($name) + { + $I = $this; + + $I->userManagerPage->seeItemIsCreated($name); + } + /** * Method to search and select user with username * @@ -184,6 +202,40 @@ public function iUnblockTheUser() $I->adminPage->clickToolbarButton('unblock'); } + /** + * Confirm the user is blocked + * + * @Then I should see the user is now blocked + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheUserIsNowBlocked() + { + $I = $this; + + $I->adminPage->waitForPageTitle('Users'); + $I->seeNumberOfElements(UserManagerPage::$seeBlocked, 1); + } + + /** + * Confirm the user is unblocked + * + * @Then I should see the user is now unblocked + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheUserIsNowUnblocked() + { + $I = $this; + + $I->adminPage->waitForPageTitle('Users'); + $I->seeNumberOfElements(UserManagerPage::$seeUnblocked, 1); + } + /** * Method to delete user * @@ -205,6 +257,25 @@ public function iDeleteTheUser($username) $I->acceptPopup(); } + /** + * Confirm the user is now deleted + * + * @param string $message The message for no item in list + * + * @Then I should see :message for deleted user + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function iShouldSeeTheUserIsNowDeleted($message) + { + $I = $this; + + $I->wait(1); + $I->see($message, UserManagerPage::$noItems); + } + /** * Method to goto user manager page. * @@ -275,6 +346,24 @@ public function iSetAssignedUserGroupAsAnAdministrator() $I->checkOption('#1group_7'); } + /** + * Method to check group is created + * + * @param string $name The group Name + * + * @Then I should see the group :name is created + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function seeTheUserGroupIsCreated($name) + { + $I = $this; + + $I->userGroupPage->seeItemIsCreated($name); + } + /** * Method to login into backend * @@ -499,6 +588,24 @@ public function iSaveTheAccessLevel() $I->adminPage->clickToolbarButton('Save & Close'); } + /** + * Method to check access level is created + * + * @param string $name The access level Name + * + * @Then I should see the access level :name is created + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function seeTheUserAclIsCreated($name) + { + $I = $this; + + $I->userAclPage->seeItemIsCreated($name); + } + /** * Method to search using the access level name * diff --git a/tests/codeception/acceptance/users.feature b/tests/codeception/acceptance/users.feature index 04686673b4..325673ac28 100644 --- a/tests/codeception/acceptance/users.feature +++ b/tests/codeception/acceptance/users.feature @@ -16,28 +16,28 @@ Feature: users Given There is a add user link When I create new user with fields Name "register", Login Name "register", Password "register" and Email "register@example.com" And I Save the user - Then I should see the "User successfully saved." message + Then I should see the user "register" is created 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" And I Save the user - Then I should see the "User successfully saved." message + Then I should see the user "Editor" is created Scenario: Block a User Given I have a user with user name "register" When I block the user - Then I should see the "User blocked." message + Then I should see the user is now 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 enabled." message + Then I should see the user is now unblocked Scenario: Delete user Given I have a user with user name "Editor" When I Delete the user "Editor" - Then I should see the "1 user successfully deleted." message + Then I should see "No Matching Results" for deleted user Scenario: Create super admin and login into the backend Given There is a add user link @@ -57,35 +57,35 @@ Feature: users Given There is a add new group link When I fill Group Title as a "Group One" And I save the Group - Then I should see the "Group successfully saved." message + Then I should see the group "Group One" is created Scenario: Edit group Given I search and select the Group with name "Group One" And I set group Title as a "Group Two" When I save the Group - Then I should see the "Group successfully saved." message + Then I should see the group "Group Two" is created Scenario: Delete Group Given I search and select the Group with name "Group Two" When I Delete the Group "Group Two" - Then I should see the "1 User Group successfully deleted." message + Then I should see "No Matching Results" for deleted user Scenario: Create ACL level Given There is a add viewing access level link When I fill Level Title as a "Acl One" and set Access as a public And I save the Access Level - Then I should see the "Access level successfully saved." message + Then I should see the access level "Acl One" is created Scenario: Edit ACL Given I search and select the Access Level with name "Acl One" And I set Access Level title as a "Acl Two" When I save the Access Level - Then I should see the "Access level successfully saved." message + Then I should see the access level "Acl Two" is created Scenario: Delete ACL Given I search and select the Access Level with name "Acl Two" When I Delete the Access level "Acl Two" - Then I should see the "1 View Access Level successfully removed." message + Then I should see "No Matching Results" for deleted user Scenario: User settings (Allow user registration) Given There is an user link From 4b14a2cb8ecb45ee0ef4a43fcf4f11977ea67b89 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Thu, 25 Aug 2016 11:44:55 +0530 Subject: [PATCH 5/5] Repair user scenarios --- .../Step/Acceptance/Administrator/User.php | 20 +++++++++++++------ tests/codeception/acceptance/users.feature | 10 +++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/User.php b/tests/codeception/_support/Step/Acceptance/Administrator/User.php index b550f3f2a4..73a5f3eab0 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/User.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/User.php @@ -205,34 +205,40 @@ public function iUnblockTheUser() /** * Confirm the user is blocked * - * @Then I should see the user is now blocked + * @param string $name The user name to be assured + * + * @Then I should see the user :name is now blocked * * @since __DEPLOY_VERSION__ * * @return void */ - public function iShouldSeeTheUserIsNowBlocked() + public function iShouldSeeTheUserIsNowBlocked($name) { $I = $this; $I->adminPage->waitForPageTitle('Users'); + $I->userManagerPage->search($name); $I->seeNumberOfElements(UserManagerPage::$seeBlocked, 1); } /** * Confirm the user is unblocked * - * @Then I should see the user is now unblocked + * @param string $name The user name to be assured + * + * @Then I should see the user :name is now unblocked * * @since __DEPLOY_VERSION__ * * @return void */ - public function iShouldSeeTheUserIsNowUnblocked() + public function iShouldSeeTheUserIsNowUnblocked($name) { $I = $this; $I->adminPage->waitForPageTitle('Users'); + $I->userManagerPage->search($name); $I->seeNumberOfElements(UserManagerPage::$seeUnblocked, 1); } @@ -261,18 +267,20 @@ public function iDeleteTheUser($username) * Confirm the user is now deleted * * @param string $message The message for no item in list + * @param string $name The user name to be assured * - * @Then I should see :message for deleted user + * @Then I should see :message for deleted user :name * * @since __DEPLOY_VERSION__ * * @return void */ - public function iShouldSeeTheUserIsNowDeleted($message) + public function iShouldSeeTheUserIsNowDeleted($message, $name) { $I = $this; $I->wait(1); + $I->userManagerPage->search($name); $I->see($message, UserManagerPage::$noItems); } diff --git a/tests/codeception/acceptance/users.feature b/tests/codeception/acceptance/users.feature index 325673ac28..1cd04f04f4 100644 --- a/tests/codeception/acceptance/users.feature +++ b/tests/codeception/acceptance/users.feature @@ -27,17 +27,17 @@ Feature: users Scenario: Block a User Given I have a user with user name "register" When I block the user - Then I should see the user is now blocked + Then I should see the user "register" is now 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 is now unblocked + Then I should see the user "register" is now unblocked Scenario: Delete user Given I have a user with user name "Editor" When I Delete the user "Editor" - Then I should see "No Matching Results" for deleted user + Then I should see "No Matching Results" for deleted user "Editor" Scenario: Create super admin and login into the backend Given There is a add user link @@ -68,7 +68,7 @@ Feature: users Scenario: Delete Group Given I search and select the Group with name "Group Two" When I Delete the Group "Group Two" - Then I should see "No Matching Results" for deleted user + Then I should see "No Matching Results" for deleted user "Group Two" Scenario: Create ACL level Given There is a add viewing access level link @@ -85,7 +85,7 @@ Feature: users Scenario: Delete ACL Given I search and select the Access Level with name "Acl Two" When I Delete the Access level "Acl Two" - Then I should see "No Matching Results" for deleted user + Then I should see "No Matching Results" for deleted user "Acl Two" Scenario: User settings (Allow user registration) Given There is an user link