From 2e782e5142db83dbce170ac29fde86e301445878 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 12 Aug 2015 19:35:09 +0800 Subject: [PATCH] MDL-51088 mod_forum: Improve mod_forum behat performance --- .../tests/behat/discussion_display.feature | 12 +-- .../tests/behat/discussion_navigation.feature | 76 +++++++++---------- .../tests/behat/edit_post_student.feature | 57 +++++++------- .../tests/behat/edit_post_teacher.feature | 3 - mod/forum/tests/behat/my_forum_posts.feature | 13 +--- .../behat/post_to_multiple_groups.feature | 39 ++-------- .../behat/single_forum_discussion.feature | 15 ++-- .../tests/behat/track_read_posts.feature | 7 -- 8 files changed, 87 insertions(+), 135 deletions(-) diff --git a/mod/forum/tests/behat/discussion_display.feature b/mod/forum/tests/behat/discussion_display.feature index 300d393acac..b12f8c60f90 100644 --- a/mod/forum/tests/behat/discussion_display.feature +++ b/mod/forum/tests/behat/discussion_display.feature @@ -37,12 +37,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: @@ -52,12 +51,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: @@ -67,11 +65,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" @@ -80,11 +77,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 a84d660bd4f..36a0c796c85 100644 --- a/mod/forum/tests/behat/discussion_navigation.feature +++ b/mod/forum/tests/behat/discussion_navigation.feature @@ -6,39 +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 am on site homepage - 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 site 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 | @@ -61,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" @@ -70,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 | @@ -102,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" @@ -118,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" @@ -126,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 e5aecd22f62..8f42c7fb1eb 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 45a474ae9cb..bd71def51b8 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/post_to_multiple_groups.feature b/mod/forum/tests/behat/post_to_multiple_groups.feature index e399c488a9f..cfbe9e9eeae 100644 --- a/mod/forum/tests/behat/post_to_multiple_groups.feature +++ b/mod/forum/tests/behat/post_to_multiple_groups.feature @@ -55,37 +55,13 @@ Background: | grouping | group | | G1 | C2G1 | | G1 | C2G2 | - 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 | Separate group forum | - | Forum type | Standard forum for general use | - | Description | Standard forum description | - | Group mode | Separate groups | - And I add a "Forum" to section "2" and I fill the form with: - | Forum name | Visible group forum | - | Forum type | Standard forum for general use | - | Description | Standard forum description | - | Group mode | Visible groups | - And I add a "Forum" to section "3" and I fill the form with: - | Forum name | No group forum | - | Forum type | Standard forum for general use | - | Description | Standard forum description | - | Group mode | No groups | - And I log out - And I log in as "teacher1" - And I follow "Course 2" - And I turn editing mode on - And I add a "Forum" to section "1" and I fill the form with: - | Forum name | Groupings forum | - | Forum type | Standard forum for general use | - | Description | Standard forum description | - | Group mode | Separate groups | - | Grouping | G1 | - And I log out + And the following "activities" exist: + | activity | name | intro | course | idnumber | groupmode | grouping | + | forum | No group forum | Test forum name | C1 | forum | 0 | | + | forum | Separate group forum | Test forum name | C1 | forum | 1 | | + | forum | Visible group forum | Test forum name | C1 | forum | 2 | | + | forum | Groupings forum | Test forum name | C2 | forum | 1 | G1 | - @javascript Scenario: Teacher is able to post a copy of a message to all groups in a separate group forum Given I log in as "teacher1" And I follow "Course 1" @@ -109,7 +85,6 @@ Background: And I follow "Separate group forum" And I should see "Discussion 1" - @javascript Scenario: Teacher is able to post a copy of a message to all groups in a visible group forum Given I log in as "teacher1" And I follow "Course 1" @@ -133,7 +108,6 @@ Background: And I follow "Visible group forum" And I should see "Discussion 1" - @javascript Scenario: Teacher is unable to post a copy of a message to all groups in a no group forum Given I log in as "teacher1" And I follow "Course 1" @@ -141,7 +115,6 @@ Background: And I press "Add a new discussion topic" Then I should not see "Post a copy to all groups" - @javascript Scenario: Posts to all groups that have groupings should only display within the grouping and not to other groups Given I log in as "teacher1" And I follow "Course 2" 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 965d061357c..422e4b84a49 100644 --- a/mod/forum/tests/behat/track_read_posts.feature +++ b/mod/forum/tests/behat/track_read_posts.feature @@ -21,7 +21,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 | @@ -38,7 +37,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 | @@ -64,7 +62,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 | @@ -81,7 +78,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 | @@ -105,7 +101,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 | @@ -129,7 +124,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 | @@ -161,7 +155,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 |