From 8422698a06d1d7a9601a4152f414406c696874b4 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Tue, 28 Feb 2023 11:21:25 +0800 Subject: [PATCH] MDL-77428 Behat: Add coverage for forum post word count --- .../behat/forum_display_word_count.feature | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 mod/forum/tests/behat/forum_display_word_count.feature diff --git a/mod/forum/tests/behat/forum_display_word_count.feature b/mod/forum/tests/behat/forum_display_word_count.feature new file mode 100644 index 00000000000..9f1651a673b --- /dev/null +++ b/mod/forum/tests/behat/forum_display_word_count.feature @@ -0,0 +1,69 @@ +@mod @mod_forum +Feature: Forum posts display word count + In order to display forum word count + As a teacher + I need to be able to update forum and set "Display word count" to Yes + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | t1@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 | + + Scenario: Forum posts display word count for single simple discussion forum + Given the following "activities" exist: + | activity | course | name | type | displaywordcount | intro | + | forum | C1 | Forum 1 | single | 1 | Single forum post | + When I am on the "Forum 1" "forum activity" page logged in as teacher1 + Then I should see "3 words" + And I am on the "Forum 1" "forum activity editing" page + And I expand all fieldsets + And I set the field "Display word count" to "No" + And I press "Save and display" + And I am on the "Forum 1" "forum activity" page + And I should not see "3 words" + + Scenario: Forum posts display word count for blog-like forum + Given the following "activities" exist: + | activity | course | name | type | displaywordcount | + | forum | C1 | Forum 1 | blog | 1 | + And the following "mod_forum > discussions" exist: + | forum | name | subject | message | + | Forum 1 | Blog Forum | Blog Forum | This is a blog forum post | + When I am on the "Forum 1" "forum activity" page logged in as teacher1 + Then I should see "6 words" + And I am on the "Forum 1" "forum activity editing" page + And I expand all fieldsets + And I set the field "Display word count" to "No" + And I press "Save and display" + And I am on the "Forum 1" "forum activity" page + And I should not see "6 words" + + Scenario Outline: Forum posts display word count for other forum types + Given the following "activities" exist: + | activity | course | name | type | displaywordcount | + | forum | C1 | Forum 1 | | 1 | + And the following "mod_forum > discussions" exist: + | forum | name | subject | message | + | Forum 1 | | | | + When I am on the "Forum 1" "forum activity" page logged in as teacher1 + And I follow "" + Then I should see " words" + And I am on the "Forum 1" "forum activity editing" page + And I expand all fieldsets + And I set the field "Display word count" to "No" + And I press "Save and display" + And I am on the "Forum 1" "forum activity" page + And I follow "" + Then I should not see " words" + + Examples: + | type | typeext | message | count | + | general | General Forum | General discussion in forum | 4 | + | eachuser | Each User Forum | This is an each user forum post | 7 | + | qanda | Q and A Forum | This is a Q and A type forum | 8 |