1@javascript @tool @tool_monitor @tool_monitor_rules 2Feature: tool_monitor_rule 3 In order to manage rules 4 As an admin 5 I need to create a rule, edit a rule, duplicate a rule and delete a rule 6 7 Background: 8 Given the following "courses" exist: 9 | fullname | shortname | 10 | Course 1 | C1 | 11 And the following "users" exist: 12 | username | firstname | lastname | email | 13 | teacher1 | Teacher | 1 | teacher1@example.com | 14 And the following "course enrolments" exist: 15 | user | course | role | 16 | teacher1 | C1 | editingteacher | 17 And I log in as "admin" 18 And I navigate to "Reports > Event monitoring rules" in site administration 19 And I click on "Enable" "link" 20 And I am on "Course 1" course homepage 21 And I navigate to "Reports > Event monitoring rules" in current page administration 22 And I press "Add a new rule" 23 And I set the following fields to these values: 24 | name | New rule course level | 25 | plugin | Forum | 26 | eventname | Post created | 27 | id_description | I want a rule to monitor posts created on a forum | 28 | frequency | 1 | 29 | minutes | 1 | 30 | Notification message | The forum post was created. {modulelink} | 31 And I press "Save changes" 32 And I navigate to "Reports > Event monitoring rules" in site administration 33 And I press "Add a new rule" 34 And I set the following fields to these values: 35 | name | New rule site level | 36 | plugin | Forum | 37 | eventname | Post created | 38 | id_description | I want a rule to monitor posts created on a forum | 39 | frequency | 1 | 40 | minutes | 1 | 41 | Notification message | The forum post was created. {modulelink} | 42 And I press "Save changes" 43 And I log out 44 45 Scenario: Add a rule on course level 46 Given I log in as "teacher1" 47 And I am on "Course 1" course homepage 48 And I navigate to "Reports > Event monitoring rules" in current page administration 49 When I press "Add a new rule" 50 And I set the following fields to these values: 51 | name | New rule | 52 | plugin | Forum | 53 | eventname | Post created | 54 | id_description | I want a rule to monitor posts created on a forum | 55 | frequency | 1 | 56 | minutes | 1 | 57 | Notification message | The forum post was created. {modulelink} | 58 And I press "Save changes" 59 Then "New rule" row "Course" column of "toolmonitorrules_table" table should contain "Course 1" 60 And I should see "I want a rule to monitor posts created on a forum" 61 And I should see "Forum" 62 And I should see "Post created" 63 And I should see "1 time(s) in 1 minute(s)" 64 65 Scenario: Delete a rule on course level 66 Given I log in as "teacher1" 67 And I am on "Course 1" course homepage 68 And I navigate to "Reports > Event monitoring rules" in current page administration 69 When I click on "Delete rule" "link" 70 Then I should see "Are you sure you want to delete the rule \"New rule course level\"?" 71 And I press "Continue" 72 And I should see "Rule successfully deleted" 73 And I should not see "New rule course level" 74 75 Scenario: Edit a rule on course level 76 Given I log in as "teacher1" 77 And I am on "Course 1" course homepage 78 And I navigate to "Reports > Event monitoring rules" in current page administration 79 When I click on "Edit rule" "link" 80 And I set the following fields to these values: 81 | name | New rule quiz | 82 | plugin | Quiz | 83 | eventname | Quiz attempt deleted | 84 | id_description | I want a rule to monitor quiz attempts deleted | 85 | frequency | 5 | 86 | minutes | 5 | 87 | Notification message | Quiz attempt deleted. {modulelink} | 88 And I press "Save changes" 89 Then I should see "New rule quiz" 90 And I should see "I want a rule to monitor quiz attempts deleted" 91 And I should see "Quiz attempt deleted" 92 And I should see "5 time(s) in 5 minute(s)" 93 94 Scenario: Duplicate a rule on course level 95 Given I log in as "teacher1" 96 And I am on "Course 1" course homepage 97 And I navigate to "Reports > Event monitoring rules" in current page administration 98 When I click on "Duplicate rule" "link" in the "New rule course level" "table_row" 99 Then I should see "Rule successfully duplicated" 100 And "#toolmonitorrules_r1" "css_element" should appear before "#toolmonitorrules_r2" "css_element" 101 And I should see "New rule" 102 And I should see "I want a rule to monitor posts created on a forum" 103 And I should see "Forum" 104 And I should see "Post created" 105 And I should see "1 time(s) in 1 minute(s)" 106 107 Scenario: Add a rule on site level 108 Given I log in as "admin" 109 And I navigate to "Reports > Event monitoring rules" in site administration 110 When I press "Add a new rule" 111 And I set the following fields to these values: 112 | name | New rule | 113 | plugin | Forum | 114 | eventname | Post created | 115 | id_description | I want a rule to monitor posts created on a forum | 116 | frequency | 1 | 117 | minutes | 1 | 118 | Notification message | The forum post was created. {modulelink} | 119 And I press "Save changes" 120 Then "New rule" row "Course" column of "toolmonitorrules_table" table should contain "Site" 121 And I should see "I want a rule to monitor posts created on a forum" 122 And I should see "Forum" 123 And I should see "Post created" 124 And I should see "1 time(s) in 1 minute(s)" 125 126 Scenario: Delete a rule on site level 127 Given I log in as "admin" 128 And I navigate to "Reports > Event monitoring rules" in site administration 129 When I click on "Delete rule" "link" 130 Then I should see "Are you sure you want to delete the rule \"New rule site level\"?" 131 And I press "Continue" 132 And I should see "Rule successfully deleted" 133 And I should not see "New rule site level" 134 135 Scenario: Edit a rule on site level 136 Given I log in as "admin" 137 And I navigate to "Reports > Event monitoring rules" in site administration 138 When I click on "Edit rule" "link" 139 And I set the following fields to these values: 140 | name | New Rule Quiz | 141 | plugin | Quiz | 142 | eventname | Quiz attempt deleted | 143 | id_description | I want a rule to monitor quiz attempts deleted | 144 | frequency | 5 | 145 | minutes | 5 | 146 | Notification message | Quiz attempt deleted. {modulelink} | 147 And I press "Save changes" 148 Then I should see "New Rule Quiz" 149 And I should see "I want a rule to monitor quiz attempts deleted" 150 And I should see "Quiz attempt deleted" 151 And I should see "5 time(s) in 5 minute(s)" 152 153 Scenario: Duplicate a rule on site level 154 Given I log in as "teacher1" 155 And I am on "Course 1" course homepage 156 And I navigate to "Reports > Event monitoring rules" in current page administration 157 When I click on "Duplicate rule" "link" in the "New rule site level" "table_row" 158 Then I should see "Rule successfully duplicated" 159 And "#toolmonitorrules_r2" "css_element" should appear after "#toolmonitorrules_r1" "css_element" 160 And I should see "I want a rule to monitor posts created on a forum" 161 And I should see "Forum" 162 And I should see "Post created" 163 And I should see "1 time(s) in 1 minute(s)" 164