Skip to content

Commit

Permalink
Partial optimisation of behat tests for Smart menu presentation (#765)
Browse files Browse the repository at this point in the history
As with other smart menu features, this uses generators, navigation
steps and named selectors to speed up the tests. There is more that can
be done to the feature, as time allows.
  • Loading branch information
marxjohnson committed Nov 22, 2024
1 parent 8f8b06d commit 8a2d987
Showing 1 changed file with 37 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,33 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, app
And the following "users" exist:
| username |
| user1 |
And I create smart menu with the following fields to these values:
| Title | Quick links |
| Menu location(s) | Main, Menu, User, Bottom |
And the following "theme_boost_union > smart menu" exists:
| title | Quick links |
| location | Main navigation, Menu bar, User menu, Bottom bar |

@javascript
Scenario Outline: Smartmenus: Menu items: Presentation - Open the smart menu items in different targets
Given the following "theme_boost_union > Smart menu item" exists:
| menu | Quick links |
| title | Available courses |
| itemtype | Dynamic courses |
| category | Category 1 |
| itemmode | Inline |
| target | <setting> |
When I log in as "admin"
And I set "Quick links" smart menu items with the following fields to these values:
| Title | Available courses |
| Menu item type | Dynamic courses |
| Dynamic courses: Course category | Category 1 |
| Menu item mode | Inline |
| Link target | <setting> |
And I should see "Available courses" in the "smartmenus_items" "table"
# Menu items in main navigation
Then "Test course 1" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > Main menu smart menu"
Then I should see smart menu "Quick links" item "Test course1" in location "Main"
And the "target" attribute of "//div[@class='primary-navigation']//a[contains(normalize-space(.), 'Test course1')]" "xpath_element" <should>
# Menu items in user menu.
And I should see smart menu "Quick links" item "Test course1" in location "User"
Then "Test course 1" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > User menu smart menu"
And the "target" attribute of "//div[contains(@class, 'carousel-item')]//a[contains(normalize-space(.), 'Test course1')]" "xpath_element" <should>
# Menu items in bottom menu.
Then I should see smart menu "Quick links" item "Test course1" in location "Bottom"
Then "Test course 1" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > Bottom bar smart menu"
And the "target" attribute of "//div[@class='bottom-navigation']//a[contains(normalize-space(.), 'Test course1')]" "xpath_element" <should>
Then I change the viewport size to "large"
# Menu items in menubar.
And I should see smart menu "Quick links" item "Test course1" in location "Menu"
Then "Test course 1" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > Menu bar smart menu"
And the "target" attribute of "//nav[contains(@class, 'menubar')]//a[contains(normalize-space(.), 'Test course1')]" "xpath_element" <should>

Examples:
Expand All @@ -49,18 +50,18 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, app

@javascript
Scenario: Smartmenus: Menu items: Presentation - Include the custom css class for a smart menu item
When I log in as "admin"
Given the following "theme_boost_union > Smart menu item" exists:
| menu | Quick links |
| title | Resources |
| itemtype | Static |
| url | http://moodle.org |
| cssclass | static-item-resources |
And I set "Quick links" smart menu items with the following fields to these values:
| Title | Resources |
| Menu item type | Static |
| Menu item URL | http://moodle.org |
And I navigate to smart menu "Quick links" items
And I click on ".action-edit" "css_element" in the "Resources" "table_row"
And I expand all fieldsets
And I set the field "CSS class" to "static-item-resources"
And I click on "Save changes" "button"
And I should see "Resources" in the "smartmenus_items" "table"
And the "class" attribute of "//div[@class='primary-navigation']//a[contains(normalize-space(.), 'Resources')]" "xpath_element" should contain "static-item-resources"
When I log in as "admin"
Then the "class" attribute of "//div[@class='primary-navigation']//a[contains(normalize-space(.), 'Resources')]" "xpath_element" should contain "static-item-resources"
And the "class" attribute of "//div[contains(@class, 'carousel-item')]//a[contains(normalize-space(.), 'Resources')]" "xpath_element" should contain "static-item-resources"
And the "class" attribute of "//nav[contains(@class, 'menubar')]//a[contains(normalize-space(.), 'Resources')]" "xpath_element" should contain "static-item-resources"
And I change the viewport size to "740x900"
Expand All @@ -82,16 +83,22 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, app

@javascript
Scenario Outline: Smartmenus: Menu items: Presentation - Display the different fields as smart menu item title
Given the following "theme_boost_union > Smart menu item" exists:
| menu | Quick links |
| title | Available courses |
| itemtype | Dynamic courses |
| category | Category 1 |
| displayfield | <selectnamefield> |
| textcount | <numberofwords> |
When I log in as "admin"
And I set "Quick links" smart menu items with the following fields to these values:
| Title | Available courses |
| Menu item type | Dynamic courses |
| Dynamic courses: Course category | Category 1 |
| Dynamic courses: Course name presentation | <selectnamefield> |
| Dynamic courses: Number of words | <numberofwords> |
And I should see "Available courses" in the "smartmenus_items" "table"
And I should see smart menu "Quick links" item "<showntitle>" in location "Main, Menu, User, Bottom"
And I should not see smart menu "Quick links" item "<notshowntitle>" in location "Main, Menu, User, Bottom"
Then "<showntitle>" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > Main menu smart menu"
And "<showntitle>" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > Menu bar smart menu"
And "<showntitle>" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > User menu smart menu"
And "<showntitle>" "theme_boost_union > Smart menu item" should exist in the "Quick links" "theme_boost_union > Bottom bar smart menu"
And "<notshowntitle>" "theme_boost_union > Smart menu item" should not exist in the "Quick links" "theme_boost_union > Main menu smart menu"
And "<notshowntitle>" "theme_boost_union > Smart menu item" should not exist in the "Quick links" "theme_boost_union > Menu bar smart menu"
And "<notshowntitle>" "theme_boost_union > Smart menu item" should not exist in the "Quick links" "theme_boost_union > User menu smart menu"
And "<notshowntitle>" "theme_boost_union > Smart menu item" should not exist in the "Quick links" "theme_boost_union > Bottom bar smart menu"

Examples:
| selectnamefield | numberofwords | showntitle | notshowntitle |
Expand Down

0 comments on commit 8a2d987

Please sign in to comment.