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 <identifier> page logged in as admin
Examples:
| description | identifier | shouldsee |
| Admin page | "Admin notifications" | Check for available updates |
- | Home page | Homepage | Recently accessed courses |
+ | Home page | Homepage | Course overview |
| 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 |
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
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Calendar upcoming events block data generator class.
+ *
+ * @package block_calendar_upcoming
+ * @category test
+ * @copyright 2021 Sara Arjona <sara@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_calendar_upcoming_generator extends testing_block_generator {
+}
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Learning plans block data generator class.
+ *
+ * @package block_lp
+ * @category test
+ * @copyright 2021 Sara Arjona <sara@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_lp_generator extends testing_block_generator {
+}
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"
| 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"
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"
| 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"
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Recently accessed courses block data generator class.
+ *
+ * @package block_recentlyaccessedcourses
+ * @category test
+ * @copyright 2021 Sara Arjona <sara@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_recentlyaccessedcourses_generator extends testing_block_generator {
+}
$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',
$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);
$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);
}
$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') {
$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') {
$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);
}
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"
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
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"
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.
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"