2 Feature: The forum search allows users to perform advanced searches for forum posts
3 In order to perform an advanced search for a forum post
5 I can use the search feature
8 Given the following "users" exist:
9 | username | firstname | lastname | email | idnumber |
10 | teacher1 | Teacher | ONE | teacher1@example.com | T1 |
11 | teacher2 | Teacher | TWO | teacher2@example.com | T1 |
12 | student1 | Student | 1 | student1@example.com | S1 |
13 And the following "courses" exist:
14 | fullname | shortname | category |
16 And the following "course enrolments" exist:
17 | user | course | role |
18 | teacher1 | C1 | editingteacher |
19 | teacher2 | C1 | editingteacher |
20 | student1 | C1 | student |
21 And the following "tags" exist:
24 And I log in as "teacher1"
25 And I am on "Course 1" course homepage with editing mode on
26 And I add the "Latest announcements" block
27 And I navigate to "Edit settings" node in "Course administration"
28 And I expand all fieldsets
29 And I set the field "id_newsitems" to "1"
30 And I press "Save and display"
31 And I add a new topic to "Announcements" forum with:
32 | Subject | My subject |
33 | Message | My message |
34 And I am on "Course 1" course homepage
35 And I add a new topic to "Announcements" forum with:
36 | Subject | Your subjective|
37 | Message | Your long message |
40 Scenario: Perform an advanced search using any term
41 Given I log in as "student1"
42 And I am on "Course 1" course homepage
43 And I follow "Announcements"
44 And I press "Search forums"
45 And I should see "Advanced search"
46 And I set the field "words" to "subject"
47 When I press "Search forums"
48 Then I should see "My subject"
49 And I should see "Your subjective"
51 Scenario: Perform an advanced search avoiding words
52 Given I log in as "student1"
53 And I am on "Course 1" course homepage
54 And I follow "Announcements"
55 And I press "Search forums"
56 And I should see "Advanced search"
57 And I set the field "words" to "My"
58 And I set the field "notwords" to "subjective"
59 When I press "Search forums"
60 Then I should see "My subject"
61 And I should not see "Your subjective"
63 Scenario: Perform an advanced search using whole words
64 Given database family used is one of the following:
67 And I log in as "student1"
68 And I am on "Course 1" course homepage
69 And I follow "Announcements"
70 And I press "Search forums"
71 And I should see "Advanced search"
72 And I set the field "fullwords" to "subject"
73 When I press "Search forums"
74 Then I should see "My subject"
75 And I should not see "Your subjective"
77 Scenario: Perform an advanced search matching the subject
78 Given I log in as "student1"
79 And I am on "Course 1" course homepage
80 And I follow "Announcements"
81 And I press "Search forums"
82 And I should see "Advanced search"
83 And I set the field "subject" to "subjective"
84 When I press "Search forums"
85 Then I should not see "My message"
86 And I should see "Your subjective"
88 Scenario: Perform an advanced search matching the author
89 Given I log in as "teacher2"
90 And I am on "Course 1" course homepage
91 And I add a new topic to "Announcements" forum with:
92 | Subject | My Subjects |
93 | Message | My message |
95 When I log in as "student1"
96 And I am on "Course 1" course homepage
97 And I follow "Announcements"
98 And I press "Search forums"
99 And I should see "Advanced search"
100 And I set the field "user" to "TWO"
101 And I press "Search forums"
102 Then I should see "Teacher TWO"
103 And I should not see "Teacher ONE"
105 Scenario: Perform an advanced search with multiple words
106 Given I log in as "student1"
107 And I am on "Course 1" course homepage
108 And I follow "Announcements"
109 And I press "Search forums"
110 And I should see "Advanced search"
111 And I set the field "subject" to "your subjective"
112 When I press "Search forums"
113 Then I should not see "My message"
114 And I should see "Your subjective"
117 Scenario: Perform an advanced search using tags
118 Given I log in as "teacher1"
119 And I am on "Course 1" course homepage
120 And I follow "Announcements"
121 And I follow "My subject"
123 And I set the following fields to these values:
124 | Tags | SearchedTag |
125 And I press "Save changes"
127 And I log in as "student1"
128 And I am on "Course 1" course homepage
129 And I follow "Announcements"
130 And I press "Search forums"
131 And I should see "Advanced search"
132 And I set the field "Is tagged with" to "SearchedTag"
133 And I click on "[data-value='SearchedTag']" "css_element"
134 When I press "Search forums"
135 Then I should see "My subject"
136 And I should not see "Your subjective"