Skip to content

Commit

Permalink
Cleanup: Introduce a dedicated Behat step to deactivate and activate …
Browse files Browse the repository at this point in the history
…debugging, resolves #670 (#671)
  • Loading branch information
abias authored Jun 10, 2024
1 parent f42e9c3 commit bae668b
Show file tree
Hide file tree
Showing 18 changed files with 128 additions and 72 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-06-10 - Cleanup: Introduce a dedicated Behat step to deactivate and activate debugging, resolves #670.
* 2024-05-05 - Cleanup: Fix 'Implicitly marking a parameter as nullable is deprecated since PHP 8.4' codechecker warning, resolves #667.
* 2024-04-28 - Feature: Allow admins to configure URLs from where Boost Union will fetch additional raw SCSS code, resolves #41.
* 2024-05-13 - Improvement: Suppress icons in footer, resolves #649
Expand Down
24 changes: 24 additions & 0 deletions tests/behat/behat_theme_boost_union_base_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,28 @@ public function pseudoclass_content_none($s, $ps, $pr) {
public function purge_theme_cache_and_reload_theme() {
theme_reset_all_caches();
}

/**
* Disables debugging in Behat.
*
* We sometimes need to deactivate debugging for a while as Behat steps would otherwise fail due to the
* stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
* on Boost Union settings pages as we simply use too much hide_if() there.
*
* @Given /^Behat debugging is disabled$/
*/
public function disable_behat_debugging() {
set_config('debug', 0);
set_config('debugdisplay', 0);
}

/**
* Re-enables debugging in Behat.
*
* @Given /^Behat debugging is enabled$/
*/
public function enable_behat_debugging() {
set_config('debug', 32767);
set_config('debugdisplay', 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,13 @@ Feature: Configuring the theme_boost_union plugin for the "Advertisement tiles"
| tile2enabled | no | theme_boost_union |
| tile2content | This is a test content for tile 2 | theme_boost_union |
When I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Advertisement tiles" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/login_bg1.jpg" file to "Advertisement tile 1 background image" filemanager
And I press "Save changes"
And I am on site homepage
# We reactivate debugging again.
And the following config values are set as admin:
| debug | 32767 |
| debugdisplay | 1 |
And Behat debugging is enabled
And I log out
And I am on site homepage
And I follow "Log in"
Expand Down Expand Up @@ -232,21 +224,13 @@ Feature: Configuring the theme_boost_union plugin for the "Advertisement tiles"
| tile1content | This is a test content for tile 1 | theme_boost_union |
| tile1backgroundimageposition | <position> | theme_boost_union |
When I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Advertisement tiles" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/login_bg1.jpg" file to "Advertisement tile 1 background image" filemanager
And I press "Save changes"
And I am on site homepage
# We reactivate debugging again.
And the following config values are set as admin:
| debug | 32767 |
| debugdisplay | 1 |
And Behat debugging is enabled
And I log out
And I am on site homepage
And I follow "Log in"
Expand All @@ -266,12 +250,7 @@ Feature: Configuring the theme_boost_union plugin for the "Advertisement tiles"
| config | value | plugin |
| tile1enabled | yes | theme_boost_union |
When I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Advertisement tiles" "link" in the "#adminsettings .nav-tabs" "css_element"
Then "#admin-tile1title" "css_element" should be visible
Expand Down
12 changes: 2 additions & 10 deletions tests/behat/theme_boost_union_contentsettings_infobanners.feature
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,13 @@ Feature: Configuring the theme_boost_union plugin for the "Information banners"
And I should not see "This is a test content"
And I log out
When I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Info banner" "link" in the "#adminsettings .nav-tabs" "css_element"
And I click on "Reset visibility of info banner 1" "link"
And I click on "Confirm" "link"
Then I should see "The visibility of info banner 1 has been reset"
# We reactivate debugging again.
And the following config values are set as admin:
| debug | 32767 |
| debugdisplay | 1 |
And Behat debugging is enabled
And I log out
When I log in as "teacher1"
And I follow "Dashboard"
Expand Down
43 changes: 7 additions & 36 deletions tests/behat/theme_boost_union_contentsettings_slider.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ Feature: Configuring the theme_boost_union plugin for the "Slider" tab on the "C
| slide1caption | Slide 1 | theme_boost_union |
| slide1content | This is a test content for slide 1 | theme_boost_union |
When I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Slider" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/login_bg1.jpg" file to "Slide 1 background image" filemanager
And I press "Save changes"
And I am on site homepage
# We reactivate debugging again.
And the following config values are set as admin:
| debug | 32767 |
| debugdisplay | 1 |
And Behat debugging is enabled
And I log out

Scenario: Setting: Slider - Display the slider on the frontpage only and nowhere else
Expand Down Expand Up @@ -267,12 +259,7 @@ Feature: Configuring the theme_boost_union plugin for the "Slider" tab on the "C
| slide4linksource | 2 | theme_boost_union |
| slide4linktarget | new | theme_boost_union |
And I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Slider" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/login_bg1.jpg" file to "Slide 2 background image" filemanager
Expand All @@ -287,10 +274,7 @@ Feature: Configuring the theme_boost_union plugin for the "Slider" tab on the "C
And I upload "theme/boost_union/tests/fixtures/login_bg1.jpg" file to "Slide 4 background image" filemanager
And I press "Save changes"
And I am on site homepage
# We reactivate debugging again.
And the following config values are set as admin:
| debug | 32767 |
| debugdisplay | 1 |
And Behat debugging is enabled
And I log out
When I log in as "teacher1"
And I am on site homepage
Expand Down Expand Up @@ -336,12 +320,7 @@ Feature: Configuring the theme_boost_union plugin for the "Slider" tab on the "C
| slide6content | This is a test content for tile 6 | theme_boost_union |
| slide6order | <orders6> | theme_boost_union |
And I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Slider" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/login_bg1.jpg" file to "Slide 2 background image" filemanager
Expand All @@ -356,10 +335,7 @@ Feature: Configuring the theme_boost_union plugin for the "Slider" tab on the "C
And I upload "theme/boost_union/tests/fixtures/login_bg1.jpg" file to "Slide 6 background image" filemanager
And I press "Save changes"
And I am on site homepage
# We reactivate debugging again.
And the following config values are set as admin:
| debug | 32767 |
| debugdisplay | 1 |
And Behat debugging is enabled
And I log out
When I log in as "teacher1"
And I am on site homepage
Expand All @@ -381,12 +357,7 @@ Feature: Configuring the theme_boost_union plugin for the "Slider" tab on the "C
| config | value | plugin |
| slide1enabled | yes | theme_boost_union |
When I log in as "admin"
# We deactivate debugging for a while as the Behat step would otherwise fail due to the
# stupid 'Too much data passed as arguments to js_call_amd' debugging message which can't be avoided
# on this settings page. This debugging message can't be avoided as we simple use too much hide_if() there.
And the following config values are set as admin:
| debug | 0 |
| debugdisplay | 0 |
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Content" in site administration
And I click on "Slider" "link" in the "#adminsettings .nav-tabs" "css_element"
Then "#admin-slide1backgroundimage" "css_element" should be visible
Expand Down
8 changes: 8 additions & 0 deletions tests/behat/theme_boost_union_flavourssettings_look.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript @_file_upload
Scenario: Flavours: Compact logo - Upload a compact logo (with a global compact logo being overridden)
When I log in as "admin"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "Site branding" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/moodlelogo.png" file to "Compact logo" filemanager
And I click on "Save changes" "button"
And Behat debugging is enabled
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
Expand All @@ -48,10 +50,12 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript @_file_upload
Scenario: Flavours: Compact logo - Do not upload a compact logo (with a global compact logo being served properly)
When I log in as "admin"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "Site branding" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/moodlelogo.png" file to "Compact logo" filemanager
And I click on "Save changes" "button"
And Behat debugging is enabled
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
Expand Down Expand Up @@ -79,10 +83,12 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript @_file_upload
Scenario: Flavours: Favicon - Upload a favicon (with a global favicon being overridden)
When I log in as "admin"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "Site branding" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/favicon.ico" file to "Favicon" filemanager
And I press "Save changes"
And Behat debugging is enabled
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
Expand All @@ -97,10 +103,12 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript @_file_upload
Scenario: Flavours: Favicon - Do not upload a favicon (with a global favicon being served properly)
When I log in as "admin"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "Site branding" "link" in the "#adminsettings .nav-tabs" "css_element"
And I upload "theme/boost_union/tests/fixtures/favicon.ico" file to "Favicon" filemanager
And I click on "Save changes" "button"
And Behat debugging is enabled
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
Expand Down
2 changes: 2 additions & 0 deletions tests/behat/theme_boost_union_general.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ Feature: Configuring the theme_boost_union plugin as admin
Scenario: Switch to the active Boost Union admin sub-tab after saving a setting and the following page reload
When I log in as "admin"
And I follow "Site administration"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "Page" "link" in the "#adminsettings .nav-tabs" "css_element"
And I set the field "Course content max width" to "600px"
And I click on "Save changes" "button"
And Behat debugging is enabled
Then I should see "Course content max width" in the ".tab-content" "css_element"
And "#theme_boost_union_look_page.tab-pane.active" "css_element" should exist
And "#theme_boost_union_look_page.tab-pane:not(.active)" "css_element" should not exist
Expand Down
2 changes: 2 additions & 0 deletions tests/behat/theme_boost_union_goodiesfordesigners.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Feature: Using the goodies for designers in the theme_boost_union plugin
@javascript
Scenario: Feature: Themerev as SCSS variable
When I log in as "admin"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "SCSS" "link" in the "#adminsettings .nav-tabs" "css_element"
# We add a small CSS snippet to the page which adds the themrev to the Dashboard header.
Expand All @@ -36,6 +37,7 @@ Feature: Using the goodies for designers in the theme_boost_union plugin
#page-my-index h1:after { content: 'Themerev: #{$themerev}'; }
"""
And I press "Save changes"
And Behat debugging is enabled
And I follow "Dashboard"
Then I should see "Dashboard" in the "#page-my-index h1" "css_element"
And element "#page-my-index h1" pseudo-class "after" should contain "content": "Themerev"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ Feature: Configuring the theme_boost_union plugin for the "Activity branding" ta
@javascript
Scenario Outline: Setting: Activity icon purposes - Setting the purpose
Given I log in as "admin"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "Activity branding" "link" in the "#adminsettings .nav-tabs" "css_element"
And I select "<purpose>" from the "<modname>" singleselect
And I press "Save changes"
And Behat debugging is enabled
And I am on "Course 1" course homepage
And I turn editing mode on
When I click on "Add an activity or resource" "button" in the "Topic 1" "section"
Expand All @@ -58,6 +60,7 @@ Feature: Configuring the theme_boost_union plugin for the "Activity branding" ta
| config | value | plugin |
| modiconsenable | yes | theme_boost_union |
When I log in as "admin"
And Behat debugging is disabled
And I navigate to "Appearance > Boost Union > Look" in site administration
And I click on "Activity branding" "link" in the "#adminsettings .nav-tabs" "css_element"
And I click on ".fa-folder-o" "css_element" in the "#admin-modiconsfiles .fp-btn-mkdir" "css_element"
Expand All @@ -74,6 +77,7 @@ Feature: Configuring the theme_boost_union plugin for the "Activity branding" ta
And I should see "Activity: <modclearname>" in the ".settings-modicons-filelist" "css_element"
And I should see "Icon version: <iconversion>" in the ".settings-modicons-filelist" "css_element"
# Unfortunately we can only test the result in the custom icons files list. We cannot distinguish the icons in the activity chooser visually
And Behat debugging is enabled

Examples:
| iconfile | iconversion | modtechname | modclearname |
Expand All @@ -89,3 +93,4 @@ Feature: Configuring the theme_boost_union plugin for the "Activity branding" ta
And I click on "Activity branding" "link" in the "#adminsettings .nav-tabs" "css_element"
Then I should not see "Custom icons files list"
And ".settings-modicons-filelist" "css_element" should not exist
And Behat debugging is enabled
Loading

0 comments on commit bae668b

Please sign in to comment.