Skip to content

Commit

Permalink
Tests: Add several Behat optimisations to bring down the test suite r…
Browse files Browse the repository at this point in the history
…un time, resolves #765
  • Loading branch information
abias committed Dec 8, 2024
1 parent 131fc1d commit 73ad514
Show file tree
Hide file tree
Showing 12 changed files with 1,900 additions and 743 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2024-12-06 - Tests: Add several Behat optimisations to bring down the test suite run time, resolves #765.
* 2024-12-06 - Upstream change: Adopt changes from MDL-83759 ('System notification navbar popover is misplaced in Moodle 4.4 and 4.5')
* 2024-12-06 - Upstream change: Adopt changes from MDL-75610 ('Quiz activity name no longer being displayed in quiz landing page when using Safe Exam Browser'), resolves #766.
* 2024-11-19 - Bugfix: Port the activity icon sizes in the nav drawer back to stable versions, resolves #755.
Expand Down
61 changes: 10 additions & 51 deletions classes/form/smartmenu_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ public function definition() {
$mform->addRule('location', get_string('required'), 'required');

// Add mode as select element.
$modeoptions = [
smartmenu::MODE_SUBMENU => get_string('smartmenusmodesubmenu', 'theme_boost_union'),
smartmenu::MODE_INLINE => get_string('smartmenusmodeinline', 'theme_boost_union'),
];
$modeoptions = smartmenu::get_mode_options();
$mform->addElement('select', 'mode', get_string('smartmenusmenumode', 'theme_boost_union'), $modeoptions);
$mform->setDefault('mode', smartmenu::MODE_SUBMENU);
$mform->setType('mode', PARAM_INT);
Expand All @@ -102,24 +99,15 @@ public function definition() {
$mform->addHelpButton('type', 'smartmenusmenutype', 'theme_boost_union');

// Add show description as select element.
$showdescriptionoptions = [
smartmenu::DESC_NEVER => get_string('smartmenusmenushowdescriptionnever', 'theme_boost_union'),
smartmenu::DESC_ABOVE => get_string('smartmenusmenushowdescriptionabove', 'theme_boost_union'),
smartmenu::DESC_BELOW => get_string('smartmenusmenushowdescriptionbelow', 'theme_boost_union'),
smartmenu::DESC_HELP => get_string('smartmenusmenushowdescriptionhelp', 'theme_boost_union'),
];
$showdescriptionoptions = smartmenu::get_showdescription_options();
$mform->addElement('select', 'showdesc', get_string('smartmenusmenushowdescription', 'theme_boost_union'),
$showdescriptionoptions);
$mform->setDefault('showdesc', smartmenu::DESC_NEVER);
$mform->setType('showdesc', PARAM_INT);
$mform->addHelpButton('showdesc', 'smartmenusmenushowdescription', 'theme_boost_union');

// Add more menu behavior as select element.
$moremenuoptions = [
smartmenu::MOREMENU_DONOTCHANGE => get_string('dontchange', 'theme_boost_union'),
smartmenu::MOREMENU_INTO => get_string('smartmenusmenumoremenubehaviorforceinto', 'theme_boost_union'),
smartmenu::MOREMENU_OUTSIDE => get_string('smartmenusmenumoremenubehaviorkeepoutside', 'theme_boost_union'),
];
$moremenuoptions = smartmenu::get_moremenu_options();
$mform->addElement('select', 'moremenubehavior', get_string('smartmenusmenumoremenubehavior', 'theme_boost_union'),
$moremenuoptions);
$mform->setDefault('moremenubehavior', smartmenu::MOREMENU_DONOTCHANGE);
Expand All @@ -132,29 +120,15 @@ public function definition() {
$mform->setType('cssclass', PARAM_TEXT);

// Add card size as select element.
$cardsizeoptions = [
smartmenu::CARDSIZE_TINY => get_string('smartmenusmenucardsizetiny', 'theme_boost_union').' (50px)',
smartmenu::CARDSIZE_SMALL => get_string('smartmenusmenucardsizesmall', 'theme_boost_union').' (100px)',
smartmenu::CARDSIZE_MEDIUM => get_string('smartmenusmenucardsizemedium', 'theme_boost_union').' (150px)',
smartmenu::CARDSIZE_LARGE => get_string('smartmenusmenucardsizelarge', 'theme_boost_union').' (200px)',
];
$cardsizeoptions = smartmenu::get_cardsize_options();
$mform->addElement('select', 'cardsize', get_string('smartmenusmenucardsize', 'theme_boost_union'), $cardsizeoptions);
$mform->setDefault('cardsize', smartmenu::CARDSIZE_TINY);
$mform->setType('cardsize', PARAM_INT);
$mform->hideIf('cardsize', 'type', 'neq', smartmenu::TYPE_CARD);
$mform->addHelpButton('cardsize', 'smartmenusmenucardsize', 'theme_boost_union');

// Add card form as select element.
$cardformoptions = [
smartmenu::CARDFORM_SQUARE =>
get_string('smartmenusmenucardformsquare', 'theme_boost_union').' (1/1)',
smartmenu::CARDFORM_PORTRAIT =>
get_string('smartmenusmenucardformportrait', 'theme_boost_union').' (2/3)',
smartmenu::CARDFORM_LANDSCAPE =>
get_string('smartmenusmenucardformlandscape', 'theme_boost_union').' (3/2)',
smartmenu::CARDFORM_FULLWIDTH =>
get_string('smartmenusmenucardformfullwidth', 'theme_boost_union'),
];
$cardformoptions = smartmenu::get_cardform_options();
$mform->addElement('select', 'cardform',
get_string('smartmenusmenucardform', 'theme_boost_union'), $cardformoptions);
$mform->setDefault('cardform', smartmenu::CARDFORM_SQUARE);
Expand All @@ -163,12 +137,7 @@ public function definition() {
$mform->addHelpButton('cardform', 'smartmenusmenucardform', 'theme_boost_union');

// Add card overflow behaviour as select element.
$cardoverflowoptions = [
smartmenu::CARDOVERFLOWBEHAVIOUR_NOWRAP =>
get_string('smartmenusmenucardoverflowbehaviornowrap', 'theme_boost_union'),
smartmenu::CARDOVERFLOWBEHAVIOUR_WRAP =>
get_string('smartmenusmenucardoverflowbehaviorwrap', 'theme_boost_union'),
];
$cardoverflowoptions = smartmenu::get_cardoverflowbehaviour_options();
$mform->addElement('select', 'cardoverflowbehavior',
get_string('smartmenusmenucardoverflowbehavior', 'theme_boost_union'), $cardoverflowoptions);
$mform->setDefault('cardoverflowbehaviour', smartmenu::CARDOVERFLOWBEHAVIOUR_NOWRAP);
Expand Down Expand Up @@ -199,10 +168,7 @@ public function definition() {
$mform->addHelpButton('roles', 'smartmenusbyrole', 'theme_boost_union');

// Add context as select element.
$rolecontext = [
smartmenu::ANYCONTEXT => get_string('any'),
smartmenu::SYSTEMCONTEXT => get_string('coresystem'),
];
$rolecontext = smartmenu::get_rolecontext_options();
$mform->addElement('select', 'rolecontext', get_string('smartmenusrolecontext', 'theme_boost_union'), $rolecontext);
$mform->setDefault('rolecontext', smartmenu::ANYCONTEXT);
$mform->setType('rolecontext', PARAM_INT);
Expand All @@ -216,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 Expand Up @@ -249,10 +211,7 @@ public function definition() {
$mform->addHelpButton('cohorts', 'smartmenusbycohort', 'theme_boost_union');

// Add operator as select element.
$operatoroptions = [
smartmenu::ANY => get_string('any'),
smartmenu::ALL => get_string('all'),
];
$operatoroptions = smartmenu::get_operator_options();
$mform->addElement('select', 'operator', get_string('smartmenusoperator', 'theme_boost_union'), $operatoroptions);
$mform->setDefault('operator', smartmenu::ANY);
$mform->setType('operator', PARAM_INT);
Expand Down
87 changes: 12 additions & 75 deletions classes/form/smartmenu_item_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ public function definition() {
$mform->addHelpButton('url', 'smartmenusmenuitemurl', 'theme_boost_union');

// Add mode as select element.
$modeoptions = [
smartmenu_item::MODE_INLINE => get_string('smartmenusmodeinline', 'theme_boost_union'),
smartmenu_item::MODE_SUBMENU => get_string('smartmenusmodesubmenu', 'theme_boost_union'),
];
$modeoptions = smartmenu_item::get_mode_options();
$mform->addElement('select', 'mode', get_string('smartmenusmenuitemmode', 'theme_boost_union'), $modeoptions);
$mform->setDefault('mode', smartmenu_item::MODE_INLINE);
$mform->setType('mode', PARAM_INT);
Expand Down Expand Up @@ -138,14 +135,7 @@ public function definition() {
$mform->addHelpButton('enrolmentrole', 'smartmenusdynamiccoursesenrolmentrole', 'theme_boost_union');

// Add completion status (for the dynamic courses menu item type) as autocomplete element.
$completionstatusoptions = [
smartmenu_item::COMPLETION_ENROLLED =>
get_string('smartmenusdynamiccoursescompletionstatusenrolled', 'theme_boost_union'),
smartmenu_item::COMPLETION_INPROGRESS =>
get_string('smartmenusdynamiccoursescompletionstatusinprogress', 'theme_boost_union'),
smartmenu_item::COMPLETION_COMPLETED =>
get_string('smartmenusdynamiccoursescompletionstatuscompleted', 'theme_boost_union'),
];
$completionstatusoptions = smartmenu_item::get_completionstatus_options();
$completionstatuswidget = $mform->addElement('autocomplete', 'completionstatus',
get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '.
get_string('smartmenusdynamiccoursescompletionstatus', 'theme_boost_union'), $completionstatusoptions);
Expand All @@ -155,14 +145,7 @@ public function definition() {
$mform->addHelpButton('completionstatus', 'smartmenusdynamiccoursescompletionstatus', 'theme_boost_union');

// Add date range (for the dynamic courses menu item type) as autocomplete element.
$daterangeoptions = [
smartmenu_item::RANGE_PAST =>
get_string('smartmenusdynamiccoursesdaterangepast', 'theme_boost_union'),
smartmenu_item::RANGE_PRESENT =>
get_string('smartmenusdynamiccoursesdaterangepresent', 'theme_boost_union'),
smartmenu_item::RANGE_FUTURE =>
get_string('smartmenusdynamiccoursesdaterangefuture', 'theme_boost_union'),
];
$daterangeoptions = smartmenu_item::get_daterange_options();
$daterangewidget = $mform->addElement('autocomplete', 'daterange',
get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '.
get_string('smartmenusdynamiccoursesdaterange', 'theme_boost_union'), $daterangeoptions);
Expand Down Expand Up @@ -196,13 +179,7 @@ public function definition() {
$PAGE->requires->js_call_amd('theme_boost_union/fontawesome-popover', 'init', ['#id_menuicon', $systemcontextid]);

// Add title presentation and select element.
$displayoptions = [
smartmenu_item::DISPLAY_SHOWTITLEICON =>
get_string('smartmenusmenuitemdisplayoptionsshowtitleicon', 'theme_boost_union'),
smartmenu_item::DISPLAY_HIDETITLE => get_string('smartmenusmenuitemdisplayoptionshidetitle', 'theme_boost_union'),
smartmenu_item::DISPLAY_HIDETITLEMOBILE =>
get_string('smartmenusmenuitemdisplayoptionshidetitlemobile', 'theme_boost_union'),
];
$displayoptions = smartmenu_item::get_display_options();
$mform->addElement('select', 'display', get_string('smartmenusmenuitemdisplayoptions', 'theme_boost_union'),
$displayoptions);
$mform->setDefault('display', smartmenu_item::DISPLAY_SHOWTITLEICON);
Expand All @@ -215,10 +192,7 @@ public function definition() {
$mform->addHelpButton('tooltip', 'smartmenusmenuitemtooltip', 'theme_boost_union');

// Add link target as select element.
$targetoptions = [
smartmenu_item::TARGET_SAME => get_string('smartmenusmenuitemlinktargetsamewindow', 'theme_boost_union'),
smartmenu_item::TARGET_NEW => get_string('smartmenusmenuitemlinktargetnewtab', 'theme_boost_union'),
];
$targetoptions = smartmenu_item::get_target_options();
$mform->addElement('select', 'target', get_string('smartmenusmenuitemlinktarget', 'theme_boost_union'),
$targetoptions);
$mform->setDefault('target', smartmenu_item::TARGET_SAME);
Expand Down Expand Up @@ -256,24 +230,7 @@ public function definition() {
$mform->addHelpButton('cssclass', 'smartmenusmenuitemcssclass', 'theme_boost_union');

// Add course list ordering (for the dynamic courses menu item type) as select element.
$listsortoptions = [
smartmenu_item::LISTSORT_FULLNAME_ASC =>
get_string('smartmenusmenuitemlistsortfullnameasc', 'theme_boost_union'),
smartmenu_item::LISTSORT_FULLNAME_DESC =>
get_string('smartmenusmenuitemlistsortfullnamedesc', 'theme_boost_union'),
smartmenu_item::LISTSORT_SHORTNAME_ASC =>
get_string('smartmenusmenuitemlistsortshortnameasc', 'theme_boost_union'),
smartmenu_item::LISTSORT_SHORTNAME_DESC =>
get_string('smartmenusmenuitemlistsortshortnamedesc', 'theme_boost_union'),
smartmenu_item::LISTSORT_COURSEID_ASC =>
get_string('smartmenusmenuitemlistsortcourseidasc', 'theme_boost_union'),
smartmenu_item::LISTSORT_COURSEID_DESC =>
get_string('smartmenusmenuitemlistsortcourseiddesc', 'theme_boost_union'),
smartmenu_item::LISTSORT_COURSEIDNUMBER_ASC =>
get_string('smartmenusmenuitemlistsortcourseidnumberasc', 'theme_boost_union'),
smartmenu_item::LISTSORT_COURSEIDNUMBER_DESC =>
get_string('smartmenusmenuitemlistsortcourseidnumberdesc', 'theme_boost_union'),
];
$listsortoptions = smartmenu_item::get_listsort_options();
$mform->addElement('select', 'listsort',
get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '.
get_string('smartmenusmenuitemlistsort', 'theme_boost_union'), $listsortoptions);
Expand All @@ -283,10 +240,7 @@ public function definition() {
$mform->addHelpButton('listsort', 'smartmenusmenuitemlistsort', 'theme_boost_union');

// Add course name presentation (for the dynamic courses menu item type) as select element.
$displayfieldoptions = [
smartmenu_item::FIELD_FULLNAME => get_string('smartmenusmenuitemdisplayfieldcoursefullname', 'theme_boost_union'),
smartmenu_item::FIELD_SHORTNAME => get_string('smartmenusmenuitemdisplayfieldcourseshortname', 'theme_boost_union'),
];
$displayfieldoptions = smartmenu_item::get_displayfield_options();
$mform->addElement('select', 'displayfield',
get_string('smartmenusmenuitemtypedynamiccourses', 'theme_boost_union').': '.
get_string('smartmenusmenuitemdisplayfield', 'theme_boost_union'), $displayfieldoptions);
Expand Down Expand Up @@ -318,14 +272,7 @@ public function definition() {
$mform->addHelpButton('image', 'smartmenusmenuitemcardimage', 'theme_boost_union');

// Add card text position as select element.
$textpositionoptions = [
smartmenu_item::POSITION_BELOW =>
get_string('smartmenusmenuitemtextpositionbelowimage', 'theme_boost_union'),
smartmenu_item::POSITION_OVERLAYTOP =>
get_string('smartmenusmenuitemtextpositionoverlaytop', 'theme_boost_union'),
smartmenu_item::POSITION_OVERLAYBOTTOM =>
get_string('smartmenusmenuitemtextpositionoverlaybottom', 'theme_boost_union'),
];
$textpositionoptions = smartmenu_item::get_textposition_options();
$mform->addElement('select', 'textposition',
get_string('smartmenusmenuitemtextposition', 'theme_boost_union'), $textpositionoptions);
$mform->setDefault('textposition', smartmenu_item::POSITION_BELOW);
Expand Down Expand Up @@ -368,10 +315,7 @@ public function definition() {
$mform->addHelpButton('roles', 'smartmenusbyrole', 'theme_boost_union');

// Add context as select element.
$rolecontext = [
smartmenu::ANYCONTEXT => get_string('any'),
smartmenu::SYSTEMCONTEXT => get_string('coresystem'),
];
$rolecontext = smartmenu::get_rolecontext_options();
$mform->addElement('select', 'rolecontext', get_string('smartmenusrolecontext', 'theme_boost_union'), $rolecontext);
$mform->setDefault('rolecontext', smartmenu::ANYCONTEXT);
$mform->setType('rolecontext', PARAM_INT);
Expand All @@ -385,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 Expand Up @@ -418,10 +358,7 @@ public function definition() {
$mform->addHelpButton('cohorts', 'smartmenusbycohort', 'theme_boost_union');

// Add operator as select element.
$operatoroptions = [
smartmenu::ANY => get_string('any'),
smartmenu::ALL => get_string('all'),
];
$operatoroptions = smartmenu::get_operator_options();
$mform->addElement('select', 'operator', get_string('smartmenusoperator', 'theme_boost_union'), $operatoroptions);
$mform->setDefault('operator', smartmenu::ANY);
$mform->setType('operator', PARAM_INT);
Expand Down
Loading

0 comments on commit 73ad514

Please sign in to comment.