diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 639d9452a8..c79e353f8e 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -149,7 +149,7 @@ public function clickToolbarButton($button) public function checkAllResults() { $I = $this; - $this->comment("Selecting Checkall button"); + $I->comment("Selecting Checkall button"); $I->click(['xpath' => "//thead//input[@name='checkall-toggle' or @name='toggle']"]); } @@ -165,9 +165,9 @@ public function selectOptionInChosenById($selectId, $option) { $chosenSelectID = $selectId . '_chzn'; $I = $this; - $this->comment("I open the $chosenSelectID chosen selector"); + $I->comment("I open the $chosenSelectID chosen selector"); $I->click(['xpath' => "//div[@id='$chosenSelectID']/a/div/b"]); - $this->comment("I select $option"); + $I->comment("I select $option"); $I->click(['xpath' => "//div[@id='$chosenSelectID']//li[text()='$option']"]); $I->wait(1); // Gives time to chosen to close } @@ -197,7 +197,7 @@ public function doAdministratorLogout() { $I = $this; $I->click(['xpath' => "//ul[@class='nav nav-user pull-right']//li//a[@class='dropdown-toggle']"]); - $this->comment("I click on Top Right corner toggle to Logout from Admin"); + $I->comment("I click on Top Right corner toggle to Logout from Admin"); $I->waitForElement(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"], TIMEOUT); $I->click(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"]); $I->waitForElement(['id' => 'mod-login-username'], TIMEOUT); @@ -218,4 +218,63 @@ public function selectOptionInRadioField($label, $option) $radioId = $label->getAttribute('for'); $I->click(['xpath' => "//fieldset[@id='$radioId']/label[contains(normalize-space(string(.)), '$option')]"]); } + + /** + * Prepare menu item creation by choosing menu and adding title. + * + * @param string $title The Menu Item title + * @param string $menu The menu in which menu item will be created. + * + * @since 3.7 + * + * @return void + */ + public function prepareMenuItemCreate($title, $menu = 'Main Menu') + { + $I = $this; + + $I->amOnPage('administrator/index.php?option=com_menus&view=menus'); + $I->waitForText('Menus', '60', ['css' => 'H1']); + $I->checkForPhpNoticesOrWarnings(); + + $I->click(['link' => $menu]); + $I->waitForText('Menus: Items', '60', ['css' => 'H1']); + $I->checkForPhpNoticesOrWarnings(); + + $I->click("New"); + $I->waitForText('Menus: New Item', '60', ['css' => 'h1']); + $I->checkForPhpNoticesOrWarnings(); + $I->fillField(['id' => 'jform_title'], $title); + } + + /** + * Creates a menu item with the Joomla menu manager, only working for menu items without additional required fields + * + * @param string $menuTitle The menu item title + * @param string $menuCategory The category of the menu type (for example Weblinks) + * @param string $menuItem The menu item type / link text (for example List all Web Link Categories) + * @param string $menu The menu where the item should be created + */ + public function selectMenuItemType($menuCategory, $menuItem) + { + $I = $this; + + $I->comment("Open the menu types iframe"); + $I->click(['link' => "Select"]); + $I->waitForElement(['id' => 'menuTypeModal'], '60'); + $I->wait(1); + $I->switchToIFrame("Menu Item Type"); + + $I->comment("Open the menu category: $menuCategory"); + // Open the category + $I->wait(1); + $I->waitForElement(['link' => $menuCategory], '60'); + $I->click(['link' => $menuCategory]); + + $I->comment("Choose the menu item type: $menuItem"); + $I->wait(1); + $I->waitForElement(['xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]"], '60'); + $I->click(['xpath' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], '$menuItem')]"]); + $I->comment('I switch back to the main window'); + } } diff --git a/tests/_support/Page/Acceptance/Administrator/CategoryManagerPage.php b/tests/_support/Page/Acceptance/Administrator/CategoryManagerPage.php new file mode 100644 index 0000000000..84a840b9bb --- /dev/null +++ b/tests/_support/Page/Acceptance/Administrator/CategoryManagerPage.php @@ -0,0 +1,19 @@ + 'jform_title']; + + public static $filterSearch = ['id' => 'filter_search']; + + public static $iconSearch = ['class' => 'icon-search']; + + public static $invalidTitle = ['class' => 'alert-error']; + + + +} diff --git a/tests/_support/Page/Acceptance/Administrator/MenuManagerPage.php b/tests/_support/Page/Acceptance/Administrator/MenuManagerPage.php new file mode 100644 index 0000000000..7227536413 --- /dev/null +++ b/tests/_support/Page/Acceptance/Administrator/MenuManagerPage.php @@ -0,0 +1,22 @@ + 'jform_title']; + + // public static $selectMenutype = ['class' =>'btn-primary']; + + // public static $selectMenuTypeArticle = ['link' => 'Articles']; + + // public static $singleArticle = ['xpath' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], 'Single Article')]"]; + + public static $selectArticle = ['class' => 'icon-file']; + + public static $chooseArticle = ['link' => 'Test_article']; + + public static $article = ['link' => 'Article']; +} diff --git a/tests/_support/Step/Acceptance/Administrator/Category.php b/tests/_support/Step/Acceptance/Administrator/Category.php new file mode 100644 index 0000000000..ff756acdaf --- /dev/null +++ b/tests/_support/Step/Acceptance/Administrator/Category.php @@ -0,0 +1,287 @@ +amOnPage(CategoryManagerPage::$url); + } + + /** + * @When I check available tabs in category + */ + public function iCheckAvailableTabsInCategory() + { + $I = $this; + $I->clickToolbarButton('New'); + $I->waitForText('Articles: New Category'); + } + + /** + * @Then I see available tabs :arg1, :arg2, :arg3 and :arg4 + */ + public function iSeeAvailableTabsAnd($tab1, $tab2, $tab3, $tab4) + { + $I = $this; + $I->verifyAvailableTabs([$tab1, $tab2, $tab3, $tab4]); + } + + /** + * @When I fill mandatory fields for creating Category + */ + public function iFillMandatoryFieldsForCreatingCategory(\Behat\Gherkin\Node\TableNode $title) + { + $I = $this; + $I->clickToolbarButton('New'); + $totalRows = count($title->getRows()); + $lastIndex = ($totalRows - 1); + + // iterate over all rows + foreach ($title->getRows() as $index => $row) + { + if ($index !== 0) + { + $I->fillField(CategoryManagerPage::$categoryTitleField, $row[0]); + + if ($index == $lastIndex) + { + $I->clickToolbarButton('Save'); + } + else + { + $I->clickToolbarButton('Save & New'); + } + } + } + } + + /** + * @When I save the category + */ + public function iSaveTheCategory() + { + $I = $this; + $I->clickToolbarButton('Save'); + } + /** + * @When I search and select category with title :arg1 + */ + public function iSearchAndSelectCategoryWithTitle($Title) + { + $I = $this; + $I->amOnPage(CategoryManagerPage::$url); + $I->fillField(CategoryManagerPage::$filterSearch, $Title); + $I->click(CategoryManagerPage::$iconSearch); + $I->checkAllResults(); + $I->clickToolbarButton('edit'); + } + + /** + * @When I set the title as a :arg1 + */ + public function iSetTheTitleAsA($title) + { + $I = $this; + $I->fillField(CategoryManagerPage::$categoryTitleField, $title); + } + + /** + * @Given I have a category with title :arg1 which needs to be unpublish + */ + public function iHaveACategoryWithTitleWhichNeedsToBeUnpublish($title) + { + $I = $this; + $I->amOnPage(CategoryManagerPage::$url); + $I->fillField(CategoryManagerPage::$filterSearch, $title); + $I->click(CategoryManagerPage::$iconSearch); + $I->checkAllResults(); + } + + /** + * @When I unpublish the category + */ + public function iUnpublishTheCategory() + { + $I = $this; + $I->clickToolbarButton('unpublish'); + } + + /** + * @Given I have a category with title :arg1 which needs to be trash + */ + public function iHaveACategoryWithTitleWhichNeedsToBeTrash($title) + { + $I = $this; + $I->amOnPage(CategoryManagerPage::$url); + $I->fillField(CategoryManagerPage::$filterSearch, $title); + $I->click(CategoryManagerPage::$iconSearch); + $I->checkAllResults(); + } + + /** + * @When I trash the category + */ + public function iTrashTheCategory() + { + $I = $this; + $I->clickToolbarButton('trash'); + } + + /** + * @When I create new category without field title + */ + public function iCreateNewCategoryWithoutFieldTitle() + { + $I = $this; + $I->amOnPage(CategoryManagerPage::$url); + $I->clickToolbarButton('New'); + $I->waitForText('Articles: New Category'); + $I->clickToolbarButton('Save'); + } + + /** + * @Then I should see the :arg1 + */ + public function iShouldSeeThe($error) + { + $I = $this; + $I->see($error, CategoryManagerPage::$invalidTitle); + } + + /** + * @When I create a new article :arg1 with content as a :arg2 + */ + public function iCreateANewArticleWithContentAsA($title, $content) + { + $I = $this; + $I->fillField(ArticleManagerPage::$articleTitleField, $title); + $I->click(ArticleManagerPage::$toggleEditor); + $I->fillField(ArticleManagerPage::$articleContentField, $content); + } + + /** + * @When I create menu item with title :title + */ + public function iCreateMenuItemWithTitle($title) + { + $I = $this; + $I->prepareMenuItemCreate($title); + } + + /** + * @When I choose menu item type :title and select :menuItem + */ + public function iAddTheMenuItemInMainMenu($title, $menuItem) + { + $I = $this; + $I->selectMenuItemType($title, $menuItem); + } + + /** + * @When I select an article :arg1 + */ + public function iSelectAnArticle($arg1) + { + $I = $this; + $I->click(MenuManagerPage::$selectArticle); + $I->switchToIFrame("Select or Change article"); + $I->waitForElement(MenuManagerPage::$chooseArticle, 60); + $I->checkForPhpNoticesOrWarnings(); + $I->click(MenuManagerPage::$chooseArticle); + $I->switchToIFrame(); + + // Waiting to close the iframe properly + $I->wait(1); + } + + /** + * @When I save the menu item + */ + public function iSaveTheMenuItem() + { + $I = $this; + $I->waitForPageTitle('Menus: New Item'); + $I->clickToolbarButton('Save'); + } + + /** + * @When I set category as a :arg1 + */ + public function iSetCategoryAsA($Category_2) + { + $I = $this; + $I->selectOptionInChosenById('jform_catid', $Category_2); + } + + /** + * @When I select a top level category :arg1 + */ + public function iSelectATopLevelCategory($Category_2) + { + $I = $this; + $I->selectOptionInChosenById('jform_request_id', $Category_2); + } + /** + * @When I set language as a :arg1 + */ + public function iSetLanguageAsA($english) + { + $I = $this; + $I->selectOptionInChosenById('jform_language', $english); + } + + /** + * @Given There is joomla home page + */ + public function thereIsJoomlaHomePage() + { + $I = $this; + $I->amOnPage(Frontpage::$url); + } + + /** + * @When I press on :arg1 menu + */ + public function iPressOnMenu($arg1) + { + $I = $this; + $I->click(MenuManagerPage::$article); + } + + /** + * @Then I should see the :arg1 in home page + */ + public function iShouldSeeTheInHomePage($arg1) + { + $I = $this; + $I->waitForText('Test_article'); + } + /** + * @When I press on :arg1 menu in joomla home page + */ + public function iPressOnMenuInJoomlaHomePage($arg1) + { + $I = $this; + $I->amOnPage(Frontpage::$url); + $I->click(MenuManagerPage::$article); + } + + /** + * @Then I should see the :arg1 error + */ + public function iShouldSeeTheError($error) + { + $I = $this; + $I->see($error, Frontpage::$alertMessage); + } +} diff --git a/tests/_support/Step/Acceptance/Administrator/Content.php b/tests/_support/Step/Acceptance/Administrator/Content.php index 3895b88169..353dbf0cf5 100644 --- a/tests/_support/Step/Acceptance/Administrator/Content.php +++ b/tests/_support/Step/Acceptance/Administrator/Content.php @@ -33,7 +33,7 @@ public function iCreateNewContent($title, $content) public function iSaveAnArticle() { $I = $this; - $I->clickToolbarButton('Save'); + $I->clickToolbarButton('Save'); } /** @@ -81,7 +81,7 @@ public function iSelectTheContentArticleWithTitle($title) } /** - * @Given I set access level as a :arg1 + * @When I set access level as a :arg1 */ public function iSetAccessLevelAsA($accessLevel) { diff --git a/tests/acceptance.suite.dist.yml b/tests/acceptance.suite.dist.yml index 1dd32e9e81..209b1c9ecb 100644 --- a/tests/acceptance.suite.dist.yml +++ b/tests/acceptance.suite.dist.yml @@ -38,4 +38,5 @@ gherkin: - Step\Acceptance\Administrator\Login - Step\Acceptance\Administrator\User - Step\Acceptance\Site\UsersFrontend - - Step\Acceptance\Administrator\Content \ No newline at end of file + - Step\Acceptance\Administrator\Content + - Step\Acceptance\Administrator\Category diff --git a/tests/acceptance/category.feature b/tests/acceptance/category.feature new file mode 100644 index 0000000000..faeac8e543 --- /dev/null +++ b/tests/acceptance/category.feature @@ -0,0 +1,92 @@ +Feature: category + In order to manage category in the web + As an owner + I need to create modify trash publish and Unpublish category + + Background: + When I Login into Joomla administrator with username "admin" and password "admin" + And I see the administrator dashboard + + Scenario: Verify available tabs in Category + Given There is an article category link + When I check available tabs in category + Then I see available tabs "Category", "Publishing", "Permissions" and "Options" + + Scenario: Create new category + Given There is an article category link + When I fill mandatory fields for creating Category + | Title | + | Category_1 | + | Category_2 | + Then I should see the "Category successfully saved." message + + 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 + + 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 + + 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 + + Scenario: Create category without Title fails + Given There is an article category link + When I create new category without field title + And I save the category + Then I should see the "Invalid field: Title" + + Scenario: Create menu item for newly created article + Given There is a add content link + When I create a new article "Test_article" with content as a "This Article test for menu item" + And I save an article + And I create menu item with title "Article" + 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 + + Scenario: Create menu item for articles belonging to a specific Category + Given There is a add content link + When I create a new article "Test_category" with content as a "This Article test for category menu item" + And I set category as a "- Category_2" + And I save an article + And I create menu item with title "All Categories" + 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 + + 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 + + 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 + + Scenario: Check article if exist in frontend + Given There is joomla home page + When I press on "Article" menu + Then I should see the "Test_article" in home page + + Scenario: Create an article for registered user and ensure is not visible in frontend + Given There is a add content link + When I select the content article with title "Test_article" + And I set access level as a "Registered" + And I save the article + And I press on "Article" menu in joomla home page + Then I should see the "You are not authorised to view this resource." error diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index c2669a7aef..1087167b47 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -20,8 +20,8 @@ Feature: content 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 + When I set access level as a "Registered" + And I save the article Then I should see the "Article successfully saved." message Scenario: Unpublish an article