From 77098e6dc14f7cdf59e9cd4cd583abc350e28bef Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Fri, 3 Oct 2014 14:37:00 +0800 Subject: [PATCH] MDL-45758 tool_monitor: Add behat tests to subscription management Original issue - MDL-47148 --- .../monitor/tests/behat/subscription.feature | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 admin/tool/monitor/tests/behat/subscription.feature diff --git a/admin/tool/monitor/tests/behat/subscription.feature b/admin/tool/monitor/tests/behat/subscription.feature new file mode 100644 index 00000000000..7f77bad73e8 --- /dev/null +++ b/admin/tool/monitor/tests/behat/subscription.feature @@ -0,0 +1,119 @@ +@javascript @tool @tool_monitor @tool_monitor_subscriptions +Feature: tool_monitor_subscriptions + In order to monitor events and receive notifications + As an user + I need to create a new rule, subscribe to it, receive notification and delete subscription + + Background: + Given the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "admin" + And I follow "Course 1" + And I navigate to "Manage rules" node in "Course administration > Reports > Event monitor" + And I press "Add a new rule" + And I set the following fields to these values: + | name | New rule course level | + | plugin | Core | + | eventname | Course viewed | + | id_description | I want a rule to monitor when a course is viewed. | + | frequency | 1 | + | minutes | 1 | + | Message template | The course was viewed. {modulelink} | + And I press "Save changes" + And I navigate to "Manage rules" node in "Site administration > Reports > Event monitor" + And I press "Add a new rule" + And I set the following fields to these values: + | name | New rule site level | + | plugin | Core | + | eventname | Course viewed | + | id_description | I want a rule to monitor when a course is viewed. | + | frequency | 1 | + | minutes | 1 | + | Message template | The course was viewed. {modulelink} | + And I press "Save changes" + And I log out + + Scenario: Subscribe to a rule on course level + Given I log in as "teacher1" + And I follow "Course 1" + And I navigate to "Manage subscriptions" node in "Course administration > Reports > Event monitor" + When I set the field "cmid" to "All events" + Then I should see "Subscription successfully created" + And "#toolmonitorsubs_r0" "css_element" should exist + + Scenario: Delete a subscription on course level + Given I log in as "teacher1" + And I follow "Course 1" + And I navigate to "Manage subscriptions" node in "Course administration > Reports > Event monitor" + And I set the field "cmid" to "All events" + And I should see "Subscription successfully created" + When I click on "Delete subscription" "link" + And I should see "Are you sure you want to delete this subscription for the rule \"New rule course level\"?" + And I press "Yes" + Then I should see "Subscription successfully removed" + And "#toolmonitorsubs_r0" "css_element" should not exist + + Scenario: Subscribe to a rule on site level + Given I log in as "admin" + And I navigate to "Manage subscriptions" node in "Site administration > Reports > Event monitor" + When I set the field "cmid" to "All events" + Then I should see "Subscription successfully created" + And "#toolmonitorsubs_r0" "css_element" should exist + + Scenario: Delete a subscription on site level + Given I log in as "admin" + And I navigate to "Manage subscriptions" node in "Site administration > Reports > Event monitor" + And I set the field "cmid" to "All events" + And I should see "Subscription successfully created" + And "#toolmonitorsubs_r0" "css_element" should exist + When I click on "Delete subscription" "link" + And I should see "Are you sure you want to delete this subscription for the rule \"New rule site level\"?" + And I press "Yes" + Then I should see "Subscription successfully removed" + And "#toolmonitorsubs_r0" "css_element" should not exist + + Scenario: Receiving notification on site level + Given I log in as "admin" + And I navigate to "Messaging" node in "My profile settings" + And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element" + And I press "Update profile" + And I am on homepage + And I follow "Course 1" + And I navigate to "Manage subscriptions" node in "Site administration > Reports > Event monitor" + And I set the field "cmid" to "All events" + And I should see "Subscription successfully created" + And "#toolmonitorsubs_r0" "css_element" should exist + And I am on homepage + And I trigger cron + And I am on homepage + And I expand "My profile" node + When I follow "Messages" + And I follow "Do not reply to this email (1)" + Then I should see "The course was viewed." + + Scenario: Receiving notification on course level + Given I log in as "teacher1" + And I navigate to "Messaging" node in "My profile settings" + And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element" + And I press "Update profile" + And I am on homepage + And I follow "Course 1" + And I navigate to "Manage subscriptions" node in "Course administration > Reports > Event monitor" + And I set the field "cmid" to "All events" + And I should see "Subscription successfully created" + And "#toolmonitorsubs_r0" "css_element" should exist + And I am on homepage + And I follow "Course 1" + And I trigger cron + And I am on homepage + And I expand "My profile" node + When I follow "Messages" + And I follow "Do not reply to this email (1)" + Then I should see "The course was viewed."