From 595177194f8e1ce2064c1854c47ef7d08910558b Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Tue, 14 Dec 2021 18:19:07 +0100 Subject: [PATCH] MDL-73339 core_blocks: Behat tests to cover can_block_be_added --- .../tests/behat/add_blocks_overridden.feature | 53 +++++++++ .../add_blocks_overridden_disabled.feature | 101 ++++++++++++++++++ theme/classic/tests/behat/blacklist.json | 3 + 3 files changed, 157 insertions(+) create mode 100644 blocks/tests/behat/add_blocks_overridden.feature create mode 100644 blocks/tests/behat/add_blocks_overridden_disabled.feature diff --git a/blocks/tests/behat/add_blocks_overridden.feature b/blocks/tests/behat/add_blocks_overridden.feature new file mode 100644 index 00000000000..b5cea1ea72b --- /dev/null +++ b/blocks/tests/behat/add_blocks_overridden.feature @@ -0,0 +1,53 @@ +@block @core_block @javascript @addablocklink +Feature: Add a block when main feature is enabled + In order to add a block to my course + As a teacher + Some blocks should be only added to courses if the main feature they are based on is enabled. + + Background: + Given the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And I am on the "C1" "course" page logged in as "admin" + + Scenario Outline: The block can be added when main feature is enabled + Given the following config values are set as admin: + | | 1 | | + | | 1 | | + And I turn editing mode on + When I click on "Add a block" "link" + Then I should see "" + + Examples: + | blockname | settingname1 | settingname2 | settingplugin1 | + | Accessibility review | enableaccessibilitytools | | | + | Blog menu | enableblogs | | | + | Recent blog entries | enableblogs | | | + | Blog tags | enableblogs | usetags | | + | Comments | usecomments | | | + | Course completion status | enablecompletion | | | + | Global search | enableglobalsearch | | | + | Latest badges | enablebadges | | | + | Tags | usetags | | | + | Learning plans | enabled | | core_competency | + + Scenario Outline: The block cannot be added when main feature is disabled + Given the following config values are set as admin: + | | 0 | | + | | 0 | | + And I turn editing mode on + When I click on "Add a block" "link" + Then I should not see "" + + Examples: + | blockname | settingname1 | settingname2 | settingplugin1 | + | Accessibility review | enableaccessibilitytools | | | + | Blog menu | enableblogs | | | + | Recent blog entries | enableblogs | | | + | Blog tags | enableblogs | usetags | | + | Comments | usecomments | | | + | Course completion status | enablecompletion | | | + | Global search | enableglobalsearch | | | + | Latest badges | enablebadges | | | + | Tags | usetags | | | + | Learning plans | enabled | | core_competency | diff --git a/blocks/tests/behat/add_blocks_overridden_disabled.feature b/blocks/tests/behat/add_blocks_overridden_disabled.feature new file mode 100644 index 00000000000..6bf3cfb8771 --- /dev/null +++ b/blocks/tests/behat/add_blocks_overridden_disabled.feature @@ -0,0 +1,101 @@ +@block @core_block @javascript +Feature: Add a block when main feature is disabled + In order to add a block to my course + As a teacher + Some blocks should be only added to courses if the main feature they are based on is enabled. + + Background: + Given the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And I am on the "C1" "course" page logged in as "admin" + + Scenario Outline: The block is displayed even when main feature is disabled + Given the following config values are set as admin: + | | 1 | | + And I turn editing mode on + And I add the "" block + When the following config values are set as admin: + | | 0 | | + Then I should see "" + + Examples: + | blockname | settingname1 | settingplugin1 | + | Accessibility review | enableaccessibilitytools | | + | Blog menu | enableblogs | | + | Recent blog entries | enableblogs | | + | Comments | usecomments | | + | Course completion status | enablecompletion | | + | Global search | enableglobalsearch | | + | Latest badges | enablebadges | | + | Tags | usetags | | + | Learning plans | enabled | core_competency | + + Scenario Outline: The block is displayed even when main feature is disabled (2 settings) + Given the following config values are set as admin: + | | 1 | + | | 1 | + And I turn editing mode on + And I add the "" block + When the following config values are set as admin: + | | 0 | + | | 0 | + Then I should see "" + + Examples: + | blockname | settingname1 | settingname2 | + | Blog tags | enableblogs | usetags | + + Scenario Outline: The block can be removed even when main feature is disabled + Given the following config values are set as admin: + | | 1 | | + And I turn editing mode on + And I add the "" block + And I open the "" blocks action menu + And I click on "Delete block" "link" in the "" "block" + And "Delete block?" "dialogue" should exist + And I click on "Cancel" "button" in the "Delete block?" "dialogue" + And I should see "" + When the following config values are set as admin: + | | 0 | | + And I open the "" blocks action menu + And I click on "Delete block" "link" in the "" "block" + And "Delete block?" "dialogue" should exist + And I click on "Delete" "button" in the "Delete block?" "dialogue" + Then I should not see "" + + Examples: + | blockname | settingname1 | settingplugin1 | + | Accessibility review | enableaccessibilitytools | | + | Blog menu | enableblogs | | + | Recent blog entries | enableblogs | | + | Comments | usecomments | | + | Course completion status | enablecompletion | | + | Global search | enableglobalsearch | | + | Latest badges | enablebadges | | + | Tags | usetags | | + | Learning plans | enabled | core_competency | + + Scenario Outline: The block can be removed even when main feature is disabled (2 settings) + Given the following config values are set as admin: + | | 1 | + | | 1 | + And I turn editing mode on + And I add the "" block + And I open the "" blocks action menu + And I click on "Delete block" "link" in the "" "block" + And "Delete block?" "dialogue" should exist + And I click on "Cancel" "button" in the "Delete block?" "dialogue" + And I should see "" + When the following config values are set as admin: + | | 0 | + | | 0 | + And I open the "" blocks action menu + And I click on "Delete block" "link" in the "" "block" + And "Delete block?" "dialogue" should exist + And I click on "Delete" "button" in the "Delete block?" "dialogue" + Then I should not see "" + + Examples: + | blockname | settingname1 | settingname2 | + | Blog tags | enableblogs | usetags | diff --git a/theme/classic/tests/behat/blacklist.json b/theme/classic/tests/behat/blacklist.json index d0170ef606c..d44c94583cd 100644 --- a/theme/classic/tests/behat/blacklist.json +++ b/theme/classic/tests/behat/blacklist.json @@ -11,5 +11,8 @@ "course/format/tests/behat/courseindex_keyboardnav.feature", "course/format/tests/behat/courseindex_completion.feature", "badges/tests/behat/badge_navigation.feature" + ], + "tags": [ + "addablocklink" ] }