Skip to content

Commit

Permalink
MDL-56299 core: fixed failing Behat tests
Browse files Browse the repository at this point in the history
This also involved removing legacy Behat tests.
  • Loading branch information
mdjnelson committed Oct 11, 2016
1 parent 6b5d0e9 commit 16f91ae
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 474 deletions.
26 changes: 14 additions & 12 deletions admin/tool/monitor/tests/behat/subscription.feature
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ Feature: tool_monitor_subscriptions
Scenario: Receiving notification on site level
Given I log in as "admin"
And I follow "Preferences" in the user menu
And I follow "Messaging"
And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element"
And I press "Save changes"
And I click on "Notification preferences" "link" in the "#page-content" "css_element"
And I click on ".preference-state" "css_element" in the "Notifications of rule subscriptions" "table_row"
And I wait until the page is ready
And I follow "Preferences" in the user menu
And I follow "Event monitoring"
And I set the field "Select a course" to "Acceptance test site"
Expand All @@ -113,16 +113,17 @@ Feature: tool_monitor_subscriptions
And I am on site homepage
And I trigger cron
And I am on site homepage
When I follow "Messages" in the user menu
And I follow "Do not reply to this email (1)"
Then I should see "The course was viewed."
When I click on ".popover-region-notifications" "css_element"
And I click on "View more" "link" in the ".popover-region-notifications" "css_element"
Then I should see "New rule site level"
And I should see "The course was viewed"

Scenario: Receiving notification on course level
Given I log in as "teacher1"
And I follow "Preferences" in the user menu
And I follow "Messaging"
And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element"
And I press "Save changes"
And I click on "Notification preferences" "link" in the "#page-content" "css_element"
And I click on ".preference-state" "css_element" in the "Notifications of rule subscriptions" "table_row"
And I wait until the page is ready
And I follow "Preferences" in the user menu
And I follow "Event monitoring"
And I set the field "Select a course" to "Course 1"
Expand All @@ -133,9 +134,10 @@ Feature: tool_monitor_subscriptions
And I follow "Course 1"
And I trigger cron
And I am on site homepage
When I follow "Messages" in the user menu
And I follow "Do not reply to this email (1)"
Then I should see "The course was viewed."
When I click on ".popover-region-notifications" "css_element"
And I click on "View more" "link" in the ".popover-region-notifications" "css_element"
Then I should see "New rule course level"
And I should see "The course was viewed"

Scenario: Navigating via quick link to rules
Given I log in as "admin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ Feature: View the course overview block on the dashboard and test it's functiona
Then I should see "Welcome Student" in the "Course overview" "block"
And I should see "You have no unread messages" in the "Course overview" "block"
And I follow "messages"
And I should see "Contact list empty"
And I should see "No messages"

@javascript
Scenario: View the block by a user with the welcome area and the user having messages.
Given the following config values are set as admin:
| showwelcomearea | 1 | block_course_overview |
Expand Down
4 changes: 3 additions & 1 deletion blocks/messages/tests/behat/block_messages_course.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Feature: The messages block allows users to list new messages an a course
And I add the "Messages" block
Then I should see "No messages waiting" in the "Messages" "block"

@javascript
Scenario: View the block by a user who has messages.
Given I log in as "student1"
And I follow "Messages" in the user menu
Expand All @@ -45,12 +46,13 @@ Feature: The messages block allows users to list new messages an a course
And I add the "Messages" block
Then I should see "Student 1" in the "Messages" "block"

@javascript
Scenario: Use the block to send a message to a user.
Given I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add the "Messages" block
And I follow "Messages"
And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block"
And I send "This is message 1" message to "Student 1" user
And I log out
When I log in as "student1"
Expand Down
4 changes: 3 additions & 1 deletion blocks/messages/tests/behat/block_messages_dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Feature: The messages block allows users to list new messages on the dashboard
When I add the "Messages" block
Then I should see "No messages waiting" in the "Messages" "block"

@javascript
Scenario: View the block by a user who has messages.
Given I log in as "student1"
And I follow "Messages" in the user menu
Expand All @@ -35,11 +36,12 @@ Feature: The messages block allows users to list new messages on the dashboard
And I add the "Messages" block
Then I should see "Student 1" in the "Messages" "block"

@javascript
Scenario: Use the block to send a message to a user.
Given I log in as "teacher1"
And I press "Customise this page"
And I add the "Messages" block
And I follow "Messages"
And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block"
And I send "This is message 1" message to "Student 1" user
And I log out
When I log in as "student1"
Expand Down
4 changes: 3 additions & 1 deletion blocks/messages/tests/behat/block_messages_frontpage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Feature: The messages block allows users to list new messages on the frontpage
When I am on site homepage
Then I should not see "Messages"

