Skip to content

Commit

Permalink
Optimise Smart menu behat features for dynamic courses and rules (moo…
Browse files Browse the repository at this point in the history
…dle-an-hochschulen#765).

This performs several optimisations to make these tests a lot faster.

Creation of smart menus and menu item has been changed to use
generators, rather than filling the forms each time.

Manual navigation has been replaced with `I am on the 'identifier'
'type'
page` as much as possible.

The assertions being made have been optimised. Previously, every
assertion of what was in a menu was opening each menu location and
checking for each item. Given that there's no option to display
different items when a menu is in different location, a lot of this is
redunant, and actually opening each menu takes time.

I have optimised this so that one scenario does a check that the menu
opens and the items are actually visible. Then each scenario tests than
an expected item exists in each menu (without opening the menu) and
checks for subsequent items just check existance in a single menu. This
balances coverage of the different functionality with speed and
conciseness of tests.
  • Loading branch information
marxjohnson committed Nov 25, 2024
1 parent ec9542e commit fe3aa58
Show file tree
Hide file tree
Showing 6 changed files with 412 additions and 517 deletions.
8 changes: 2 additions & 6 deletions classes/form/smartmenu_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,8 @@ public function definition() {
}

// Add restriction as select element.
$rolecontext = [
smartmenu::BYADMIN_ALL => get_string('smartmenusbyadmin_all', 'theme_boost_union'),
smartmenu::BYADMIN_ADMINS => get_string('smartmenusbyadmin_admins', 'theme_boost_union'),
smartmenu::BYADMIN_NONADMINS => get_string('smartmenusbyadmin_nonadmins', 'theme_boost_union'),
];
$mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $rolecontext);
$byadminoptions = smartmenu::get_byadmin_options();
$mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $byadminoptions);
$mform->setDefault('byadmin', smartmenu::BYADMIN_ALL);
$mform->setType('byadmin', PARAM_INT);
$mform->addHelpButton('byadmin', 'smartmenusbyadmin', 'theme_boost_union');
Expand Down
8 changes: 2 additions & 6 deletions classes/form/smartmenu_item_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,8 @@ public function definition() {
}

// Add restriction as select element.
$rolecontext = [
smartmenu::BYADMIN_ALL => get_string('smartmenusbyadmin_all', 'theme_boost_union'),
smartmenu::BYADMIN_ADMINS => get_string('smartmenusbyadmin_admins', 'theme_boost_union'),
smartmenu::BYADMIN_NONADMINS => get_string('smartmenusbyadmin_nonadmins', 'theme_boost_union'),
];
$mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $rolecontext);
$byadminoptions = smartmenu::get_byadmin_options();
$mform->addElement('select', 'byadmin', get_string('smartmenusbyadmin', 'theme_boost_union'), $byadminoptions);
$mform->setDefault('byadmin', smartmenu::BYADMIN_ALL);
$mform->setType('byadmin', PARAM_INT);
$mform->addHelpButton('byadmin', 'smartmenusbyadmin', 'theme_boost_union');
Expand Down
Loading

0 comments on commit fe3aa58

Please sign in to comment.