weekly release 5.0dev
[moodle.git] / user / tests / behat / view_preferences_page.feature
blob49642fb218aa5c0ec0b94d6d2dc72c29bcde5c41
1 @core @core_user
2 Feature: Access to preferences page
3   In order to view the preferences page
4   As a user
5   I need global permissions to view the page.
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email |
10       | student1 | Student | 1 | student1@example.com |
11       | student2 | Student | 2 | student2@example.com |
12       | manager1 | Manager | 1 | manager1@example.com |
13       | teacher1 | Teacher | 1 | teacher1@example.com |
14       | parent   | Parent  | 1 | parent1@example.com |
15     And the following "courses" exist:
16       | fullname | shortname | format |
17       | Course 1 | C1 | topics |
18       | Course 2 | C2 | topics |
19     And the following "course enrolments" exist:
20       | user | course | role |
21       | student1 | C1 | student |
22       | student2 | C1 | student |
23       | teacher1 | C1 | editingteacher |
24     And the following "system role assigns" exist:
25       | user | course | role |
26       | manager1 | Acceptance test site | manager |
28   Scenario: A student and teacher with normal permissions can not view another user's permissions page.
29     Given I log in as "student1"
30     And I am on "Course 1" course homepage
31     And I navigate to course participants
32     And I follow "Student 2"
33     And I should not see "Preferences" in the "region-main" "region"
34     And I log out
35     And I log in as "teacher1"
36     And I am on "Course 1" course homepage
37     When I navigate to course participants
38     And I follow "Student 2"
39     Then I should not see "Preferences" in the "region-main" "region"
41   Scenario: Administrators and Managers can view another user's permissions page.
42     Given I log in as "admin"
43     And I am on "Course 1" course homepage
44     And I navigate to course participants
45     And I follow "Student 2"
46     And I should see "Preferences" in the "region-main" "region"
47     And I log out
48     And I log in as "manager1"
49     And I am on "Course 1" course homepage
50     When I navigate to course participants
51     And I follow "Student 2"
52     Then I should see "Preferences" in the "region-main" "region"
54   Scenario: A user with the appropriate permissions can view another user's permissions page.
55     Given the following "role" exists:
56       | shortname                            | Parent |
57       | name                                 | Parent |
58       | context_user                         | 1      |
59       | moodle/user:editprofile              | allow  |
60       | moodle/user:viewalldetails           | allow  |
61       | moodle/user:viewuseractivitiesreport | allow  |
62       | moodle/user:viewdetails              | allow  |
63     And the following "blocks" exist:
64       | blockname | contextlevel | reference | pagetypepattern | defaultregion |
65       | mentees   | System       | 1         | site-index      | side-pre      |
66     When I log in as "admin"
67     And I am on site homepage
68     And I am on the "student1" "user > profile" page
69     And I click on "Preferences" "link" in the ".profile_tree" "css_element"
70     And I follow "Assign roles relative to this user"
71     And I follow "Parent"
72     And I set the field "Potential users" to "Parent 1 (parent1@example.com)"
73     And I click on "Add" "button" in the "#page-content" "css_element"
74     And I log out
75     And I log in as "parent"
76     And I am on site homepage
77     When I follow "Student 1"
78     Then I should see "Preferences" in the "region-main" "region"