MDL-59890 calendar: Add behat tests
[moodle.git] / calendar / tests / behat / category_events.feature
1 @core @core_calendar
2 Feature: Course Category Events
3   In order to inform multiple courses of shared events
4   As a manager
5   I need to create catgory events
7   Background:
8     Given the following "users" exist:
9       | username    | firstname     | lastname      | email                     |
10       | managera    | Manager       | A             | managera@example.com      |
11       | managera1   | Manager       | A1            | managera1@example.com     |
12       | managera2   | Manager       | A2            | managera2@example.com     |
13       | teachera1i  | Teacher       | A1i           | teachera1i@example.com    |
14       | managerb    | Manager       | B             | managerb@example.com      |
15       | managerb1   | Manager       | B1            | managerb1@example.com     |
16       | managerb2   | Manager       | B2            | managerb2@example.com     |
17       | teacherb1i  | Teacher       | B1i           | teacherb1i@example.com    |
18       | student1    | Student       | 1             | student1@example.com      |
19       | student2    | Student       | 2             | student2@example.com      |
20     And the following "categories" exist:
21       | name            | idnumber      | category  |
22       | Year            | year          |           |
23       | Faculty A       | faculty-a     | year      |
24       | Faculty B       | faculty-b     | year      |
25       | Department A1   | department-a1 | faculty-a |
26       | Department A2   | department-a2 | faculty-a |
27       | Department B1   | department-b1 | faculty-b |
28       | Department B2   | department-b2 | faculty-b |
29     And the following "courses" exist:
30       | fullname    | shortname | idnumber     | format        | category          |
31       | Course A1i  | A1i       | A1i          | topics        | department-a1     |
32       | Course A2i  | A2i       | A2i          | topics        | department-a2     |
33       | Course B1i  | B1i       | B1i          | topics        | department-b1     |
34       | Course B2i  | B2i       | B2i          | topics        | department-b2     |
35     And the following "role assigns" exist:
36       | user        | role      | contextlevel  | reference         |
37       | managera    | manager   | Category      | faculty-a         |
38       | managera1   | manager   | Category      | department-a1     |
39       | managerb    | manager   | Category      | faculty-b         |
40       | managerb1   | manager   | Category      | department-b1     |
41     And the following "course enrolments" exist:
42       | user        | course    | role              |
43       | teachera1i  | A1i       | editingteacher    |
44       | teacherb1i  | B1i       | editingteacher    |
45       | student1    | A1i       | student           |
46       | student1    | A2i       | student           |
47       | student2    | B1i       | student           |
48       | student2    | B2i       | student           |
49     And the following "events" exist:
50       | name        | eventtype | category          | course |
51       | Site event  | global    |                   |        |
52       | FA event    | category  | faculty-a         |        |
53       | DA1 event   | category  | department-a1     |        |
54       | DA2 event   | category  | department-a1     |        |
55       | FB event    | category  | faculty-b         |        |
56       | DB1 event   | category  | department-b1     |        |
57       | DB2 event   | category  | department-b1     |        |
58       | CA1i event  | course    |                   | A1i    |
59       | CA2i event  | course    |                   | A2i    |
60       | CB1i event  | course    |                   | B1i    |
61       | CB2i event  | course    |                   | B2i    |
63   @javascript
64   Scenario: Manager of a Category can see all child and parent events in their category
65     Given I log in as "managera"
66     When I navigate to "Calendar" node in "Site pages"
67     Then I should see "FA event"
68     And  I should see "DA1 event"
69     And  I should see "DA2 event"
70     And  I should not see "FB event"
71     And  I should not see "DB1 event"
72     And  I should not see "DB2 event"
73     And  I log out
74     Given I log in as "managerb"
75     When I navigate to "Calendar" node in "Site pages"
76     Then I should see "FB event"
77     And  I should see "DB1 event"
78     And  I should see "DB2 event"
79     And  I should not see "FA event"
80     And  I should not see "DA1 event"
81     And  I should not see "DA2 event"
83   @javascript
84   Scenario: Users enrolled in a course can see all child and parent events in their category
85     Given I log in as "student1"
86     When I navigate to "Calendar" node in "Site pages"
87     Then I should see "FA event"
88     And  I should see "DA1 event"
89     And  I should see "DA2 event"
90     And  I should see "CA1i event"
91     And  I should see "CA2i event"
92     And  I should not see "FB event"
93     And  I should not see "DB1 event"
94     And  I should not see "DB2 event"
95     And  I should not see "CB1i event"
96     And  I should not see "CB2i event"