@javascript
Scenario: View the block by a user who has messages.
Given I log in as "student1"
And I follow "Messages" in the user menu
Expand All @@ -45,10 +46,11 @@ Feature: The messages block allows users to list new messages on the frontpage
And I am on site homepage
Then I should see "Student 1" in the "Messages" "block"

@javascript
Scenario: Use the block to send a message to a user.
Given I log in as "teacher1"
And I am on site homepage
And I follow "Messages"
And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block"
And I send "This is message 1" message to "Student 1" user
And I log out
When I log in as "student1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Feature: People Block used in a course
When I log in as "student1"
And I follow "Course 1"
And I click on "Participants" "link" in the "People" "block"
Then I should see "All participants" in the "h3" "css_element"
Then I should see "All participants" in the "#page-content" "css_element"
And the "My courses" select box should contain "C101"

Scenario: Student without permission can not view participants link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: Course category management interface performs as expected
And I go to the courses management page
And I should see "Course and category management" in the "h2" "css_element"
And I should see "Course categories" in the ".view-mode-selector" "css_element"
And I should see "Course categories" in the "h3" "css_element"
And I should see "Course categories" in the "#page-content" "css_element"
And I should see the "Course categories and courses" management page

@javascript
Expand Down
50 changes: 32 additions & 18 deletions message/tests/behat/behat_message.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

require_once(__DIR__ . '/../../../lib/behat/behat_base.php');

use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;

/**
* Messaging system steps definitions.
*
Expand All @@ -42,33 +40,49 @@ class behat_message extends behat_base {
/**
* Sends a message to the specified user from the logged user. The user full name should contain the first and last names.
*
* @Given /^I send "(?P<message_contents_string>(?:[^"]|\\")*)" message to "(?P<user_full_name_string>(?:[^"]|\\")*)" user$/
* @param string $messagecontent
* @Given /^I view the message profile for "(?P<user_full_name_string>(?:[^"]|\\")*)" user$/
* @param string $userfullname
*/
public function i_send_message_to_user($messagecontent, $userfullname) {

public function i_view_users_message_profile($userfullname) {
// Visit home page and follow messages.
$this->execute("behat_general::i_am_on_homepage");

if ($this->running_javascript()) {
$this->execute("behat_navigation::i_follow_in_the_user_menu", get_string('messages', 'message'));
} else {
$this->execute("behat_general::click_link", get_string('messages', 'message'));
}
$this->execute("behat_navigation::i_follow_in_the_user_menu", get_string('messages', 'message'));

$this->execute('behat_forms::i_set_the_field_to',
array(get_string('searchcombined', 'message'), $this->escape($userfullname))
);
$this->execute("behat_forms::press_button", get_string('searchcombined', 'message'));
$this->execute('behat_general::i_click_on', array("[data-action='contacts-view']", 'css_element'));

$this->execute("behat_general::click_link", $this->escape(get_string('sendmessageto', 'message', $userfullname)));
$this->execute('behat_general::wait_until_the_page_is_ready');

$this->execute('behat_forms::i_set_the_field_to',
array("id_message", $this->escape($messagecontent))
array(get_string('searchforuserorcourse', 'message'), $this->escape($userfullname))
);

$this->execute("behat_forms::press_button", get_string('sendmessage', 'message'));
$this->execute('behat_general::wait_until_the_page_is_ready');

$this->execute('behat_general::i_click_on', array("//div[@data-action='view-contact-profile']
[./div[contains(normalize-space(.), '" . $this->escape($userfullname) . "')]]", 'xpath_element'));

$this->execute('behat_general::wait_until_the_page_is_ready');
}

/**
* Sends a message to the specified user from the logged user. The user full name should contain the first and last names.
*
* @Given /^I send "(?P<message_contents_string>(?:[^"]|\\")*)" message to "(?P<user_full_name_string>(?:[^"]|\\")*)" user$/
* @param string $messagecontent
* @param string $userfullname
*/
public function i_send_message_to_user($messagecontent, $userfullname) {
$this->i_view_users_message_profile($userfullname);

$this->execute("behat_general::i_click_on", array("[data-action='profile-send-message']", 'css_element'));

$this->execute('behat_general::wait_until_the_page_is_ready');

$this->execute('behat_forms::i_set_the_field_with_xpath_to',
array("//textarea[@data-region='send-message-txt']", $this->escape($messagecontent))
);

$this->execute("behat_forms::press_button", get_string('send', 'message'));
}
}
45 changes: 0 additions & 45 deletions message/tests/behat/block_noncontacts.feature

This file was deleted.

44 changes: 0 additions & 44 deletions message/tests/behat/block_users.feature

This file was deleted.

Loading

0 comments on commit 16f91ae

Please sign in to comment.