diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/MenuItemManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/MenuItemManagerPage.php new file mode 100644 index 0000000000..e44b5543ff --- /dev/null +++ b/tests/codeception/_support/Page/Acceptance/Administrator/MenuItemManagerPage.php @@ -0,0 +1,83 @@ + 'alert-error']; + + /** + * Locator for Menu Item unpublished icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeUnpublished = ['xpath' => "//table[@id='itemList']//*//span[@class='icon-unpublish']"]; + + /** + * Locator for menu Item language field + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeLanguage = ['xpath' => "//table[@id='itemList']//tr[1]//td[10]"]; + + public function selectMenuItemType($menuCategory, $menuItem) + { + + + // 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'); + } + + public function selectTypeAndMenu($type, $menu){ + + $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: $type"); + + + } +} \ No newline at end of file diff --git a/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php b/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php index 7f71aaf947..7e8141c79b 100644 --- a/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php +++ b/tests/codeception/_support/Page/Acceptance/Administrator/MenuManagerPage.php @@ -19,7 +19,7 @@ class MenuManagerPage extends AdminPage { /** - * Link to the article category listing url. + * Link to the menu listing url. * * @var string * @since __DEPLOY_VERSION__ @@ -59,6 +59,14 @@ class MenuManagerPage extends AdminPage */ public static $article = ['link' => 'Article']; + /** + * Locator for category unpublished icon + * + * @var array + * @since __DEPLOY_VERSION__ + */ + public static $seeUnpublished = ['xpath' => "//table[@id='categoryList']//*//span[@class='icon-unpublish']"]; + /** * This method is to set page object to choose an article dynamically. * diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php b/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php index 24b3bdec86..134d55d118 100644 --- a/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php +++ b/tests/codeception/_support/Step/Acceptance/Administrator/Admin.php @@ -14,6 +14,7 @@ use Page\Acceptance\Administrator\ArticleManagerPage; use Page\Acceptance\Administrator\CategoryManagerPage; use Page\Acceptance\Administrator\ExtensionManagerPage; +use Page\Acceptance\Administrator\MenuItemManagerPage; use Page\Acceptance\Administrator\MenuManagerPage; use Page\Acceptance\Administrator\UserAclPage; use Page\Acceptance\Administrator\UserGroupPage; @@ -91,6 +92,15 @@ class Admin extends \AcceptanceTester */ protected $menuManagerPage = null; + /** + * Menu Item Manager Page Object for this class + * + * @var null|MenuItemManagerPage + * + * @since __DEPLOY_VERSION__ + */ + protected $menuItemManagerPage = null; + /** * User constructor. * @@ -111,6 +121,7 @@ public function __construct(Scenario $scenario) $this->userAclPage = new UserAclPage($scenario); $this->menuManagerPage = new MenuManagerPage($scenario); $this->extensionManagerPage = new ExtensionManagerPage($scenario); + $this->menuItemManagerPage = new MenuItemManagerPage($scenario); } /** diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/MenuItem.php b/tests/codeception/_support/Step/Acceptance/Administrator/MenuItem.php new file mode 100644 index 0000000000..bfdb135de8 --- /dev/null +++ b/tests/codeception/_support/Step/Acceptance/Administrator/MenuItem.php @@ -0,0 +1,219 @@ +adminPage->clickToolbarButton('New'); + $I->waitForText('Menus: New Item'); + } + + /** + * @Then I see the available tabs :arg1, :arg2, :arg3, :arg4, :arg5 + */ + public function iSeeTheAvailableTabs($arg1, $arg2, $arg3, $arg4, $arg5) + { + $I = $this; + + $I->adminPage->verifyAvailableTabs([$arg1, $arg2, $arg3, $arg4, $arg5]); + } + + /** + * @When I fill mandatory fields for creating menu item + */ + public function iFillMandatoryFieldsForCreatingMenuItem(TableNode $title) + { + $I = $this; + + $I->adminPage->clickToolbarButton('New'); + + $totalRows = count($title->getRows()); + $lastIndex = ($totalRows - 1); + + // Iterate over all rows + foreach ($title->getRows() as $index => $row) + { + if ($index !== 0) + { + $I->fillField(MenuItemManagerPage::$title, $row[0]); + + if ($index == $lastIndex) + { + $I->adminPage->clickToolbarButton('Save'); + } + else + { + $I->adminPage->clickToolbarButton('Save & New'); + } + } + } + } + + /** + * @When I should see :arg1 + */ + public function iShouldSee($menuItem) + { + $I = $this; + + $I->menuItemManagerPage->seeItemIsCreated($menuItem); + } + + /** + * @When I should see error :arg1 + */ + public function iShouldSeeError($error) + { + $I = $this; + + $I->see($error, MenuItemManagerPage::$invalidTitle); + } + + /** + * @Given There is an menu item link + */ + public function thereIsAnMenuItemLink() + { + $I = $this; + + $I->amOnPage(MenuItemManagerPage::$url); + $I->adminPage->clickToolbarButton('New'); + } + + /** + * @Given I have a menu item with title :arg1 which needs to be unpublished + */ + public function iHaveAMenuItemWithTitleWhichNeedsToBeUnpublished($title) + { + $this->menuItemManagerPage->haveItemUsingSearch($title); + } + + /** + * @When I unpublish the menu item + */ + public function iUnpublishTheMenuItem() + { + $I = $this; + + $I->adminPage->clickToolbarButton('unpublish'); + } + + /** + * @Then I should see the menu item is now unpublished + */ + public function iShouldSeeTheMenuItemIsNowUnpublished() + { + $I = $this; + + $I->seeNumberOfElements(MenuItemManagerPage::$seeUnpublished, 1); + } + + /** + * @Given I have a menu item with title :arg1 which needs to be trash + */ + public function iHaveAMenuItemWithTitleWhichNeedsToBeTrash($title) + { + $this->menuItemManagerPage->haveItemUsingSearch($title); } + + /** + * @When I trash the menu item + */ + public function iTrashTheMenuItem($title) + { + $this->menuItemManagerPage->haveItemUsingSearch($title); + } + + /** + * @When I create new menu item without field title + */ + public function iCreateNewMenuItemWithoutFieldTitle() + { + $I = $this; + + $I->amOnPage(MenuItemManagerPage::$url); + $I->adminPage->clickToolbarButton('New'); + + $I->waitForText('Menus: New Item'); + $I->adminPage->clickToolbarButton('Save'); + } + + /** + * @When I choose menu item type :arg1 and Menu :arg2 + */ + public function iChooseMenuItemTypeAndMenu($type, $menu) + { + $I = $this; + + $I->menuItemManagerPage->selectTypeAndMenu($type, $menu); + } + + /** + * @When I set the menu as :arg1 + */ + public function iSetTheMenuAs($name) + { + $I = $this; + + $I->adminPage->selectOptionInChosenById('jform_menutype', $name); + } + + /** + * @When I go to joomla home page + */ + public function iGoToJoomlaHomePage() + { + $I = $this; + + $I->amOnPage(FrontPage::$url); + } + + /** + * @Then I should see the menu item language as :arg1 + */ + public function iShouldSeeTheMenuItemLanguageAs($title) + { + $I = $this; + + $I->amOnPage(MenuItemManagerPage::$url); + $I->see($title, MenuItemManagerPage::$seeLanguage); + } + + /** + * @When I search and select menu Item with title :arg1 + */ + public function iSearchAndSelectMenuItemWithTitle($title) + { + $I = $this; + + $I->menuItemManagerPage->haveItemUsingSearch($title); + $I->adminPage->clickToolbarButton('edit'); + } +} \ No newline at end of file diff --git a/tests/codeception/_support/Step/Acceptance/Administrator/menu.php b/tests/codeception/_support/Step/Acceptance/Administrator/menu.php new file mode 100644 index 0000000000..7ae0c1b561 --- /dev/null +++ b/tests/codeception/_support/Step/Acceptance/Administrator/menu.php @@ -0,0 +1,170 @@ +amOnPage(MenuManagerPage::$url); + $I->adminPage->clickToolbarButton('New'); + } + + /** + * @When I check available tabs in menu + */ + public function iCheckAvailableTabsInMenu($tab1, $tab2) + { + $I = $this; + + $I->adminPage->clickToolbarButton('New'); + $I->waitForText('Menus: Add'); + } + + /** + * @Then I see available tabs :arg1, :arg2 + */ + public function iSeeAvailableTabs($tab1, $tab2) + { + $I = $this; + + $I->adminPage->verifyAvailableTabs([$tab1, $tab2]); + } + + /** + * @When I fill mandatory fields for creating menu + */ + public function iFillMandatoryFieldsForCreatingMenu(TableNode $title) + { + $I = $this; + + $I->adminPage->clickToolbarButton('New'); + + $totalRows = count($title->getRows()); + $lastIndex = ($totalRows - 1); + + // Iterate over all rows + foreach ($title->getRows() as $index => $row) + { + if ($index !== 0) + { + $I->fillField(MenuManagerPage::$title, $row[0]); + + if ($index == $lastIndex) + { + $I->adminPage->clickToolbarButton('Save'); + } + else + { + $I->adminPage->clickToolbarButton('Save & New'); + } + } + } + } + + /** + * @Then I should see the menu :arg1 is created + */ + public function iShouldSeeTheMenuIsCreated($menu) + { + $I = $this; + + $I->menuManagerPage->seeItemIsCreated($menu); + } + + /** + * @When I search and select menu with title :arg1 + */ + public function iSearchAndSelectMenuWithTitle($title) + { + $I = $this; + + $I->menuManagerPage->haveItemUsingSearch($title); + $I->adminPage->clickToolbarButton('edit'); + } + + /** + * @When I save the menu + */ + public function iSaveTheMenu() + { + $I = $this; + + $I->adminPage->waitForPageTitle('Menus: Add'); + $I->adminPage->clickToolbarButton('save & close'); + } + + /** + * @Given I have a menu with title :arg1 which needs to be trash + */ + public function iHaveAMenuWithTitleWhichNeedsToBeTrash($title) + { + $this->menuManagerPage->haveItemUsingSearch($title); + } + + /** + * @When I trash the menu + */ + public function iTrashTheMenu() + { + $I = $this; + + $I->adminPage->clickToolbarButton('trash'); + } + + /** + * @Then I should see the menu :arg1 in trash + */ + public function iShouldSeeTheMenuInTrash($title) + { + $I = $this; + + $I->menuManagerPage->seeItemInTrash($title, 'Menus'); + } + + /** + * @When I create new menu without field title + */ + public function iCreateNewMenuWithoutFieldTitle() + { + $I = $this; + + $I->amOnPage(MenuManagerPage::$url); + $I->adminPage->clickToolbarButton('New'); + + $I->waitForText('Menus: New Item'); + $I->adminPage->clickToolbarButton('Save'); + } + + /** + * @When I set menu Type as :arg1 + */ + public function iSetMenuTypeAs($menuType) + { + $I = $this; + + $I->adminPage->selectOptionInChosenById('jform_menutype', $menuType); } +} \ No newline at end of file diff --git a/tests/codeception/acceptance.suite.dist.yml b/tests/codeception/acceptance.suite.dist.yml index d13c965f4c..7a90babf4f 100644 --- a/tests/codeception/acceptance.suite.dist.yml +++ b/tests/codeception/acceptance.suite.dist.yml @@ -51,3 +51,5 @@ gherkin: - Step\Acceptance\Administrator\Admin - Step\Acceptance\Administrator\Extension - Step\Acceptance\Administrator\Banner + - Step\Acceptance\Administrator\Menu + - Step\Acceptance\Administrator\MenuItem diff --git a/tests/codeception/acceptance/menu.feature b/tests/codeception/acceptance/menu.feature new file mode 100644 index 0000000000..f49faef1e2 --- /dev/null +++ b/tests/codeception/acceptance/menu.feature @@ -0,0 +1,39 @@ +Feature: menu + In order to manage menu in the web + As an owner + I need to create modify trash publish and Unpublish menu + + Background: + When I Login into Joomla administrator with username "admin" and password "admin" + And I see the administrator dashboard + + Scenario: Verify available tabs in Menu + Given There is an menu link + When I check available tabs in menu + Then I see available tabs "Menu Details", "Permissions" + + Scenario: Create new menu + Given There is an menu link + When I fill mandatory fields for creating menu + | Title | + | Menu_1 | + Then I should see the menu "Menu_1" is created + + Scenario: Modify Menu + Given There is an menu link + When I search and select menu with title "Menu_1" + And I set the title as a "Modify_menu_1" + And I save the menu + Then I should see the menu "Modify_menu_1" is created + + Scenario: Trash menu + Given I have a menu with title "Modify_menu_1" which needs to be trash + When I trash the menu + Then I should see the menu "Modify_menu_1" in trash + + Scenario: Create menu without Title fails + Given There is an menu link + When I create new menu without field title + And I set menu Type as "Menu Type" + And I save the menu + Then I should see the "Invalid field: Title" diff --git a/tests/codeception/acceptance/menuItem.feature b/tests/codeception/acceptance/menuItem.feature new file mode 100644 index 0000000000..7a8f8f1a34 --- /dev/null +++ b/tests/codeception/acceptance/menuItem.feature @@ -0,0 +1,70 @@ +Feature: menu Item + In order to manage menu item in the web + As an owner + I need to create modify trash publish and Unpublish menu item + + Background: + When I Login into Joomla administrator with username "admin" and password "admin" + And I see the administrator dashboard + + Scenario: Verify available tabs in Menu Items + Given There is an menu item link + When I check available tabs in menu item + Then I see the available tabs "Details", "Link Type", "Page Display", "Metadata", "Module Assignment" + + Scenario: Create new menu item + Given There is an menu item link + When I fill mandatory fields for creating menu item + | Title | + | MenuItem_1 | + Then I should see the menu item "MenuItem_1" is created + + Scenario: Modify Menu Item + Given There is an menu item link + When I search and select menu Item with title "MenuItem_1" + And I set the title as a "Modify_menuItem_1" + And I save the menu item + Then I should see the menu item "Modify_menuItem_1" is created + + Scenario: Unpublish menu item + Given I have a menu item with title "Modify_menuItem_1" which needs to be unpublished + When I unpublish the menu item + Then I should see the menu item is now unpublished + + Scenario: Trash menu item + Given I have a menu item with title "Modify_menuItem_1" which needs to be trash + When I trash the menu item + Then I should see the menu "Modify_menuItem_1" in trash + + Scenario: Create menu without Title fails + Given There is an menu item link + When I create new menu item without field title + And I choose menu item type "Archived Articles" and Menu "Main Menu" + And I save the menu item + Then I should see error "Invalid field: Title" + + Scenario: Create menu item for newly created menu + Given There is an menu link + When I fill mandatory fields for creating menu + | Title | + | Menu_1 | + Then I should see the menu "Menu" is created + And I create menu item with title "menuItem_2" + And I choose menu item type "Archived Articles" and Menu "Menu_1" + And I save the menu item + Then I should see the menu item "menuItem_2" is created + + Scenario: Change menu Item's Menu + Given There is an menu item link + When I search and select menu Item with title "menuItem_2" + And I set the menu as "Main Menu" + And I go to joomla home page + Then I should see "menuItem_2" + + Scenario: Menu item Language settings + Given There is an menu item link + When I search and select menu Item with title "menuItem_2" + And I set language as a "English (en-GB)" + And I save the menu item + Then I should see the menu item language as "English (en-GB)" +