From 89b453d1f6b224dfa1e98f0376d4fa7385b33d90 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 12 Aug 2015 19:34:49 +0800 Subject: [PATCH 1/2] MDL-51088 completion: Do not require hover to confirm xpath --- completion/tests/behat/behat_completion.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/completion/tests/behat/behat_completion.php b/completion/tests/behat/behat_completion.php index 807c7fea7f0..c0eb174e5e7 100644 --- a/completion/tests/behat/behat_completion.php +++ b/completion/tests/behat/behat_completion.php @@ -27,7 +27,8 @@ require_once(__DIR__ . '/../../../lib/behat/behat_base.php'); -use Behat\Behat\Context\Step\Given as Given, +use Behat\Behat\Context\Step\Given, + Behat\Behat\Context\Step\Then, Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException; /** @@ -56,7 +57,7 @@ class behat_completion extends behat_base { return array( new Given('I go to the current course activity completion report'), - new Given('I hover "' . $this->escape($xpath) . '" "xpath_element"') + new Then('"' . $this->escape($xpath) . '" "xpath_element" should exist') ); } @@ -75,7 +76,7 @@ class behat_completion extends behat_base { "/descendant::img[contains(@title, $titleliteral)]"; return array( new Given('I go to the current course activity completion report'), - new Given('I hover "' . $this->escape($xpath) . '" "xpath_element"') + new Then('"' . $this->escape($xpath) . '" "xpath_element" should exist') ); return $steps; From c658ddf1292a894573c901cd84e7a3100d939878 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 12 Aug 2015 19:35:09 +0800 Subject: [PATCH 2/2] MDL-51088 mod_forum: Improve mod_forum behat performance --- .../tests/behat/discussion_display.feature | 12 +-- .../tests/behat/discussion_navigation.feature | 75 ++++++++++--------- .../tests/behat/edit_post_student.feature | 57 +++++++------- .../tests/behat/edit_post_teacher.feature | 3 - mod/forum/tests/behat/my_forum_posts.feature | 13 +--- .../behat/single_forum_discussion.feature | 15 ++-- .../tests/behat/track_read_posts.feature | 7 -- 7 files changed, 81 insertions(+), 101 deletions(-) diff --git a/mod/forum/tests/behat/discussion_display.feature b/mod/forum/tests/behat/discussion_display.feature index c01188cd651..705cb844763 100644 --- a/mod/forum/tests/behat/discussion_display.feature +++ b/mod/forum/tests/behat/discussion_display.feature @@ -36,12 +36,11 @@ Feature: Students can choose from 4 discussion display options and their choice And I log in as "student1" And I follow "Course 1" - @javascript Scenario: Display replies flat, with oldest first Given I reply "Discussion 1" post from "Test forum name" forum with: | Subject | Reply 2 to discussion 1 | | Message | Discussion contents 1, third message | - When I set the field "mode" to "Display replies flat, with oldest first" + When I select "Display replies flat, with oldest first" from the "mode" singleselect Then I should see "Discussion contents 1, first message" in the "div.firstpost.starter" "css_element" And I should see "Discussion contents 1, second message" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ') and not(contains(@class, 'starter'))]" "xpath_element" And I reply "Discussion 2" post from "Test forum name" forum with: @@ -51,12 +50,11 @@ Feature: Students can choose from 4 discussion display options and their choice And I should see "Discussion contents 2, first message" in the "div.firstpost.starter" "css_element" And I should see "Discussion contents 2, second message" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ') and not(contains(@class, 'starter'))]" "xpath_element" - @javascript Scenario: Display replies flat, with newest first Given I reply "Discussion 1" post from "Test forum name" forum with: | Subject | Reply 2 to discussion 1 | | Message | Discussion contents 1, third message | - When I set the field "mode" to "Display replies flat, with newest first" + When I select "Display replies flat, with newest first" from the "mode" singleselect Then I should see "Discussion contents 1, first message" in the "div.firstpost.starter" "css_element" And I should see "Discussion contents 1, third message" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ') and not(contains(@class, 'starter'))]" "xpath_element" And I reply "Discussion 2" post from "Test forum name" forum with: @@ -66,11 +64,10 @@ Feature: Students can choose from 4 discussion display options and their choice And I should see "Discussion contents 2, first message" in the "div.firstpost.starter" "css_element" And I should see "Discussion contents 2, third message" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ') and not(contains(@class, 'starter'))]" "xpath_element" - @javascript Scenario: Display replies in threaded form Given I follow "Test forum name" And I follow "Discussion 1" - When I set the field "mode" to "Display replies in threaded form" + When I select "Display replies in threaded form" from the "mode" singleselect Then I should see "Discussion contents 1, first message" And I should see "Reply 1 to discussion 1" in the "span.forumthread" "css_element" And I follow "Test forum name" @@ -79,11 +76,10 @@ Feature: Students can choose from 4 discussion display options and their choice And I should see "Discussion contents 2, first message" And I should see "Reply 1 to discussion 2" in the "span.forumthread" "css_element" - @javascript Scenario: Display replies in nested form Given I follow "Test forum name" And I follow "Discussion 1" - When I set the field "mode" to "Display replies in nested form" + When I select "Display replies in nested form" from the "mode" singleselect Then I should see "Discussion contents 1, first message" in the "div.firstpost.starter" "css_element" And I should see "Discussion contents 1, second message" in the "div.indent div.forumpost" "css_element" And I follow "Test forum name" diff --git a/mod/forum/tests/behat/discussion_navigation.feature b/mod/forum/tests/behat/discussion_navigation.feature index 03025c50445..36a0c796c85 100644 --- a/mod/forum/tests/behat/discussion_navigation.feature +++ b/mod/forum/tests/behat/discussion_navigation.feature @@ -6,38 +6,36 @@ Feature: A user can navigate to previous and next discussions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | student1 | Student | 1 | student1@example.com | - | student2 | Student | 2 | student2@example.com | + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + | student1 | Student | 1 | student1@example.com | + | student2 | Student | 2 | student2@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | + | Course 1 | C1 | 0 | And the following "course enrolments" exist: | user | course | role | + | teacher1 | C1 | editingteacher | | student1 | C1 | student | | student2 | C1 | student | - And I log in as "admin" - And I follow "Course 1" - And I navigate to "Groups" node in "Users" - And I press "Create group" - And I set the following fields to these values: - | Group name | Group 1 | - And I press "Save changes" - And I press "Create group" - And I set the following fields to these values: - | Group name | Group 2 | - And I press "Save changes" - And I add "Student 1" user to "Group 1" group members - And I add "Student 2" user to "Group 2" group members - And I am on homepage - And I follow "Course 1" - And I turn editing mode on + And the following "groups" exist: + | name | course | idnumber | + | Group 1 | C1 | G1 | + | Group 2 | C1 | G2 | + And the following "group members" exist: + | user | group | + | teacher1 | G1 | + | teacher1 | G2 | + | student1 | G1 | + | student2 | G2 | - @javascript Scenario: A user can navigate between discussions - Given I add a "Forum" to section "1" and I fill the form with: - | Forum name | Test forum name | - | Description | Test forum description | + Given the following "activities" exist: + | activity | name | intro | course | idnumber | groupmode | + | forum | Test forum name | Test forum name | C1 | forum | 0 | + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Test forum name" And I add a new discussion to "Test forum name" forum with: | Subject | Discussion 1 | | Message | Test post message | @@ -60,6 +58,7 @@ Feature: A user can navigate to previous and next discussions And I set the following fields to these values: | Message | Answer to discussion | And I press "Post to forum" + And I wait to be redirected And I should not see "Discussion 2" And I should see "Discussion 3" And I follow "Discussion 3" @@ -69,12 +68,13 @@ Feature: A user can navigate to previous and next discussions And I should not see "Discussion 1" And I should see "Discussion 3" - @javascript Scenario: A user can navigate between discussions with visible groups - Given I add a "Forum" to section "1" and I fill the form with: - | Forum name | Test forum name | - | Description | Test forum description | - | Group mode | Visible groups | + Given the following "activities" exist: + | activity | name | intro | course | idnumber | groupmode | + | forum | Test forum name | Test forum name | C1 | forum | 2 | + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Test forum name" And I add a new discussion to "Test forum name" forum with: | Subject | Discussion 1 Group 0 | | Message | Test post message | @@ -101,7 +101,7 @@ Feature: A user can navigate to previous and next discussions When I log in as "student1" And I follow "Course 1" And I follow "Test forum name" - And I set the field "Visible groups" to "All participants" + And I select "All participants" from the "Visible groups" singleselect And I follow "Discussion 1 Group 0" Then I should see "Discussion 2 Group 0" And I should not see "Group 1" @@ -117,7 +117,7 @@ Feature: A user can navigate to previous and next discussions And I should see "Discussion 2 Group 1" And I should see "Discussion 2 Group 2" And I follow "Test forum name" - And I set the field "Visible groups" to "Group 1" + And I select "Group 1" from the "Visible groups" singleselect And I follow "Discussion 1 Group 1" Then I should see "Discussion 2 Group 0" And I should see "Discussion 2 Group 1" @@ -125,12 +125,13 @@ Feature: A user can navigate to previous and next discussions And I should see "Discussion 1 Group 1" And I should not see "Group 2" - @javascript Scenario: A user can navigate between discussions with separate groups - Given I add a "Forum" to section "1" and I fill the form with: - | Forum name | Test forum name | - | Description | Test forum description | - | Group mode | Separate groups | + Given the following "activities" exist: + | activity | name | intro | course | idnumber | groupmode | + | forum | Test forum name | Test forum name | C1 | forum | 1 | + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Test forum name" And I add a new discussion to "Test forum name" forum with: | Subject | Discussion 1 Group 0 | | Message | Test post message | diff --git a/mod/forum/tests/behat/edit_post_student.feature b/mod/forum/tests/behat/edit_post_student.feature index 6b3d5a8c915..8e04ba39b26 100644 --- a/mod/forum/tests/behat/edit_post_student.feature +++ b/mod/forum/tests/behat/edit_post_student.feature @@ -14,6 +14,35 @@ Feature: Students can edit or delete their forum posts within a set time limit And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | + And the following "activities" exist: + | activity | name | intro | course | idnumber | + | forum | Test forum name | Test forum description | C1 | forum | + And I log in as "student1" + And I follow "Course 1" + And I add a new discussion to "Test forum name" forum with: + | Subject | Forum post subject | + | Message | This is the body | + + Scenario: Edit forum post + Given I follow "Forum post subject" + And I follow "Edit" + When I set the following fields to these values: + | Subject | Edited post subject | + | Message | Edited post body | + And I press "Save changes" + And I wait to be redirected + Then I should see "Edited post subject" + And I should see "Edited post body" + + Scenario: Delete forum post + Given I follow "Forum post subject" + When I follow "Delete" + And I press "Continue" + Then I should not see "Forum post subject" + + @javascript + Scenario: Time limit expires + Given I log out And I log in as "admin" And I expand "Site administration" node And I expand "Security" node @@ -28,33 +57,9 @@ Feature: Students can edit or delete their forum posts within a set time limit | Forum type | Standard forum for general use | | Description | Test forum description | And I log out - And I follow "Course 1" And I log in as "student1" - And I add a new discussion to "Test forum name" forum with: - | Subject | Forum post subject | - | Message | This is the body | - - Scenario: Edit forum post - When I follow "Forum post subject" - And I follow "Edit" - And I set the following fields to these values: - | Subject | Edited post subject | - | Message | Edited post body | - And I press "Save changes" - And I wait to be redirected - Then I should see "Edited post subject" - And I should see "Edited post body" - - @javascript - Scenario: Delete forum post - When I follow "Forum post subject" - And I follow "Delete" - And I press "Continue" - Then I should not see "Forum post subject" - - @javascript - Scenario: Time limit expires - When I wait "70" seconds + And I follow "Course 1" + When I wait "61" seconds And I follow "Forum post subject" Then I should not see "Edit" in the "region-main" "region" And I should not see "Delete" in the "region-main" "region" diff --git a/mod/forum/tests/behat/edit_post_teacher.feature b/mod/forum/tests/behat/edit_post_teacher.feature index 3cc1dfd0e7b..42db6130826 100644 --- a/mod/forum/tests/behat/edit_post_teacher.feature +++ b/mod/forum/tests/behat/edit_post_teacher.feature @@ -32,7 +32,6 @@ Feature: Teachers can edit or delete any forum post | Subject | Student post subject | | Message | Student post message | - @javascript Scenario: A teacher can delete another user's posts Given I log out And I log in as "teacher1" @@ -44,7 +43,6 @@ Feature: Teachers can edit or delete any forum post Then I should not see "Student post subject" And I should not see "Student post message" - @javascript Scenario: A teacher can edit another user's posts Given I log out And I log in as "teacher1" @@ -59,7 +57,6 @@ Feature: Teachers can edit or delete any forum post Then I should see "Edited student subject" And I should see "Edited by Teacher 1 - original submission" - @javascript Scenario: A student can't edit or delete another user's posts When I follow "Teacher post subject" Then I should not see "Edit" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][contains(., 'Teacher post subject')]" "xpath_element" diff --git a/mod/forum/tests/behat/my_forum_posts.feature b/mod/forum/tests/behat/my_forum_posts.feature index 20f405b4660..6db380d2eb2 100644 --- a/mod/forum/tests/behat/my_forum_posts.feature +++ b/mod/forum/tests/behat/my_forum_posts.feature @@ -7,23 +7,16 @@ Feature: A user can view their posts and discussions Scenario: View the student's posts and discussions Given the following "users" exist: | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | | student1 | Student | 1 | student1@example.com | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: | user | course | role | - | teacher1 | C1 | editingteacher | | student1 | C1 | student | - And I log in as "teacher1" - And I follow "Course 1" - And I turn editing mode on - And I add a "Forum" to section "1" and I fill the form with: - | Forum name | Test forum name | - | Forum type | Standard forum for general use | - | Description | Test forum description | - And I log out + And the following "activities" exist: + | activity | name | intro | course | idnumber | groupmode | + | forum | Test forum name | Test forum | C1 | forum | 0 | And I log in as "student1" And I follow "Course 1" And I add a new discussion to "Test forum name" forum with: diff --git a/mod/forum/tests/behat/single_forum_discussion.feature b/mod/forum/tests/behat/single_forum_discussion.feature index cd6d196a67c..ca4f90676d0 100644 --- a/mod/forum/tests/behat/single_forum_discussion.feature +++ b/mod/forum/tests/behat/single_forum_discussion.feature @@ -16,23 +16,18 @@ Feature: Single simple forum discussion type | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | - And I log in as "teacher1" - And I follow "Course 1" - And I turn editing mode on - And I add a "Forum" to section "1" and I fill the form with: - | Forum name | Single discussion forum name | - | Forum type | A single simple discussion | - | Description | Single discussion forum description | + And the following "activities" exist: + | activity | name | intro | type | course | idnumber | + | forum | Single discussion forum name | Single discussion forum description | single | C1 | forum | - @javascript Scenario: Teacher can start the single simple discussion + Given I log in as "teacher1" + And I follow "Course 1" When I follow "Single discussion forum name" Then I should see "Single discussion forum description" in the "div.firstpost.starter" "css_element" And I should not see "Add a new discussion topic" - @javascript Scenario: Student can not add more discussions - Given I log out And I log in as "student1" And I follow "Course 1" When I reply "Single discussion forum name" post from "Single discussion forum name" forum with: diff --git a/mod/forum/tests/behat/track_read_posts.feature b/mod/forum/tests/behat/track_read_posts.feature index 13d5ab90df7..ba066799050 100644 --- a/mod/forum/tests/behat/track_read_posts.feature +++ b/mod/forum/tests/behat/track_read_posts.feature @@ -20,7 +20,6 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos And I follow "Course 1" And I turn editing mode on - @javascript Scenario: Tracking forum posts off Given I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | @@ -37,7 +36,6 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos And I follow "Test forum name" And I should not see "Track unread posts" - @javascript Scenario: Tracking forum posts optional with user tracking on Given I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | @@ -63,7 +61,6 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos And I follow "Course 1" And I should not see "1 unread post" - @javascript Scenario: Tracking forum posts optional with user tracking off Given I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | @@ -80,7 +77,6 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos And I follow "Test forum name" And I should not see "Track unread posts" - @javascript Scenario: Tracking forum posts forced with user tracking on Given the following config values are set as admin: | forum_allowforcedreadtracking | 1 | @@ -104,7 +100,6 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos And I follow "Course 1" And I should not see "1 unread post" - @javascript Scenario: Tracking forum posts forced with user tracking off Given the following config values are set as admin: | forum_allowforcedreadtracking | 1 | @@ -128,7 +123,6 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos And I follow "Course 1" And I should not see "1 unread post" - @javascript Scenario: Tracking forum posts forced (with force disabled) with user tracking on Given the following config values are set as admin: | forum_allowforcedreadtracking | 1 | @@ -160,7 +154,6 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos And I follow "Course 1" And I should not see "1 unread post" - @javascript Scenario: Tracking forum posts forced (with force disabled) with user tracking off Given the following config values are set as admin: | forum_allowforcedreadtracking | 1 |