configure_block_throughout_site.feature 3.06 KB
Newer Older
1
@core @core_block
David Monllaó's avatar
David Monllaó committed
2
3
Feature: Add and configure blocks throughout the site
  In order to maintain some patterns across all the site
4
  As a manager
David Monllaó's avatar
David Monllaó committed
5
6
  I need to set and configure blocks throughout the site

7
  Background:
8
    Given the following "courses" exist:
David Monllaó's avatar
David Monllaó committed
9
10
      | fullname | shortname | category |
      | Course 1 | C1 | 0 |
11
    And the following "users" exist:
David Monllaó's avatar
David Monllaó committed
12
      | username | firstname | lastname | email |
13
      | manager1 | Manager | 1 | manager1@example.com |
14
15
16
17
      | teacher1 | teacher | 1 | teacher@example.com |
    And the following "course enrolments" exist:
      | user     | course | role           |
      | teacher1 | C1     | editingteacher |
18
    And the following "system role assigns" exist:
David Monllaó's avatar
David Monllaó committed
19
20
      | user | course | role |
      | manager1 | Acceptance test site | manager |
21
22
23
24
25
26
27
28
29
30
31
    # Allow at least one role assignment in the block context:
    And I log in as "admin"
    And I navigate to "Define roles" node in "Site administration > Users > Permissions"
    And I follow "Edit Non-editing teacher role"
    And I set the following fields to these values:
      | Block | 1 |
    And I press "Save changes"
    And I log out

  Scenario: Add and configure a block throughtout the site
    Given I log in as "manager1"
32
    And I am on site homepage
David Monllaó's avatar
David Monllaó committed
33
34
    And I follow "Turn editing on"
    And I add the "Comments" block
35
    And I configure the "Comments" block
36
    And I set the following fields to these values:
David Monllaó's avatar
David Monllaó committed
37
38
      | Page contexts | Display throughout the entire site |
    And I press "Save changes"
39
    When I am on "Course 1" course homepage
40
41
    Then I should see "Comments" in the "Comments" "block"
    And I should see "Save comment" in the "Comments" "block"
42
    And I am on site homepage
43
    And I configure the "Comments" block
44
    And I set the following fields to these values:
David Monllaó's avatar
David Monllaó committed
45
46
      | Default weight | -10 (first) |
    And I press "Save changes"
47
    And I am on "Course 1" course homepage
David Monllaó's avatar
David Monllaó committed
48
    # The first block matching the pattern should be top-left block
49
    And I should see "Comments" in the "//*[@id='region-pre' or @id='block-region-side-pre']/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' block ')]" "xpath_element"
50

51
  Scenario: Blocks on the dashboard page can have roles assigned to them
52
    Given I log in as "manager1"
53
    When I press "Customise this page"
54
    Then I should see "Assign roles in Private files block"
55
56

  Scenario: Blocks on courses can have roles assigned to them
57
    Given I log in as "teacher1"
58
    And I am on "Course 1" course homepage with editing mode on
59
    And I add the "Search forums" block
60
    Then I should see "Assign roles in Search forums block"
61
62
63
64

  @javascript
  Scenario: Blocks can safely be customised
    Given I log in as "admin"
65
    And I am on homepage
66
67
68
69
    And I press "Customise this page"
    And I add the "HTML" block
    And I configure the "(new HTML block)" block
    And I set the following fields to these values:
70
71
      | Block title | Foo " onload="document.getElementsByTagName('body')[0].remove()" alt=" |
      | Content     | Example |
72
    When I press "Save changes"
73
    Then I should see "Course overview"