2 Feature: New discussions and discussions with recently added replies are displayed first
3 In order to use forum as a discussion tool
5 I need to see currently active discussions first
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | teacher1 | Teacher | 1 | teacher1@example.com |
11 | student1 | Student | 1 | student1@example.com |
12 And the following "courses" exist:
13 | fullname | shortname | category |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | teacher1 | C1 | editingteacher |
18 | student1 | C1 | student |
19 And I log in as "teacher1"
20 And I follow "Course 1"
21 And I turn editing mode on
22 And I add a "Forum" to section "1" and I fill the form with:
23 | Forum name | Course general forum |
24 | Description | Single discussion forum description |
25 | Forum type | Standard forum for general use |
29 # We need javascript/wait to prevent creation of the posts in the same second. The threads
30 # would then ignore each other in the prev/next navigation as the Forum is unable to compute
34 Scenario: Replying to a forum post or editing it puts the discussion to the front
35 Given I log in as "student1"
36 And I follow "Course 1"
37 And I follow "Course general forum"
39 # Add three posts into the forum.
41 When I add a new discussion to "Course general forum" forum with:
42 | Subject | Forum post 1 |
43 | Message | This is the first post |
44 And I wait "1" seconds
45 And I add a new discussion to "Course general forum" forum with:
46 | Subject | Forum post 2 |
47 | Message | This is the second post |
48 And I wait "1" seconds
49 And I add a new discussion to "Course general forum" forum with:
50 | Subject | Forum post 3 |
51 | Message | This is the third post |
53 # Edit one of the forum posts.
55 And I follow "Forum post 2"
56 And I click on "Edit" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][contains(., 'Forum post 2')]" "xpath_element"
57 And I set the following fields to these values:
58 | Subject | Edited forum post 2 |
59 And I press "Save changes"
60 And I wait to be redirected
63 # Reply to another forum post.
65 And I log in as "teacher1"
66 And I follow "Course 1"
67 And I follow "Course general forum"
68 And I follow "Forum post 1"
69 And I click on "Reply" "link" in the "//div[@aria-label='Forum post 1 by Student 1']" "xpath_element"
70 And I set the following fields to these values:
71 | Message | Reply to the first post |
72 And I press "Post to forum"
73 And I wait to be redirected
74 And I am on site homepage
75 And I follow "Course 1"
76 And I follow "Course general forum"
78 # Make sure the order of the forum posts is as expected (most recently participated first).
80 Then I should see "Forum post 3" in the "//tr[contains(concat(' ', normalize-space(@class), ' '), ' discussion ')][position()=3]" "xpath_element"
81 And I should see "Edited forum post 2" in the "//tr[contains(concat(' ', normalize-space(@class), ' '), ' discussion ')][position()=2]" "xpath_element"
82 And I should see "Forum post 1" in the "//tr[contains(concat(' ', normalize-space(@class), ' '), ' discussion ')][position()=1]" "xpath_element"
84 # Make sure the next/prev navigation uses the same order of the posts.
86 And I follow "Edited forum post 2"
87 And "//a[@aria-label='Next discussion: Forum post 1']" "xpath_element" should exist
88 And "//a[@aria-label='Previous discussion: Forum post 3']" "xpath_element" should exist