Merge branch 'MDL-58465-master' of git://github.com/ankitagarwal/moodle
[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 |
d2ba493c 34 | Tags | SearchedTag |
fdeeaff9 35 And I am on "Course 1" course homepage
1e93eb58
SB
36 And I add a new topic to "Announcements" forum with:
37 | Subject | My subjective|
38 | Message | My long message |
39 And I log out
40
41 Scenario: Perform an advanced search using any term
42 Given I log in as "student1"
fdeeaff9 43 And I am on "Course 1" course homepage
1e93eb58
SB
44 And I follow "Announcements"
45 And I press "Search forums"
46 And I should see "Advanced search"
47 And I set the field "words" to "subject"
48 When I press "Search forums"
49 Then I should see "My subject"
50 And I should see "My subjective"
51
52 Scenario: Perform an advanced search avoiding words
53 Given I log in as "student1"
fdeeaff9 54 And I am on "Course 1" course homepage
1e93eb58
SB
55 And I follow "Announcements"
56 And I press "Search forums"
57 And I should see "Advanced search"
58 And I set the field "words" to "My"
59 And I set the field "notwords" to "subjective"
60 When I press "Search forums"
61 Then I should see "My subject"
62 And I should not see "My subjective"
63
64 Scenario: Perform an advanced search using whole words
99ad3223
RT
65 Given database family used is one of the following:
66 | mysql |
67 | postgres |
68 And I log in as "student1"
fdeeaff9 69 And I am on "Course 1" course homepage
1e93eb58
SB
70 And I follow "Announcements"
71 And I press "Search forums"
72 And I should see "Advanced search"
73 And I set the field "fullwords" to "subject"
74 When I press "Search forums"
75 Then I should see "My subject"
76 And I should not see "My subjective"
77
78 Scenario: Perform an advanced search matching the subject
79 Given I log in as "student1"
fdeeaff9 80 And I am on "Course 1" course homepage
1e93eb58
SB
81 And I follow "Announcements"
82 And I press "Search forums"
83 And I should see "Advanced search"
84 And I set the field "subject" to "subjective"
85 When I press "Search forums"
86 Then I should not see "My message"
87 And I should see "My subjective"
88
89 Scenario: Perform an advanced search matching the author
90 Given I log in as "teacher2"
fdeeaff9 91 And I am on "Course 1" course homepage
1e93eb58
SB
92 And I add a new topic to "Announcements" forum with:
93 | Subject | My Subjects |
94 | Message | My message |
95 And I log out
96 When I log in as "student1"
fdeeaff9 97 And I am on "Course 1" course homepage
1e93eb58
SB
98 And I follow "Announcements"
99 And I press "Search forums"
100 And I should see "Advanced search"
101 And I set the field "user" to "TWO"
102 And I press "Search forums"
103 Then I should see "Teacher TWO"
104 And I should not see "Teacher ONE"
105
106 Scenario: Perform an advanced search with multiple words
107 Given I log in as "student1"
fdeeaff9 108 And I am on "Course 1" course homepage
1e93eb58
SB
109 And I follow "Announcements"
110 And I press "Search forums"
111 And I should see "Advanced search"
112 And I set the field "subject" to "my subjective"
113 When I press "Search forums"
114 Then I should not see "My message"
115 And I should see "My subjective"
d2ba493c
AH
116
117 @javascript
118 Scenario: Perform an advanced search using tags
119 Given I log in as "student1"
32a96916 120 And I am on "Course 1" course homepage
d2ba493c
AH
121 And I follow "Announcements"
122 And I press "Search forums"
123 And I should see "Advanced search"
124 And I set the field "Is tagged with" to "SearchedTag"
125 And I click on "[data-value='SearchedTag']" "css_element"
126 When I press "Search forums"
127 Then I should see "My subject"
128 And I should not see "My subjective"