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