3 * Copyright 2011, Roland Mas
5 * This file is part of FusionForge.
7 * FusionForge is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License,
10 * or (at your option) any later version.
12 * FusionForge is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 require_once dirname(dirname(__FILE__)).'/Testing/SeleniumGforge.php';
24 class Search extends FForge_SeleniumTestCase
32 $this->populateStandardTemplate();
33 $this->createProject('projecta');
34 $this->createProject('projectb');
37 $this->waitForPageToLoad("30000");
38 $this->type("//input[@name='words']", "XXXXXXXXXXXXXXXXXXXXXXXXXX");
39 $this->click("//input[@name='Search']");
40 $this->waitForPageToLoad("30000");
41 $this->assertTrue($this->isTextPresent("No matches found for"));
44 $this->waitForPageToLoad("30000");
45 $this->type("//input[@name='words']", "projecta");
46 $this->click("//input[@name='Search']");
47 $this->waitForPageToLoad("30000");
48 $this->assertFalse($this->isTextPresent("No matches found for"));
49 $this->assertTrue($this->isTextPresent("public description for projecta"));
50 $this->assertFalse($this->isTextPresent("public description for projectb"));
53 $this->waitForPageToLoad("30000");
54 $this->type("//input[@name='words']", "description public projecta");
55 $this->click("//input[@name='Search']");
56 $this->waitForPageToLoad("30000");
57 $this->assertFalse($this->isTextPresent("No matches found for"));
58 $this->assertTrue($this->isTextPresent("public description for projecta"));
59 $this->assertFalse($this->isTextPresent("public description for projectb"));
62 $this->waitForPageToLoad("30000");
63 $this->type("//input[@name='words']", "description 'public projecta'");
64 $this->click("//input[@name='Search']");
65 $this->waitForPageToLoad("30000");
66 $this->assertTrue($this->isTextPresent("No matches found for"));
67 $this->assertFalse($this->isTextPresent("public description for projecta"));
68 $this->assertFalse($this->isTextPresent("public description for projectb"));
71 $this->waitForPageToLoad("30000");
72 $this->type("//input[@name='words']", "description public");
73 $this->click("//input[@name='Search']");
74 $this->waitForPageToLoad("30000");
75 $this->assertFalse($this->isTextPresent("No matches found for"));
76 $this->assertTrue($this->isTextPresent("public description for projecta"));
77 $this->assertTrue($this->isTextPresent("public description for projectb"));
80 $this->waitForPageToLoad("30000");
81 $this->type("//input[@name='words']", "'description public'");
82 $this->click("//input[@name='Search']");
83 $this->waitForPageToLoad("30000");
84 $this->assertTrue($this->isTextPresent("No matches found for"));
85 $this->assertFalse($this->isTextPresent("public description for projecta"));
86 $this->assertFalse($this->isTextPresent("public description for projectb"));
89 $this->waitForPageToLoad("30000");
90 $this->type("//input[@name='words']", "'public description'");
91 $this->click("//input[@name='Search']");
92 $this->waitForPageToLoad("30000");
93 $this->assertFalse($this->isTextPresent("No matches found for"));
94 $this->assertTrue($this->isTextPresent("public description for projecta"));
95 $this->assertTrue($this->isTextPresent("public description for projectb"));
101 $this->createUser('ratatouille');
102 $this->createUser('tartiflette');
105 $this->waitForPageToLoad("30000");
106 $this->select("type_of_search", "label=People");
107 $this->type("//input[@name='words']", "tartempion");
108 $this->click("//input[@name='Search']");
109 $this->waitForPageToLoad("30000");
110 $this->assertTrue($this->isTextPresent("No matches found for"));
111 $this->assertFalse($this->isTextPresent("ratatouille Lastname"));
112 $this->assertFalse($this->isTextPresent("tartiflette Lastname"));
115 $this->waitForPageToLoad("30000");
116 $this->select("type_of_search", "label=People");
117 $this->type("//input[@name='words']", "ratatouille");
118 $this->click("//input[@name='Search']");
119 $this->waitForPageToLoad("30000");
120 $this->assertFalse($this->isTextPresent("No matches found for"));
121 $this->assertTrue($this->isTextPresent("ratatouille Lastname"));
122 $this->assertFalse($this->isTextPresent("tartiflette Lastname"));
125 $this->waitForPageToLoad("30000");
126 $this->select("type_of_search", "label=People");
127 $this->type("//input[@name='words']", "lastname ratatouille");
128 $this->click("//input[@name='Search']");
129 $this->waitForPageToLoad("30000");
130 $this->assertFalse($this->isTextPresent("No matches found for"));
131 $this->assertTrue($this->isTextPresent("ratatouille Lastname"));
132 $this->assertFalse($this->isTextPresent("tartiflette Lastname"));
135 $this->waitForPageToLoad("30000");
136 $this->select("type_of_search", "label=People");
137 $this->type("//input[@name='words']", "Lastname");
138 $this->click("//input[@name='Search']");
139 $this->waitForPageToLoad("30000");
140 $this->assertFalse($this->isTextPresent("No matches found for"));
141 $this->assertTrue($this->isTextPresent("ratatouille Lastname"));
142 $this->assertTrue($this->isTextPresent("tartiflette Lastname"));
145 * Search inside a project
148 // Prepare some tracker items
150 $this->gotoProject('projecta');
151 $this->clickAndWait("link=Tracker");
152 $this->clickAndWait("link=Bugs");
153 $this->clickAndWait("link=Submit New");
154 $this->type("summary", "Bug1 boustrophédon");
155 $this->type("details", "brebis outremanchienne");
156 $this->clickAndWait("//form[@id='trackeraddform']//input[@type='submit']");
157 $this->clickAndWait("link=Bug1 boustrophédon");
158 $this->type("details", 'Ceci était une référence au « Génie des Alpages », rien à voir avec Charlie');
159 $this->clickAndWait("submit");
160 $this->clickAndWait("link=Bug1 boustrophédon");
161 $this->type("details", 'This is the needle');
162 $this->clickAndWait("submit");
164 $this->clickAndWait("link=Tracker");
165 $this->clickAndWait("link=Patches");
166 $this->clickAndWait("link=Submit New");
167 $this->type("summary", "Bug2 gratapouêt");
168 $this->type("details", "cthulhu was here");
169 $this->clickAndWait("//form[@id='trackeraddform']//input[@type='submit']");
170 $this->clickAndWait("link=Bug2 gratapouêt");
171 $this->type("details", 'Charlie was here too');
172 $this->clickAndWait("submit");
174 // Search in trackers
176 $this->select("type_of_search", "label=This project's trackers");
177 $this->type("//input[@name='words']", "brebis");
178 $this->clickAndWait("//input[@name='Search']");
179 $this->assertFalse($this->isTextPresent("No matches found for"));
180 $this->assertTrue($this->isTextPresent("Bug1"));
182 $this->select("type_of_search", "label=This project's trackers");
183 $this->type("//input[@name='words']", "alpages");
184 $this->clickAndWait("//input[@name='Search']");
185 $this->assertFalse($this->isTextPresent("No matches found for"));
186 $this->assertTrue($this->isTextPresent("Bug1"));
188 $this->select("type_of_search", "label=This project's trackers");
189 $this->type("//input[@name='words']", "boustrophédon brebis alpages");
190 $this->clickAndWait("//input[@name='Search']");
191 $this->assertFalse($this->isTextPresent("No matches found for"));
192 $this->assertTrue($this->isTextPresent("Bug1"));
194 $this->select("type_of_search", "label=This project's trackers");
195 $this->type("//input[@name='words']", "'boustrophédon brebis'");
196 $this->clickAndWait("//input[@name='Search']");
197 $this->assertTrue($this->isTextPresent("No matches found for"));
198 $this->assertFalse($this->isTextPresent("Bug1"));
200 $this->select("type_of_search", "label=This project's trackers");
201 $this->type("//input[@name='words']", "boustrophédon cthulhu");
202 $this->clickAndWait("//input[@name='Search']");
203 $this->assertTrue($this->isTextPresent("No matches found for"));
204 $this->assertFalse($this->isTextPresent("Bug1"));
205 $this->assertFalse($this->isTextPresent("Bug2"));
207 // Search in one particular tracker
209 $this->select("type_of_search", "label=This project's trackers");
210 $this->type("//input[@name='words']", "charlie");
211 $this->clickAndWait("//input[@name='Search']");
212 $this->assertFalse($this->isTextPresent("No matches found for"));
213 $this->assertTrue($this->isTextPresent("Bug1"));
214 $this->assertTrue($this->isTextPresent("Bug2"));
216 $this->clickAndWait("link=Tracker");
217 $this->clickAndWait("link=Bugs");
218 $this->select("type_of_search", "label=Bugs");
219 $this->type("//input[@name='words']", "charlie");
220 $this->clickAndWait("//input[@name='Search']");
221 $this->assertFalse($this->isTextPresent("No matches found for"));
222 $this->assertTrue($this->isTextPresent("Bug1"));
223 $this->assertFalse($this->isTextPresent("Bug2"));
225 $this->clickAndWait("link=Bugs");
226 $this->select("type_of_search", "label=Bugs");
227 $this->type("//input[@name='words']", "charlie boustrophédon");
228 $this->clickAndWait("//input[@name='Search']");
229 $this->assertFalse($this->isTextPresent("No matches found for"));
230 $this->assertTrue($this->isTextPresent("Bug1"));
231 $this->assertFalse($this->isTextPresent("Bug2"));
235 $this->gotoProject('projecta');
236 $this->clickAndWait("link=Tasks");
237 $this->clickAndWait("link=To Do");
238 $this->clickAndWait("link=Add Task");
239 $this->type("summary", "Task1 the brain");
240 $this->type("details", "The same thing we do every night, Pinky - try to take over the world!");
241 $this->type("hours", "199");
242 $this->clickAndWait("submit");
244 $this->clickAndWait("link=Task1 the brain");
245 $this->type("details", 'This is the needle for tasks');
246 $this->clickAndWait("submit");
248 $this->clickAndWait("link=Add Task");
249 $this->type("summary", "Task2 world peace");
250 $this->type("details", "Otherwise WW4 will be fought with sticks");
251 $this->type("hours", "199");
252 $this->clickAndWait("submit");
256 $this->select("type_of_search", "label=This project's tasks");
257 $this->type("//input[@name='words']", "pinky");
258 $this->clickAndWait("//input[@name='Search']");
259 $this->assertFalse($this->isTextPresent("No matches found for"));
260 $this->assertTrue($this->isTextPresent("Task1"));
262 $this->select("type_of_search", "label=This project's tasks");
263 $this->type("//input[@name='words']", "cortex");
264 $this->clickAndWait("//input[@name='Search']");
265 $this->assertTrue($this->isTextPresent("No matches found for"));
266 $this->assertFalse($this->isTextPresent("Task1"));
268 $this->select("type_of_search", "label=This project's tasks");
269 $this->type("//input[@name='words']", "brain pinky needle");
270 $this->clickAndWait("//input[@name='Search']");
271 $this->assertFalse($this->isTextPresent("No matches found for"));
272 $this->assertTrue($this->isTextPresent("Task1"));
274 // Post some messages in a forum
276 $this->gotoProject('projecta');
277 $this->clickAndWait("link=Forums");
278 $this->clickAndWait("link=open-discussion");
279 $this->click("link=Start New Thread");
280 $this->waitForPageToLoad("30000");
281 $this->type("subject", "Message1 in a bottle");
282 $this->type("body", "ninetynine of them on Charlie's wall");
283 $this->clickAndWait("submit");
284 $this->clickAndWait("link=Message1 in a bottle");
285 $this->clickAndWait("link=[ reply ]");
286 $this->type("subject", "Message2 in a bottle");
287 $this->type("body", "ninetyeight of them in Charlie's fridge");
288 $this->clickAndWait("submit");
289 $this->clickAndWait("link=Message1 in a bottle");
290 $this->clickAndWait("link=[ reply ]");
291 $this->type("subject", "Message3 in a bottle");
292 $this->type("body", "and yet another needle for the forums");
293 $this->clickAndWait("submit");
295 $this->clickAndWait("link=Forums");
296 $this->clickAndWait("link=developers-discussion");
297 $this->click("link=Start New Thread");
298 $this->waitForPageToLoad("30000");
299 $this->type("subject", "Message4 in an envelope");
300 $this->type("body", "not the same thing as an antilope (and different thread anyway) (but still related to Charlie)");
301 $this->clickAndWait("submit");
305 $this->select("type_of_search", "label=This project's forums");
306 $this->type("//input[@name='words']", "bottle");
307 $this->clickAndWait("//input[@name='Search']");
308 $this->assertFalse($this->isTextPresent("No matches found for"));
309 $this->assertTrue($this->isTextPresent("Message1"));
310 $this->assertTrue($this->isTextPresent("Message2"));
311 $this->assertTrue($this->isTextPresent("Message3"));
312 $this->assertFalse($this->isTextPresent("Message4"));
314 $this->select("type_of_search", "label=This project's forums");
315 $this->type("//input[@name='words']", "bottle fridge");
316 $this->clickAndWait("//input[@name='Search']");
317 $this->assertFalse($this->isTextPresent("No matches found for"));
318 $this->assertFalse($this->isTextPresent("Message1"));
319 $this->assertTrue($this->isTextPresent("Message2"));
320 $this->assertFalse($this->isTextPresent("Message3"));
321 $this->assertFalse($this->isTextPresent("Message4"));
323 // Search in one particular forum
325 $this->select("type_of_search", "label=This project's forums");
326 $this->type("//input[@name='words']", "charlie");
327 $this->clickAndWait("//input[@name='Search']");
328 $this->assertFalse($this->isTextPresent("No matches found for"));
329 $this->assertTrue($this->isTextPresent("Message1"));
330 $this->assertTrue($this->isTextPresent("Message2"));
331 $this->assertFalse($this->isTextPresent("Message3"));
332 $this->assertTrue($this->isTextPresent("Message4"));
334 $this->clickAndWait("link=Forums");
335 $this->clickAndWait("link=open-discussion");
336 $this->select("type_of_search", "label=This forum");
337 $this->type("//input[@name='words']", "charlie");
338 $this->clickAndWait("//input[@name='Search']");
339 $this->assertFalse($this->isTextPresent("No matches found for"));
340 $this->assertTrue($this->isTextPresent("Message1"));
341 $this->assertTrue($this->isTextPresent("Message2"));
342 $this->assertFalse($this->isTextPresent("Message3"));
343 $this->assertFalse($this->isTextPresent("Message4"));
345 $this->clickAndWait("link=Forums");
346 $this->clickAndWait("link=open-discussion");
347 $this->select("type_of_search", "label=This forum");
348 $this->type("//input[@name='words']", "charlie fridge");
349 $this->clickAndWait("//input[@name='Search']");
350 $this->assertFalse($this->isTextPresent("No matches found for"));
351 // Only one result => threaded view => need to check on bodies, not subjects
352 $this->assertFalse($this->isTextPresent("wall"));
353 $this->assertTrue($this->isTextPresent("fridge"));
354 $this->assertFalse($this->isTextPresent("needle"));
355 $this->assertFalse($this->isTextPresent("Message4"));
357 // Create some documents
359 $this->gotoProject('projecta');
360 $this->clickAndWait("link=Docs");
361 $this->clickAndWait("addItemDocmanMenu");
362 $this->click("buttonDoc");
363 $this->type("title", "Doc1 Vladimir");
364 $this->type("description", "Jenkins buildbot");
365 $this->click("//input[@name='type' and @value='pasteurl']");
366 $this->type("file_url", "http://buildbot3.fusionforge.org/");
367 $this->clickAndWait("submit");
369 $this->clickAndWait("addItemDocmanMenu");
370 $this->click("buttonDoc");
371 $this->type("title", "Doc2 Astromir");
372 $this->type("description", "Hudson (the needle)");
373 $this->click("//input[@name='type' and @value='pasteurl']");
374 $this->type("file_url", "http://buildbot.fusionforge.org/");
375 $this->clickAndWait("submit");
377 // Search in Documents
379 $this->select("type_of_search", "label=This project's documents");
380 $this->type("//input[@name='words']", "jenkins");
381 $this->clickAndWait("//input[@name='Search']");
382 $this->assertFalse($this->isTextPresent("No matches found for"));
383 $this->assertTrue($this->isTextPresent("Doc1"));
384 $this->assertFalse($this->isTextPresent("Doc2"));
386 $this->select("type_of_search", "label=This project's documents");
387 $this->type("//input[@name='words']", "vladimir jenkins");
388 $this->clickAndWait("//input[@name='Search']");
389 $this->assertFalse($this->isTextPresent("No matches found for"));
390 $this->assertTrue($this->isTextPresent("Doc1"));
391 $this->assertFalse($this->isTextPresent("Doc2"));
395 $this->gotoProject('projecta');
396 $this->clickAndWait("link=News");
397 $this->clickAndWait("link=Submit");
398 $this->type("summary", "News1 daily planet");
399 $this->type("details", "Clark Kent's newspaper");
400 $this->clickAndWait("submit");
402 $this->clickAndWait("link=Submit");
403 $this->type("summary", "News2 usenet");
404 $this->type("details", "alt sysadmin recovery (needle)");
405 $this->clickAndWait("submit");
406 $this->clickAndWait("link=News");
410 $this->select("type_of_search", "label=This project's news");
411 $this->type("//input[@name='words']", "sysadmin");
412 $this->clickAndWait("//input[@name='Search']");
413 $this->assertFalse($this->isTextPresent("No matches found for"));
414 $this->assertTrue($this->isTextPresent("News2"));
416 $this->select("type_of_search", "label=This project's news");
417 $this->type("//input[@name='words']", "daily newspaper");
418 $this->clickAndWait("//input[@name='Search']");
419 $this->assertFalse($this->isTextPresent("No matches found for"));
420 $this->assertTrue($this->isTextPresent("News1"));
422 // Search in entire project
424 $this->gotoProject('projecta');
425 $this->select("type_of_search", "label=Search the entire project");
426 $this->type("//input[@name='words']", "needle");
427 $this->clickAndWait("//input[@name='Search']");
428 $this->assertTrue($this->isTextPresent("Bug1"));
429 $this->assertFalse($this->isTextPresent("Bug2"));
430 $this->assertTrue($this->isTextPresent("Task1"));
431 $this->assertFalse($this->isTextPresent("Task2"));
432 $this->assertFalse($this->isTextPresent("Message1"));
433 $this->assertFalse($this->isTextPresent("Message2"));
434 $this->assertTrue($this->isTextPresent("Message3"));
435 $this->assertFalse($this->isTextPresent("Message4"));
436 $this->assertFalse($this->isTextPresent("Doc1"));
437 $this->assertTrue($this->isTextPresent("Doc2"));
438 $this->assertFalse($this->isTextPresent("News1"));
439 $this->assertTrue($this->isTextPresent("News2"));
443 $this->gotoProject('projecta');
444 $this->clickAndWait('Link=Advanced search');
445 $this->click("//input[@class='checkthemall']");
446 $this->type("//div[@id='maindiv']//input[@name='words']", "needle");
447 $this->clickAndWait("//input[@name='submitbutton']");
448 $this->assertTrue($this->isTextPresent("Bug1"));
449 $this->assertFalse($this->isTextPresent("Bug2"));
450 $this->assertTrue($this->isTextPresent("Task1"));
451 $this->assertFalse($this->isTextPresent("Task2"));
452 $this->assertFalse($this->isTextPresent("Message1"));
453 $this->assertFalse($this->isTextPresent("Message2"));
454 $this->assertTrue($this->isTextPresent("Message3"));
455 $this->assertFalse($this->isTextPresent("Message4"));
456 $this->assertFalse($this->isTextPresent("Doc1"));
457 $this->assertTrue($this->isTextPresent("Doc2"));
458 $this->assertFalse($this->isTextPresent("News1"));
459 $this->assertTrue($this->isTextPresent("News2"));