weekly release 3.3dev
[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 |
21 And I log in as "teacher1"
fdeeaff9 22 And I am on "Course 1" course homepage with editing mode on
ba5c5083 23 And I add the "Latest announcements" block
1e93eb58
SB
24 And I navigate to "Edit settings" node in "Course administration"
25 And I set the field "id_newsitems" to "1"
26 And I press "Save and display"
27 And I add a new topic to "Announcements" forum with:
28 | Subject | My subject |
29 | Message | My message |
fdeeaff9 30 And I am on "Course 1" course homepage
1e93eb58
SB
31 And I add a new topic to "Announcements" forum with:
32 | Subject | My subjective|
33 | Message | My long message |
34 And I log out
35
36 Scenario: Perform an advanced search using any term
37 Given I log in as "student1"
fdeeaff9 38 And I am on "Course 1" course homepage
1e93eb58
SB
39 And I follow "Announcements"
40 And I press "Search forums"
41 And I should see "Advanced search"
42 And I set the field "words" to "subject"
43 When I press "Search forums"
44 Then I should see "My subject"
45 And I should see "My subjective"
46
47 Scenario: Perform an advanced search avoiding words
48 Given I log in as "student1"
fdeeaff9 49 And I am on "Course 1" course homepage
1e93eb58
SB
50 And I follow "Announcements"
51 And I press "Search forums"
52 And I should see "Advanced search"
53 And I set the field "words" to "My"
54 And I set the field "notwords" to "subjective"
55 When I press "Search forums"
56 Then I should see "My subject"
57 And I should not see "My subjective"
58
59 Scenario: Perform an advanced search using whole words
99ad3223
RT
60 Given database family used is one of the following:
61 | mysql |
62 | postgres |
63 And I log in as "student1"
fdeeaff9 64 And I am on "Course 1" course homepage
1e93eb58
SB
65 And I follow "Announcements"
66 And I press "Search forums"
67 And I should see "Advanced search"
68 And I set the field "fullwords" to "subject"
69 When I press "Search forums"
70 Then I should see "My subject"
71 And I should not see "My subjective"
72
73 Scenario: Perform an advanced search matching the subject
74 Given I log in as "student1"
fdeeaff9 75 And I am on "Course 1" course homepage
1e93eb58
SB
76 And I follow "Announcements"
77 And I press "Search forums"
78 And I should see "Advanced search"
79 And I set the field "subject" to "subjective"
80 When I press "Search forums"
81 Then I should not see "My message"
82 And I should see "My subjective"
83
84 Scenario: Perform an advanced search matching the author
85 Given I log in as "teacher2"
fdeeaff9 86 And I am on "Course 1" course homepage
1e93eb58
SB
87 And I add a new topic to "Announcements" forum with:
88 | Subject | My Subjects |
89 | Message | My message |
90 And I log out
91 When I log in as "student1"
fdeeaff9 92 And I am on "Course 1" course homepage
1e93eb58
SB
93 And I follow "Announcements"
94 And I press "Search forums"
95 And I should see "Advanced search"
96 And I set the field "user" to "TWO"
97 And I press "Search forums"
98 Then I should see "Teacher TWO"
99 And I should not see "Teacher ONE"
100
101 Scenario: Perform an advanced search with multiple words
102 Given I log in as "student1"
fdeeaff9 103 And I am on "Course 1" course homepage
1e93eb58
SB
104 And I follow "Announcements"
105 And I press "Search forums"
106 And I should see "Advanced search"
107 And I set the field "subject" to "my subjective"
108 When I press "Search forums"
109 Then I should not see "My message"
110 And I should see "My subjective"