diff --git a/admin/tool/behat/tests/behat/i_am_on_page.feature b/admin/tool/behat/tests/behat/i_am_on_page.feature index 8bef7f9a775..9c60a8b3da9 100644 --- a/admin/tool/behat/tests/behat/i_am_on_page.feature +++ b/admin/tool/behat/tests/behat/i_am_on_page.feature @@ -73,7 +73,7 @@ Feature: Use core page resolvers for the I am on the page steps Examples: | description | identifier | shouldsee | | Admin page | "Admin notifications" | Check for available updates | - | Home page | Homepage | Recently accessed courses | + | Home page | Homepage | Course overview | Scenario Outline: When I am on a named page logged in as When I am on the page logged in as admin @@ -82,4 +82,4 @@ Feature: Use core page resolvers for the I am on the page steps Examples: | description | identifier | shouldsee | | Admin page | "Admin notifications" | Check for available updates | - | Home page | Homepage | Recently accessed courses | + | Home page | Homepage | Course overview | diff --git a/admin/tool/lp/tests/behat/plan_workflow.feature b/admin/tool/lp/tests/behat/plan_workflow.feature index 9d8f2eb39c1..6b6a244913d 100644 --- a/admin/tool/lp/tests/behat/plan_workflow.feature +++ b/admin/tool/lp/tests/behat/plan_workflow.feature @@ -37,6 +37,9 @@ Feature: Manage plan workflow | Test-Plan1 | Test-Comp2 | | Test-Plan2 | Test-Comp1 | | Test-Plan2 | Test-Comp2 | + And the following "blocks" exist: + | blockname | contextlevel | reference | pagetypepattern | defaultregion | + | lp | System | 1 | my-index | content | And I log in as "admin" And I set the following system permissions of "User manage own draft plan role" role: | capability | permission | diff --git a/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_course.feature b/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_course.feature index 1b4d9e06961..d160777d1ea 100644 --- a/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_course.feature +++ b/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_course.feature @@ -14,6 +14,9 @@ Feature: Enable the upcoming events block in a course And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + And the following "blocks" exist: + | blockname | contextlevel | reference | pagetypepattern | defaultregion | + | calendar_upcoming | System | 1 | my-index | side-post | @javascript Scenario: View a site event in the calendar block diff --git a/blocks/calendar_upcoming/tests/generator/lib.php b/blocks/calendar_upcoming/tests/generator/lib.php new file mode 100644 index 00000000000..e569db825ea --- /dev/null +++ b/blocks/calendar_upcoming/tests/generator/lib.php @@ -0,0 +1,26 @@ +. + +/** + * Calendar upcoming events block data generator class. + * + * @package block_calendar_upcoming + * @category test + * @copyright 2021 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class block_calendar_upcoming_generator extends testing_block_generator { +} diff --git a/blocks/lp/tests/generator/lib.php b/blocks/lp/tests/generator/lib.php new file mode 100644 index 00000000000..d6998c45e83 --- /dev/null +++ b/blocks/lp/tests/generator/lib.php @@ -0,0 +1,26 @@ +. + +/** + * Learning plans block data generator class. + * + * @package block_lp + * @category test + * @copyright 2021 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class block_lp_generator extends testing_block_generator { +} diff --git a/blocks/online_users/tests/behat/block_online_users_course.feature b/blocks/online_users/tests/behat/block_online_users_course.feature index 097cee10c43..119e2dae974 100644 --- a/blocks/online_users/tests/behat/block_online_users_course.feature +++ b/blocks/online_users/tests/behat/block_online_users_course.feature @@ -89,6 +89,7 @@ Feature: The online users block allow you to see who is currently online And the following config values are set as admin: | block_online_users_onlinestatushiding | 0 | When I log in as "student1" + And I am on "Course 1" course homepage Then I should see "Student 1" in the "Online users" "block" And "Hide" "icon" should not exist in the ".block.block_online_users" "css_element" diff --git a/blocks/online_users/tests/behat/block_online_users_dashboard.feature b/blocks/online_users/tests/behat/block_online_users_dashboard.feature index d15e46a7b07..0c46b5b522a 100644 --- a/blocks/online_users/tests/behat/block_online_users_dashboard.feature +++ b/blocks/online_users/tests/behat/block_online_users_dashboard.feature @@ -19,6 +19,9 @@ Feature: The online users block allow you to see who is currently online on dash | teacher1 | C1 | editingteacher | | student1 | C1 | student | | student2 | C1 | student | + And the following "blocks" exist: + | blockname | contextlevel | reference | pagetypepattern | defaultregion | + | online_users | System | 1 | my-index | side-post | Scenario: View the online users block on the dashboard and see myself Given I log in as "teacher1" diff --git a/blocks/online_users/tests/behat/block_online_users_frontpage.feature b/blocks/online_users/tests/behat/block_online_users_frontpage.feature index 0c08e522fd0..e8f9591f6d7 100644 --- a/blocks/online_users/tests/behat/block_online_users_frontpage.feature +++ b/blocks/online_users/tests/behat/block_online_users_frontpage.feature @@ -114,6 +114,7 @@ Feature: The online users block allow you to see who is currently online on fron And the following config values are set as admin: | block_online_users_onlinestatushiding | 0 | When I log in as "student1" + And I am on site homepage Then I should see "Student 1" in the "Online users" "block" And "Hide" "icon" should not exist in the ".block.block_online_users" "css_element" diff --git a/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature b/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature index 5e9ae8c8621..a31bbe6235c 100644 --- a/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature +++ b/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature @@ -25,6 +25,9 @@ Feature: The recently accessed courses block allows users to easily access their | student1 | C3 | student | | student1 | C4 | student | | student1 | C5 | student | + And the following "blocks" exist: + | blockname | contextlevel | reference | pagetypepattern | defaultregion | + | recentlyaccessedcourses | System | 1 | my-index | content | Scenario: User has not accessed any course Given I log in as "student1" diff --git a/blocks/recentlyaccessedcourses/tests/generator/lib.php b/blocks/recentlyaccessedcourses/tests/generator/lib.php new file mode 100644 index 00000000000..f89468f6371 --- /dev/null +++ b/blocks/recentlyaccessedcourses/tests/generator/lib.php @@ -0,0 +1,26 @@ +. + +/** + * Recently accessed courses block data generator class. + * + * @package block_recentlyaccessedcourses + * @category test + * @copyright 2021 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class block_recentlyaccessedcourses_generator extends testing_block_generator { +} diff --git a/blocks/tests/externallib_test.php b/blocks/tests/externallib_test.php index f5bb942308d..937b640a71b 100644 --- a/blocks/tests/externallib_test.php +++ b/blocks/tests/externallib_test.php @@ -325,7 +325,7 @@ class core_block_externallib_testcase extends externallib_advanced_testcase { $PAGE->set_url('/my/index.php'); // Need this because some internal API calls require the $PAGE url to be set. // Force a setting change to check the returned blocks settings. - set_config('displaycategories', 0, 'block_recentlyaccessedcourses'); + set_config('displaycategories', 0, 'block_myoverview'); // Get the expected default blocks. $alldefaultblocksordered = $DB->get_records_menu('block_instances', @@ -337,15 +337,15 @@ class core_block_externallib_testcase extends externallib_advanced_testcase { $result = core_block_external::get_dashboard_blocks($user->id); // We need to execute the return values cleaning process to simulate the web service server. $result = external_api::clean_returnvalue(core_block_external::get_dashboard_blocks_returns(), $result); - // Expect all blogs except learning plans one (no learning plans to show). - $this->assertCount(count($alldefaultblocksordered) - 1, $result['blocks']); + // Expect all default blocks defined in blocks_add_default_system_blocks(). + $this->assertCount(count($alldefaultblocksordered), $result['blocks']); $returnedblocks = array(); foreach ($result['blocks'] as $block) { // Check all the returned blocks are in the expected blocks array. $this->assertContains($block['name'], $alldefaultblocksordered); $returnedblocks[] = $block['name']; // Check the configuration returned for this default block. - if ($block['name'] == 'recentlyaccessedcourses') { + if ($block['name'] == 'myoverview') { // Convert config to associative array to avoid DB sorting randomness. $config = array_column($block['configs'], null, 'name'); $this->assertArrayHasKey('displaycategories', $config); @@ -353,8 +353,7 @@ class core_block_externallib_testcase extends externallib_advanced_testcase { $this->assertEquals('plugin', $config['displaycategories']['type']); } } - // Remove lp block. - array_shift($alldefaultblocksordered); + // Check that we received the blocks in the expected order. $this->assertEquals(array_values($alldefaultblocksordered), $returnedblocks); } @@ -387,8 +386,8 @@ class core_block_externallib_testcase extends externallib_advanced_testcase { $result = core_block_external::get_dashboard_blocks($user->id); // We need to execute the return values cleaning process to simulate the web service server. $result = external_api::clean_returnvalue(core_block_external::get_dashboard_blocks_returns(), $result); - // Expect all blogs plus sticky one except learning plans one (no learning plans to show). - $this->assertCount(count($alldefaultblocks), $result['blocks']); + // Expect all default blocks defined in blocks_add_default_system_blocks() plus sticky one. + $this->assertCount(count($alldefaultblocks) + 1, $result['blocks']); $found = false; foreach ($result['blocks'] as $block) { if ($block['name'] == 'myprofile') { @@ -432,8 +431,8 @@ class core_block_externallib_testcase extends externallib_advanced_testcase { $result = core_block_external::get_dashboard_blocks($user->id); // We need to execute the return values cleaning process to simulate the web service server. $result = external_api::clean_returnvalue(core_block_external::get_dashboard_blocks_returns(), $result); - // Expect all default blogs plys the one we added except learning plans one (no learning plans to show). - $this->assertCount(count($alldefaultblocks), $result['blocks']); + // Expect all default blocks defined in blocks_add_default_system_blocks() plus the one we added. + $this->assertCount(count($alldefaultblocks) + 1, $result['blocks']); $found = false; foreach ($result['blocks'] as $block) { if ($block['name'] == 'myprofile') { diff --git a/lib/blocklib.php b/lib/blocklib.php index 35a6102635d..af86926b025 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -2607,7 +2607,7 @@ function blocks_add_default_system_blocks() { $subpagepattern = null; } - $newblocks = array('timeline', 'private_files', 'online_users', 'badges', 'calendar_month', 'calendar_upcoming'); - $newcontent = array('lp', 'recentlyaccessedcourses', 'myoverview'); + $newblocks = array('timeline', 'private_files', 'badges', 'calendar_month'); + $newcontent = array('myoverview'); $page->blocks->add_blocks(array(BLOCK_POS_RIGHT => $newblocks, 'content' => $newcontent), 'my-index', $subpagepattern); } diff --git a/my/tests/behat/add_blocks.feature b/my/tests/behat/add_blocks.feature index fd612d18c2b..92be5f38a15 100644 --- a/my/tests/behat/add_blocks.feature +++ b/my/tests/behat/add_blocks.feature @@ -24,4 +24,4 @@ Feature: Add blocks to dashboard page Then I should see "Latest announcements" in the "Latest announcements" "block" And I should see "Latest badges" in the "Latest badges" "block" And I should see "Calendar" in the "Calendar" "block" - And I should see "Upcoming events" in the "Upcoming events" "block" + And I should not see "Upcoming events" diff --git a/my/tests/behat/reset_all_pages.feature b/my/tests/behat/reset_all_pages.feature index c762b73957b..9f24eb80095 100644 --- a/my/tests/behat/reset_all_pages.feature +++ b/my/tests/behat/reset_all_pages.feature @@ -45,8 +45,8 @@ Feature: Reset all personalised pages to default And I navigate to "Appearance > Default Dashboard page" in site administration And I press "Blocks editing on" And I add the "Latest announcements" block - And I open the "Online users" blocks action menu - And I follow "Delete Online users" + And I open the "Latest badges" blocks action menu + And I follow "Delete Latest badges block" And I press "Yes" And I press "Blocks editing off" And I log out @@ -54,13 +54,13 @@ Feature: Reset all personalised pages to default And I log in as "student1" And I follow "Dashboard" in the user menu And I should not see "Latest announcements" - And I should see "Online users" + And I should see "Latest badges" And I log out And I log in as "student3" And I follow "Dashboard" in the user menu And I should not see "Latest announcements" - And I should see "Online users" + And I should see "Latest badges" And I log out And I log in as "admin" @@ -73,13 +73,13 @@ Feature: Reset all personalised pages to default And I follow "Dashboard" in the user menu Then I should see "Latest announcements" And I should not see "Comments" - And I should not see "Online users" + And I should not see "Latest badges" And I log out And I log in as "student3" And I follow "Dashboard" in the user menu And I should see "Latest announcements" - And I should not see "Online users" + And I should not see "Latest badges" And I log out # Check that this did not affect the customised profiles. diff --git a/my/tests/behat/reset_page.feature b/my/tests/behat/reset_page.feature index 707fb9b09fa..c7fd951b052 100644 --- a/my/tests/behat/reset_page.feature +++ b/my/tests/behat/reset_page.feature @@ -26,6 +26,6 @@ Feature: Reset dashboard page to default Then I should not see "Latest announcements" And I should see "Latest badges" And I should see "Calendar" - And I should see "Upcoming events" + And I should not see "Upcoming events" And I should not see "Comments" And I should not see "Reset page to default"