MDL-46929 mod_forum: behat fixes
[moodle.git] / mod / forum / tests / behat / advanced_search.feature
CommitLineData
1e93eb58
SB
1@mod @mod_forum
2Feature: The forum search allows users to perform advanced searches for forum posts
3 In order to perform an advanced search for a forum post
4 As a teacher
5 I can use the search feature
6
7 Background:
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 |
15 | Course 1 | C1 | 0 |
16 And the following "course enrolments" exist:
17 | user | course | role |
18 | teacher1 | C1 | editingteacher |
19 | teacher2 | C1 | editingteacher |
20 | student1 | C1 | student |
d2ba493c
AH
21 And the following "tags" exist:
22 | name | isstandard |
23 | SearchedTag | 1 |
1e93eb58 24 And I log in as "teacher1"
fdeeaff9 25 And I am on "Course 1" course homepage with editing mode on
ba5c5083 26 And I add the "Latest announcements" block
1e93eb58 27 And I navigate to "Edit settings" node in "Course administration"
32a96916 28 And I expand all fieldsets
1e93eb58
SB
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 |
fdeeaff9 34 And I am on "Course 1" course homepage
1e93eb58 35 And I add a new topic to "Announcements" forum with:
43bb3b77
EL
36 | Subject | Your subjective|
37 | Message | Your long message |
1e93eb58
SB
38 And I log out
39
40 Scenario: Perform an advanced search using any term
41 Given I log in as "student1"
fdeeaff9 42 And I am on "Course 1" course homepage
1e93eb58
SB
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"
43bb3b77 49 And I should see "Your subjective"
1e93eb58
SB
50
51 Scenario: Perform an advanced search avoiding words
52 Given I log in as "student1"
fdeeaff9 53 And I am on "Course 1" course homepage
1e93eb58
SB
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"
43bb3b77 61 And I should not see "Your subjective"
1e93eb58
SB
62
63 Scenario: Perform an advanced search using whole words
99ad3223
RT
64 Given database family used is one of the following:
65 | mysql |
66 | postgres |
67 And I log in as "student1"
fdeeaff9 68 And I am on "Course 1" course homepage
1e93eb58
SB
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"
43bb3b77 75 And I should not see "Your subjective"
1e93eb58
SB
76
77 Scenario: Perform an advanced search matching the subject
78 Given I log in as "student1"
fdeeaff9 79 And I am on "Course 1" course homepage
1e93eb58
SB
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"
43bb3b77 86 And I should see "Your subjective"
1e93eb58
SB
87
88 Scenario: Perform an advanced search matching the author
89 Given I log in as "teacher2"
fdeeaff9 90 And I am on "Course 1" course homepage
1e93eb58
SB
91 And I add a new topic to "Announcements" forum with:
92 | Subject | My Subjects |
93 | Message | My message |
94 And I log out
95 When I log in as "student1"
fdeeaff9 96 And I am on "Course 1" course homepage
1e93eb58
SB
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"
104
105 Scenario: Perform an advanced search with multiple words
106 Given I log in as "student1"
fdeeaff9 107 And I am on "Course 1" course homepage
1e93eb58
SB
108 And I follow "Announcements"
109 And I press "Search forums"
110 And I should see "Advanced search"
43bb3b77 111 And I set the field "subject" to "your subjective"
1e93eb58
SB
112 When I press "Search forums"
113 Then I should not see "My message"
43bb3b77 114 And I should see "Your subjective"
d2ba493c
AH
115
116 @javascript
117 Scenario: Perform an advanced search using tags
43bb3b77
EL
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"
122 And I follow "Edit"
123 And I set the following fields to these values:
124 | Tags | SearchedTag |
125 And I press "Save changes"
126 And I log out
127 And I log in as "student1"
32a96916 128 And I am on "Course 1" course homepage
d2ba493c
AH
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"
43bb3b77 136 And I should not see "Your subjective"