MDL-33486 wiki: allow searching individual wikis
[moodle.git] / mod / wiki / tests / behat / wiki_search.feature
blobee0a687038bca0b6a6768554c497a9e7d8f26297
1 @mod @mod_wiki
2 Feature: Users can search wikis
3   In order to find information in wiki
4   As a user
5   I need to be able to search individual and collaborative wikis
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email |
10       | teacher1 | Teacher | 1 | teacher1@asd.com |
11       | student1 | Student | 1 | student1@asd.com |
12       | student2 | Student | 2 | student2@asd.com |
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       | student1 | C1 | student |
20       | student2 | C1 | student |
22   @javascript
23   Scenario: Searching collaborative wiki
24     Given I log in as "teacher1"
25     And I follow "Course 1"
26     And I turn editing mode on
27     And I add a "Wiki" to section "1" and I fill the form with:
28       | Wiki name | Collaborative wiki name |
29       | Description | Collaborative wiki description |
30       | First page name | Collaborative index |
31       | Wiki mode | Collaborative wiki |
32     And I follow "Collaborative wiki name"
33     And I press "Create page"
34     And I set the following fields to these values:
35       | HTML format | Collaborative teacher1 page [[new page]] |
36     And I press "Save"
37     And I follow "Course 1"
38     And I log out
39     And I log in as "student1"
40     And I follow "Course 1"
41     And I follow "Collaborative wiki name"
42     And I follow "new page"
43     And I press "Create page"
44     And I set the following fields to these values:
45       | HTML format | New page created by student1 |
46     And I press "Save"
47     When I set the field "searchstring" to "page"
48     And I press "Search wikis"
49     Then I should see "New page created by student1"
50     And I should see "Collaborative teacher1 page"
51     And I set the field "searchstring" to "teacher1"
52     And I press "Search wikis"
53     And I should not see "New page created by student1"
54     And I should see "Collaborative teacher1 page"
55     And I log out
58   @javascript
59   Scenario: Searching individual wiki
60     Given I log in as "teacher1"
61     And I follow "Course 1"
62     And I turn editing mode on
63     And I add a "Wiki" to section "1" and I fill the form with:
64       | Wiki name | Individual wiki name |
65       | Description | Individual wiki description |
66       | First page name | Individual index |
67       | Wiki mode | Individual wiki |
68     And I follow "Individual wiki name"
69     And I press "Create page"
70     And I set the following fields to these values:
71       | HTML format | Individual teacher1 page |
72     And I press "Save"
73     And I log out
74     And I log in as "student1"
75     And I follow "Course 1"
76     And I follow "Individual wiki name"
77     And I press "Create page"
78     And I set the following fields to these values:
79       | HTML format | Individual student1 page |
80     And I press "Save"
81     When I set the field "searchstring" to "page"
82     And I press "Search wikis"
83     Then I should see "Individual student1 page"
84     And I should not see "Individual teacher1 page"
85     And I log out
86     And I log in as "student2"
87     And I follow "Course 1"
88     And I follow "Individual wiki name"
89     And I press "Create page"
90     And I set the following fields to these values:
91       | HTML format | Individual student2 page |
92     And I press "Save"
93     And I set the field "searchstring" to "page"
94     And I press "Search wikis"
95     And I should see "Individual student2 page"
96     And I should not see "Individual student1 page"
97     And I should not see "Individual teacher1 page"
98     And I log out
99     And I log in as "teacher1"
100     And I follow "Course 1"
101     And I follow "Individual wiki name"
102     And I set the field "searchstring" to "page"
103     And I press "Search wikis"
104     And I should see "Individual teacher1 page"
105     And I should not see "Individual student1 page"
106     And I should not see "Individual student2 page"
107     And I set the field "uid" to "Student 1"
108     And I should not see "Individual teacher1 page"
109     And I should see "Individual student1 page"
110     And I should not see "Individual student2 page"
111     And I set the field "uid" to "Student 2"
112     And I should not see "Individual teacher1 page"
113     And I should not see "Individual student1 page"
114     And I should see "Individual student2 page"
115     And I log out
117   @javascript
118   Scenario: Searching group wiki
119     Given the following "groups" exist:
120       | name | course | idnumber |
121       | Group1 | C1 | G1 |
122       | Group2 | C1 | G2 |
123     And the following "group members" exist:
124       | user | group |
125       | student1 | G1 |
126       | student2 | G2 |
127     And I log in as "teacher1"
128     And I follow "Course 1"
129     And I turn editing mode on
130     And I add a "Wiki" to section "1" and I fill the form with:
131       | Wiki name | Group wiki name |
132       | Description | Wiki description |
133       | First page name | Groups index |
134       | Wiki mode | Collaborative wiki |
135       | Group mode | Separate groups |
136     And I follow "Group wiki name"
137     And I set the field "Group" to "All participants"
138     And I press "Create page"
139     And I set the following fields to these values:
140       | HTML format | All participants teacher1 page |
141     And I press "Save"
142     And I set the field "group" to "Group1"
143     And I press "Create page"
144     And I set the following fields to these values:
145       | HTML format | Group1 teacher1 page [[new page1]] |
146     And I press "Save"
147     And I set the field "group" to "Group2"
148     And I press "Create page"
149     And I set the following fields to these values:
150       | HTML format | Group2 teacher1 page [[new page2]] |
151     And I press "Save"
152     And I log out
153     And I log in as "student1"
154     And I follow "Course 1"
155     And I follow "Group wiki name"
156     And I follow "new page1"
157     And I press "Create page"
158     And I set the following fields to these values:
159       | HTML format | Group1 student1 new page |
160     And I press "Save"
161     When I set the field "searchstring" to "page"
162     And I press "Search wikis"
163     Then I should see "Group1 teacher1 page"
164     And I should not see "Group2 teacher1 page"
165     And I should see "Group1 student1 new page"
166     And I should not see "All participants teacher1 page"
167     And I log out
168     And I log in as "student2"
169     And I follow "Course 1"
170     And I follow "Group wiki name"
171     And I follow "new page2"
172     And I press "Create page"
173     And I set the following fields to these values:
174       | HTML format | Group2 student2 new page |
175     And I press "Save"
176     And I set the field "searchstring" to "page"
177     And I press "Search wikis"
178     And I should not see "Group1 teacher1 page"
179     And I should see "Group2 teacher1 page"
180     And I should not see "Group1 student1 new page"
181     And I should see "Group2 student2 new page"
182     And I should not see "All participants teacher1 page"
183     And I log out
184     And I log in as "teacher1"
185     And I follow "Course 1"
186     And I follow "Group wiki name"