MDL-76169 behat: Add improved steps for using action menus

This commit adds new steps related to action menus to support:
* Choosing an item in a named action menu
* Choosing an item in a named action menu within a container
* Confirming that an action menu item does or does not exist in a named
  action menu
* Confirming that an action menu item does or does not exist in a named
  action menu within a container

The existing action menu steps were insufficient as they assume that
there is only one action menu within he container, which is not
necessarily the case.

The existing action menu steps are not non-JS friendly and will error if
JS is disabled, without providing any fallback when one is easily
available.

Unfortunately these steps cannot be used to replace the existing steps
without manual intervention.
This commit is contained in:
Andrew Nicols 2022-11-02 10:36:37 +08:00
parent 720bd60fc6
commit 232ebac338
3 changed files with 159 additions and 29 deletions

View file

@ -86,6 +86,7 @@ class behat_partial_named_selector extends \Behat\Mink\Selector\PartialNamedSele
*/
protected static $allowedselectors = array(
'activity' => 'activity',
'actionmenu' => 'actionmenu',
'badge' => 'badge',
'block' => 'block',
'button' => 'button',
@ -138,6 +139,17 @@ class behat_partial_named_selector extends \Behat\Mink\Selector\PartialNamedSele
protected static $moodleselectors = array(
'activity' => <<<XPATH
.//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][descendant::*[contains(normalize-space(.), %locator%)]]
XPATH
, 'actionmenu' => <<<XPATH
.//*[
contains(concat(' ', normalize-space(@class), ' '), ' action-menu ')
and
descendant::*[
contains(concat(' ', normalize-space(@class), ' '), ' dropdown-toggle ')
and
contains(normalize-space(.), %locator%)
]
]
XPATH
, 'badge' => <<<XPATH
.//span[(contains(@class, 'badge')) and text()[contains(., %locator%)]]