MDL-74078 core_my: Lock all blocks on the my courses page

This commit is contained in:
Michael Hawkins 2022-03-24 18:27:04 +08:00
parent a0c6b4a174
commit a640f43181
4 changed files with 89 additions and 0 deletions

View file

@ -58,6 +58,13 @@ $PAGE->blocks->add_region('content');
$PAGE->set_subpage($currentpage->id);
$PAGE->set_title(get_string('mycourses'));
$PAGE->set_heading(get_string('mycourses'));
// No blocks can be edited on this page (including by managers/admins) because:
// - Course overview is a fixed item on the page and cannot be moved/removed.
// - We do not want new blocks on the page.
// - Only global blocks (if any) should be visible on the site panel, and cannot be moved int othe centre pane.
$PAGE->force_lock_all_blocks();
// Force the add block out of the default area.
$PAGE->theme->addblockposition = BLOCK_ADDBLOCK_POSITION_CUSTOM;

View file

@ -86,3 +86,28 @@ Feature: Run tests over my courses.
And I click on "Manage courses" "link"
And I wait to be redirected
And I should see "Manage course categories and courses"
@javascript
Scenario: Admin can see relevant blocks but not add or move them
Given I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Text" block
And I configure the "(new text block)" block
And I set the following fields to these values:
| Page contexts | Display throughout the entire site |
| Text block title | Text on all pages |
| Content | This is visible on all pages |
| Default region | Right |
And I press "Save changes"
And I should see "This is visible on all pages"
And "Move Text on all pages block" "button" should exist in the "Text on all pages" "block"
When I am on the "My courses" page
# Check blocks visible but are "locked" in place.
Then "Course overview" "text" should exist in the "region-main" "region"
And I should not see "Add a block"
And I should see "This is visible on all pages"
And "Move Text on all pages block" "button" should not exist in the "Text on all pages" "block"
And "Move Course overview block" "button" should not exist in the "Course overview" "block"
And I click on "Actions menu" "icon" in the "Course overview" "block"
And I should not see "Delete Course overview block"