From f6e31a3d4157f3caead569d13c8ee3ea22f572bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikel=20Mart=C3=ADn?= Date: Tue, 3 Dec 2024 16:06:49 +0100 Subject: [PATCH] MDL-75669 theme_boost: Fix BS5 related behat steps and scenarios - Fix some behat steps and scenarios that are failing because of Bootstrap 5 syntax changes. - Add a new $behatsite SCSS variable when behat is runinng that disables Bootstrap transitions and effects. --- course/tests/behat/activity_chooser_plus.feature | 2 +- lib/tests/behat/behat_action_menu.php | 2 +- mod/assign/tests/behat/assign_anonymous_submission.feature | 2 +- theme/boost/lib.php | 5 +++++ theme/boost/scss/preset/default.scss | 5 +++++ theme/classic/lib.php | 5 +++++ theme/classic/scss/preset/default.scss | 7 +++++-- 7 files changed, 23 insertions(+), 5 deletions(-) diff --git a/course/tests/behat/activity_chooser_plus.feature b/course/tests/behat/activity_chooser_plus.feature index f87a7baf37b..94827b9276a 100644 --- a/course/tests/behat/activity_chooser_plus.feature +++ b/course/tests/behat/activity_chooser_plus.feature @@ -34,7 +34,7 @@ Feature: Use the activity chooser to insert activities anywhere in a section Given I change window size to "large" And I hover "Insert content before 'Test Forum'" "button" And I press "Insert content before 'Test Forum'" - And I click on "Activity or resource" "button" in the ".dropdown .show" "css_element" + And I click on "Activity or resource" "button" in the ".dropdown-menu.show" "css_element" When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" And I set the following fields to these values: | Assignment name | Test Assignment | diff --git a/lib/tests/behat/behat_action_menu.php b/lib/tests/behat/behat_action_menu.php index 3e69218bdd2..2005d322c0b 100644 --- a/lib/tests/behat/behat_action_menu.php +++ b/lib/tests/behat/behat_action_menu.php @@ -84,7 +84,7 @@ class behat_action_menu extends behat_base { $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"; + $menuselector = ".moodle-actionmenu .dropdown .dropdown-menu.show"; $node = $this->get_node_in_container("link", trim($menuitem), "css_element", $menuselector); $node->click(); } diff --git a/mod/assign/tests/behat/assign_anonymous_submission.feature b/mod/assign/tests/behat/assign_anonymous_submission.feature index a4ec447a56e..0975ea6740f 100644 --- a/mod/assign/tests/behat/assign_anonymous_submission.feature +++ b/mod/assign/tests/behat/assign_anonymous_submission.feature @@ -39,7 +39,7 @@ Feature: Teacher can enable anonymous submissions for an assignment And I set the field "Grade out of 100" to "70" And I press "Save changes" And I am on the "Assign 1" "assign activity" page - And I follow "Reveal student identities" + And I navigate to "Reveal student identities" in current page administration And I should see "Are you sure you want to reveal student identities for this assignment? This operation cannot be undone. Once the student identities have been revealed, the marks will be released to the gradebook." And I press "Continue" # Confirm that student identity is no longer hidden and grade is retained diff --git a/theme/boost/lib.php b/theme/boost/lib.php index 755fc42623a..3207cfe683c 100644 --- a/theme/boost/lib.php +++ b/theme/boost/lib.php @@ -179,6 +179,11 @@ function theme_boost_get_pre_scss($theme) { }, (array) $targets); } + // Add a new variable to indicate that we are running behat. + if (defined('BEHAT_SITE_RUNNING')) { + $scss .= "\$behatsite: true;\n"; + } + // Prepend pre-scss. if (!empty($theme->settings->scsspre)) { $scss .= $theme->settings->scsspre; diff --git a/theme/boost/scss/preset/default.scss b/theme/boost/scss/preset/default.scss index 5d3b6ac6ced..561402dd30d 100644 --- a/theme/boost/scss/preset/default.scss +++ b/theme/boost/scss/preset/default.scss @@ -106,6 +106,11 @@ $spacers: ( 6: ($spacer * 3) ) !default; +// Behat site specific variable values. +$behatsite: false !default; +$enable-transitions: not $behatsite !default; +$enable-smooth-scroll: not $behatsite !default; + // Import FontAwesome. @import "fontawesome"; diff --git a/theme/classic/lib.php b/theme/classic/lib.php index 9861e6eb824..2711283effa 100644 --- a/theme/classic/lib.php +++ b/theme/classic/lib.php @@ -75,6 +75,11 @@ function theme_classic_get_pre_scss($theme) { }, (array) $targets); } + // Add a new variable to indicate that we are running behat. + if (defined('BEHAT_SITE_RUNNING')) { + $scss .= "\$behatsite: true;\n"; + } + // Prepend pre-scss. if (!empty($theme->settings->scsspre)) { $scss .= $theme->settings->scsspre; diff --git a/theme/classic/scss/preset/default.scss b/theme/classic/scss/preset/default.scss index 21f3e779b6d..c8b2648ed7d 100644 --- a/theme/classic/scss/preset/default.scss +++ b/theme/classic/scss/preset/default.scss @@ -37,14 +37,12 @@ $table-accent-bg: rgba($black, .03) !default; // Options $enable-rounded: true !default; -$enable-responsive-font-sizes: true !default; // Body $body-color: $gray-900 !default; // Fonts $font-size-base: 0.9375rem !default; -$rfs-base-font-size: 0.9rem !default; $headings-font-weight: 300 !default; // Navbar @@ -102,6 +100,11 @@ $spacers: ( 6: ($spacer * 3) ) !default; +// Behat site specific variable values. +$behatsite: false !default; +$enable-transitions: not $behatsite !default; +$enable-smooth-scroll: not $behatsite !default; + // Import FontAwesome. @import "fontawesome";