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
26 function testProjectSearch()
29 $this->createProject('projectb');
32 $this->waitForPageToLoad("30000");
33 $this->type("//input[@name='words']", "XXXXXXXXXXXXXXXXXXXXXXXXXX");
34 $this->click("//input[@name='Search']");
35 $this->waitForPageToLoad("30000");
36 $this->assertTrue($this->isTextPresent("No matches found for"));
39 $this->waitForPageToLoad("30000");
40 $this->type("//input[@name='words']", "projecta");
41 $this->click("//input[@name='Search']");
42 $this->waitForPageToLoad("30000");
43 $this->assertFalse($this->isTextPresent("No matches found for"));
44 $this->assertTrue($this->isTextPresent("public description for ProjectA"));
45 $this->assertFalse($this->isTextPresent("public description for projectb"));
48 $this->waitForPageToLoad("30000");
49 $this->type("//input[@name='words']", "description public projecta");
50 $this->click("//input[@name='Search']");
51 $this->waitForPageToLoad("30000");
52 $this->assertFalse($this->isTextPresent("No matches found for"));
53 $this->assertTrue($this->isTextPresent("public description for ProjectA"));
54 $this->assertFalse($this->isTextPresent("public description for projectb"));
57 $this->waitForPageToLoad("30000");
58 $this->type("//input[@name='words']", "description 'public projecta'");
59 $this->click("//input[@name='Search']");
60 $this->waitForPageToLoad("30000");
61 $this->assertTrue($this->isTextPresent("No matches found for"));
62 $this->assertFalse($this->isTextPresent("public description for ProjectA"));
63 $this->assertFalse($this->isTextPresent("public description for projectb"));
66 $this->waitForPageToLoad("30000");
67 $this->type("//input[@name='words']", "description public");
68 $this->click("//input[@name='Search']");
69 $this->waitForPageToLoad("30000");
70 $this->assertFalse($this->isTextPresent("No matches found for"));
71 $this->assertTrue($this->isTextPresent("public description for ProjectA"));
72 $this->assertTrue($this->isTextPresent("public description for projectb"));
75 $this->waitForPageToLoad("30000");
76 $this->type("//input[@name='words']", "'description public'");
77 $this->click("//input[@name='Search']");
78 $this->waitForPageToLoad("30000");
79 $this->assertTrue($this->isTextPresent("No matches found for"));
80 $this->assertFalse($this->isTextPresent("public description for ProjectA"));
81 $this->assertFalse($this->isTextPresent("public description for projectb"));
84 $this->waitForPageToLoad("30000");
85 $this->type("//input[@name='words']", "'public description'");
86 $this->click("//input[@name='Search']");
87 $this->waitForPageToLoad("30000");
88 $this->assertFalse($this->isTextPresent("No matches found for"));
89 $this->assertTrue($this->isTextPresent("public description for ProjectA"));
90 $this->assertTrue($this->isTextPresent("public description for projectb"));
93 function testPeopleSearch()
95 $this->switchUser(FORGE_ADMIN_USERNAME);
96 $this->createUser('ratatouille');
97 $this->createUser('tartiflette');
100 $this->waitForPageToLoad("30000");
101 $this->select("type_of_search", "label=People");
102 $this->type("//input[@name='words']", "tartempion");
103 $this->click("//input[@name='Search']");
104 $this->waitForPageToLoad("30000");
105 $this->assertTrue($this->isTextPresent("No matches found for"));
106 $this->assertFalse($this->isTextPresent("ratatouille Lastname"));
107 $this->assertFalse($this->isTextPresent("tartiflette Lastname"));
110 $this->waitForPageToLoad("30000");
111 $this->select("type_of_search", "label=People");
112 $this->type("//input[@name='words']", "ratatouille");
113 $this->click("//input[@name='Search']");
114 $this->waitForPageToLoad("30000");
115 $this->assertFalse($this->isTextPresent("No matches found for"));
116 $this->assertTrue($this->isTextPresent("ratatouille Lastname"));
117 $this->assertFalse($this->isTextPresent("tartiflette Lastname"));
120 $this->waitForPageToLoad("30000");
121 $this->select("type_of_search", "label=People");
122 $this->type("//input[@name='words']", "lastname ratatouille");
123 $this->click("//input[@name='Search']");
124 $this->waitForPageToLoad("30000");
125 $this->assertFalse($this->isTextPresent("No matches found for"));
126 $this->assertTrue($this->isTextPresent("ratatouille Lastname"));
127 $this->assertFalse($this->isTextPresent("tartiflette Lastname"));
130 $this->waitForPageToLoad("30000");
131 $this->select("type_of_search", "label=People");
132 $this->type("//input[@name='words']", "Lastname");
133 $this->click("//input[@name='Search']");
134 $this->waitForPageToLoad("30000");
135 $this->assertFalse($this->isTextPresent("No matches found for"));
136 $this->assertTrue($this->isTextPresent("ratatouille Lastname"));
137 $this->assertTrue($this->isTextPresent("tartiflette Lastname"));
141 function testSearchInTools()
143 $this->populateStandardTemplate();
144 $this->createProject('projecta');
146 // TODO: check that search results vary according to what items are visible to the user
147 // $this->createProject('projectb');
148 // $this->createUser('piperade');
149 // $this->createUser('cassoulet');
151 // Prepare some tracker items
153 $this->gotoProject('projecta');
154 $this->clickAndWait("link=Tracker");
155 $this->clickAndWait("link=Bugs");
156 $this->clickAndWait("link=Submit New");
157 $this->type("summary", "Bug1 boustrophédon");
158 $this->type("details", "brebis outremanchienne");
159 $this->clickAndWait("//form[@id='trackeraddform']//input[@type='submit']");
160 $this->clickAndWait("link=Bug1 boustrophédon");
161 $this->type("details", 'Ceci était une référence au « Génie des Alpages », rien à voir avec Charlie');
162 $this->clickAndWait("submit");
163 $this->clickAndWait("link=Bug1 boustrophédon");
164 $this->type("details", 'This is the needle');
165 $this->clickAndWait("submit");
167 $this->clickAndWait("link=Tracker");
168 $this->clickAndWait("link=Patches");
169 $this->clickAndWait("link=Submit New");
170 $this->type("summary", "Bug2 gratapouêt");
171 $this->type("details", "cthulhu was here");
172 $this->clickAndWait("//form[@id='trackeraddform']//input[@type='submit']");
173 $this->clickAndWait("link=Bug2 gratapouêt");
174 $this->type("details", 'Charlie was here too');
175 $this->clickAndWait("submit");
177 // Search in trackers
179 $this->select("type_of_search", "label=This project's trackers");
180 $this->type("//input[@name='words']", "brebis");
181 $this->clickAndWait("//input[@name='Search']");
182 $this->assertFalse($this->isTextPresent("No matches found for"));
183 $this->assertTrue($this->isTextPresent("Bug1"));
185 $this->select("type_of_search", "label=This project's trackers");
186 $this->type("//input[@name='words']", "alpages");
187 $this->clickAndWait("//input[@name='Search']");
188 $this->assertFalse($this->isTextPresent("No matches found for"));
189 $this->assertTrue($this->isTextPresent("Bug1"));
191 $this->select("type_of_search", "label=This project's trackers");
192 $this->type("//input[@name='words']", "boustrophédon brebis alpages");
193 $this->clickAndWait("//input[@name='Search']");
194 $this->assertFalse($this->isTextPresent("No matches found for"));
195 $this->assertTrue($this->isTextPresent("Bug1"));
197 $this->select("type_of_search", "label=This project's trackers");
198 $this->type("//input[@name='words']", "'boustrophédon brebis'");
199 $this->clickAndWait("//input[@name='Search']");
200 $this->assertTrue($this->isTextPresent("No matches found for"));
201 $this->assertFalse($this->isTextPresent("Bug1"));
203 $this->select("type_of_search", "label=This project's trackers");
204 $this->type("//input[@name='words']", "boustrophédon cthulhu");
205 $this->clickAndWait("//input[@name='Search']");
206 $this->assertTrue($this->isTextPresent("No matches found for"));
207 $this->assertFalse($this->isTextPresent("Bug1"));
208 $this->assertFalse($this->isTextPresent("Bug2"));
210 // Search in one particular tracker
212 $this->select("type_of_search", "label=This project's trackers");
213 $this->type("//input[@name='words']", "charlie");
214 $this->clickAndWait("//input[@name='Search']");
215 $this->assertFalse($this->isTextPresent("No matches found for"));
216 $this->assertTrue($this->isTextPresent("Bug1"));
217 $this->assertTrue($this->isTextPresent("Bug2"));
219 $this->clickAndWait("link=Tracker");
220 $this->clickAndWait("link=Bugs");
221 $this->select("type_of_search", "label=Bugs");
222 $this->type("//input[@name='words']", "charlie");
223 $this->clickAndWait("//input[@name='Search']");
224 $this->assertFalse($this->isTextPresent("No matches found for"));
225 $this->assertTrue($this->isTextPresent("Bug1"));
226 $this->assertFalse($this->isTextPresent("Bug2"));
228 $this->clickAndWait("link=Bugs");
229 $this->select("type_of_search", "label=Bugs");
230 $this->type("//input[@name='words']", "charlie boustrophédon");
231 $this->clickAndWait("//input[@name='Search']");
232 $this->assertFalse($this->isTextPresent("No matches found for"));
233 $this->assertTrue($this->isTextPresent("Bug1"));
234 $this->assertFalse($this->isTextPresent("Bug2"));
238 $this->gotoProject('projecta');
239 $this->clickAndWait("link=Tasks");
240 $this->clickAndWait("link=To Do");
241 $this->clickAndWait("link=Add Task");
242 $this->type("summary", "Task1 the brain");
243 $this->type("details", "The same thing we do every night, Pinky - try to take over the world!");
244 $this->type("hours", "199");
245 $this->clickAndWait("submit");
247 $this->clickAndWait("link=Task1 the brain");
248 $this->type("details", 'This is the needle for tasks');
249 $this->clickAndWait("submit");
251 $this->clickAndWait("link=Add Task");
252 $this->type("summary", "Task2 world peace");
253 $this->type("details", "Otherwise WW4 will be fought with sticks");
254 $this->type("hours", "199");
255 $this->clickAndWait("submit");
259 $this->select("type_of_search", "label=This project's tasks");
260 $this->type("//input[@name='words']", "pinky");
261 $this->clickAndWait("//input[@name='Search']");
262 $this->assertFalse($this->isTextPresent("No matches found for"));
263 $this->assertTrue($this->isTextPresent("Task1"));
265 $this->select("type_of_search", "label=This project's tasks");
266 $this->type("//input[@name='words']", "cortex");
267 $this->clickAndWait("//input[@name='Search']");
268 $this->assertTrue($this->isTextPresent("No matches found for"));
269 $this->assertFalse($this->isTextPresent("Task1"));
271 $this->select("type_of_search", "label=This project's tasks");
272 $this->type("//input[@name='words']", "brain pinky needle");
273 $this->clickAndWait("//input[@name='Search']");
274 $this->assertFalse($this->isTextPresent("No matches found for"));
275 $this->assertTrue($this->isTextPresent("Task1"));
277 // Post some messages in a forum
279 $this->gotoProject('projecta');
280 $this->clickAndWait("link=Forums");
281 $this->clickAndWait("link=open-discussion");
282 $this->click("link=Start New Thread");
283 $this->waitForPageToLoad("30000");
284 $this->type("subject", "Message1 in a bottle");
285 $this->type("body", "ninetynine of them on Charlie's wall");
286 $this->clickAndWait("submit");
287 $this->clickAndWait("link=Message1 in a bottle");
288 $this->clickAndWait("link=[ reply ]");
289 $this->type("subject", "Message2 in a bottle");
290 $this->type("body", "ninetyeight of them in Charlie's fridge");
291 $this->clickAndWait("submit");
292 $this->clickAndWait("link=Message1 in a bottle");
293 $this->clickAndWait("link=[ reply ]");
294 $this->type("subject", "Message3 in a bottle");
295 $this->type("body", "and yet another needle for the forums");
296 $this->clickAndWait("submit");
298 $this->clickAndWait("link=Forums");
299 $this->clickAndWait("link=developers-discussion");
300 $this->click("link=Start New Thread");
301 $this->waitForPageToLoad("30000");
302 $this->type("subject", "Message4 in an envelope");
303 $this->type("body", "not the same thing as an antilope (and different thread anyway) (but still related to Charlie)");
304 $this->clickAndWait("submit");
308 $this->select("type_of_search", "label=This project's forums");
309 $this->type("//input[@name='words']", "bottle");
310 $this->clickAndWait("//input[@name='Search']");
311 $this->assertFalse($this->isTextPresent("No matches found for"));
312 $this->assertTrue($this->isTextPresent("Message1"));
313 $this->assertTrue($this->isTextPresent("Message2"));
314 $this->assertTrue($this->isTextPresent("Message3"));
315 $this->assertFalse($this->isTextPresent("Message4"));
317 $this->select("type_of_search", "label=This project's forums");
318 $this->type("//input[@name='words']", "bottle fridge");
319 $this->clickAndWait("//input[@name='Search']");
320 $this->assertFalse($this->isTextPresent("No matches found for"));
321 $this->assertFalse($this->isTextPresent("Message1"));
322 $this->assertTrue($this->isTextPresent("Message2"));
323 $this->assertFalse($this->isTextPresent("Message3"));
324 $this->assertFalse($this->isTextPresent("Message4"));
326 // Search in one particular forum
328 $this->select("type_of_search", "label=This project's forums");
329 $this->type("//input[@name='words']", "charlie");
330 $this->clickAndWait("//input[@name='Search']");
331 $this->assertFalse($this->isTextPresent("No matches found for"));
332 $this->assertTrue($this->isTextPresent("Message1"));
333 $this->assertTrue($this->isTextPresent("Message2"));
334 $this->assertFalse($this->isTextPresent("Message3"));
335 $this->assertTrue($this->isTextPresent("Message4"));
337 $this->clickAndWait("link=Forums");
338 $this->clickAndWait("link=open-discussion");
339 $this->select("type_of_search", "label=This forum");
340 $this->type("//input[@name='words']", "charlie");
341 $this->clickAndWait("//input[@name='Search']");
342 $this->assertFalse($this->isTextPresent("No matches found for"));
343 $this->assertTrue($this->isTextPresent("Message1"));
344 $this->assertTrue($this->isTextPresent("Message2"));
345 $this->assertFalse($this->isTextPresent("Message3"));
346 $this->assertFalse($this->isTextPresent("Message4"));
348 $this->clickAndWait("link=Forums");
349 $this->clickAndWait("link=open-discussion");
350 $this->select("type_of_search", "label=This forum");
351 $this->type("//input[@name='words']", "charlie fridge");
352 $this->clickAndWait("//input[@name='Search']");
353 $this->assertFalse($this->isTextPresent("No matches found for"));
354 // Only one result => threaded view => need to check on bodies, not subjects
355 $this->assertFalse($this->isTextPresent("wall"));
356 $this->assertTrue($this->isTextPresent("fridge"));
357 $this->assertFalse($this->isTextPresent("needle"));
358 $this->assertFalse($this->isTextPresent("Message4"));
360 // Create some documents
362 $this->gotoProject('projecta');
363 $this->clickAndWait("link=Docs");
364 $this->clickAndWait("addItemDocmanMenu");
365 $this->click("buttonDoc");
366 $this->type("title", "Doc1 Vladimir");
367 $this->type("description", "Jenkins buildbot");
368 $this->click("//input[@name='type' and @value='pasteurl']");
369 $this->type("file_url", "http://buildbot3.fusionforge.org/");
370 $this->clickAndWait("submit");
372 $this->clickAndWait("addItemDocmanMenu");
373 $this->click("buttonDoc");
374 $this->type("title", "Doc2 Astromir");
375 $this->type("description", "Hudson (the needle)");
376 $this->click("//input[@name='type' and @value='pasteurl']");
377 $this->type("file_url", "http://buildbot.fusionforge.org/");
378 $this->clickAndWait("submit");
380 // Search in Documents
382 $this->select("type_of_search", "label=This project's documents");
383 $this->type("//input[@name='words']", "jenkins");
384 $this->clickAndWait("//input[@name='Search']");
385 $this->assertFalse($this->isTextPresent("No matches found for"));
386 $this->assertTrue($this->isTextPresent("Doc1"));
387 $this->assertFalse($this->isTextPresent("Doc2"));
389 $this->select("type_of_search", "label=This project's documents");
390 $this->type("//input[@name='words']", "vladimir jenkins");
391 $this->clickAndWait("//input[@name='Search']");
392 $this->assertFalse($this->isTextPresent("No matches found for"));
393 $this->assertTrue($this->isTextPresent("Doc1"));
394 $this->assertFalse($this->isTextPresent("Doc2"));
398 $this->gotoProject('projecta');
399 $this->clickAndWait("link=News");
400 $this->clickAndWait("link=Submit");
401 $this->type("summary", "News1 daily planet");
402 $this->type("details", "Clark Kent's newspaper");
403 $this->clickAndWait("submit");
405 $this->clickAndWait("link=Submit");
406 $this->type("summary", "News2 usenet");
407 $this->type("details", "alt sysadmin recovery (needle)");
408 $this->clickAndWait("submit");
409 $this->clickAndWait("link=News");
413 $this->select("type_of_search", "label=This project's news");
414 $this->type("//input[@name='words']", "sysadmin");
415 $this->clickAndWait("//input[@name='Search']");
416 $this->assertFalse($this->isTextPresent("No matches found for"));
417 $this->assertTrue($this->isTextPresent("News2"));
419 $this->select("type_of_search", "label=This project's news");
420 $this->type("//input[@name='words']", "daily newspaper");
421 $this->clickAndWait("//input[@name='Search']");
422 $this->assertFalse($this->isTextPresent("No matches found for"));
423 $this->assertTrue($this->isTextPresent("News1"));
425 // Search in entire project
427 $this->gotoProject('projecta');
428 $this->select("type_of_search", "label=Search the entire project");
429 $this->type("//input[@name='words']", "needle");
430 $this->clickAndWait("//input[@name='Search']");
431 $this->assertTrue($this->isTextPresent("Bug1"));
432 $this->assertFalse($this->isTextPresent("Bug2"));
433 $this->assertTrue($this->isTextPresent("Task1"));
434 $this->assertFalse($this->isTextPresent("Task2"));
435 $this->assertFalse($this->isTextPresent("Message1"));
436 $this->assertFalse($this->isTextPresent("Message2"));
437 $this->assertTrue($this->isTextPresent("Message3"));
438 $this->assertFalse($this->isTextPresent("Message4"));
439 $this->assertFalse($this->isTextPresent("Doc1"));
440 $this->assertTrue($this->isTextPresent("Doc2"));
441 $this->assertFalse($this->isTextPresent("News1"));
442 $this->assertTrue($this->isTextPresent("News2"));
445 $this->gotoProject('projecta');
446 $this->clickAndWait('Link=Advanced search');
447 $this->click("//a[contains(@href,'short_forum') and .='all']");
448 $this->click("//a[contains(@href,'short_tracker') and .='all']");
449 $this->click("//a[contains(@href,'short_pm') and .='all']");
450 $this->click("//a[contains(@href,'short_docman') and .='all']");
451 $this->click("//a[contains(@href,'short_news') and .='all']");
452 $this->type("//div[@id='maindiv']//input[@name='words']", "needle");
453 $this->clickAndWait("//input[@name='submitbutton']");
454 $this->assertTrue($this->isTextPresent("Bug1"));
455 $this->assertFalse($this->isTextPresent("Bug2"));
456 $this->assertTrue($this->isTextPresent("Task1"));
457 $this->assertFalse($this->isTextPresent("Task2"));
458 $this->assertFalse($this->isTextPresent("Message1"));
459 $this->assertFalse($this->isTextPresent("Message2"));
460 $this->assertTrue($this->isTextPresent("Message3"));
461 $this->assertFalse($this->isTextPresent("Message4"));
462 $this->assertFalse($this->isTextPresent("Doc1"));
463 $this->assertTrue($this->isTextPresent("Doc2"));
464 $this->assertFalse($this->isTextPresent("News1"));
465 $this->assertTrue($this->isTextPresent("News2"));