Skip to content

Commit

Permalink
MDL-78203 behat: adding subpanels to action menu step
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranrecio committed Aug 11, 2023
1 parent fc37e6c commit 5151dc5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/tests/behat/behat_action_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public function i_open_the_action_menu_in($element, $selectortype) {
/**
* When an action menu is open, follow one of the items in it.
*
* The > is used to indicate a sub-menu. For example "Group mode > Visible groups"
* will do two clicks, one on the Group mode menu item, and one on the Visible groups link
* in the sub-menu.
*
* @Given /^I choose "(?P<link_string>(?:[^"]|\\")*)" in the open action menu$/
* @param string $linkstring
* @return void
Expand All @@ -77,11 +81,16 @@ public function i_choose_in_the_open_action_menu($menuitemstring) {
if (!$this->running_javascript()) {
throw new DriverException('Action menu steps are not available with Javascript disabled');
}
// Gets the node based on the requested selector type and locator.
$menuselector = ".moodle-actionmenu .dropdown.show .dropdown-menu";
$node = $this->get_node_in_container("link", $menuitemstring, "css_element", $menuselector);
$this->ensure_node_is_visible($node);
$node->click();
// Check for sub-menus.
$menuitems = explode('>', $menuitemstring);
foreach ($menuitems as $menuitem) {
// Gets the node based on the requested selector type and locator.
$menuselector = ".moodle-actionmenu .dropdown.show .dropdown-menu";
$node = $this->get_node_in_container("link", trim($menuitem), "css_element", $menuselector);
$this->ensure_node_is_visible($node);
$node->click();
}

}

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ information provided here is intended especially for developers.
- core\output\local\dropdown\dialog to display HTML inside a dropdown element.
- core\output\local\dropdown\status to render a user choice into a dropdown.
- core\output\choicelist class to render a list of user choices. It combines with dropdown status and action menu subpanels.
* The behat step I choose "WHATEVER" in the open action menu is now compatible with action menus subpanels
using the ">" symbol to suparate the item link text and subitem one. For example:
- I choose "Group mode > Visible groups" in the open action menu

=== 4.2 ===

Expand Down

0 comments on commit 5151dc5

Please sign in to comment.