Merge remote-tracking branch 'origin/4.4' into 4.4-4.5-2014-09-14-13-58-42
[civicrm-core.git] / tests / phpunit / WebTest / Campaign / SurveyUsageScenarioTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Campaign_SurveyUsageScenarioTest
31 */
32 class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 function testSurveyUsageScenario() {
39 $this->webtestLogin('admin');
40
41 // Create new group
42 $title = substr(sha1(rand()), 0, 7);
43 $groupName = $this->WebtestAddGroup();
44
45 // Adding contact
46 $firstName1 = substr(sha1(rand()), 0, 7);
47 $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
48
49 // add contact to group
50 // visit group tab
51 $this->click("css=li#tab_group a");
52 $this->waitForElementPresent("css=#group_id option");
53
54 // add to group
55 $this->select("group_id", "label=$groupName");
56 $this->click("_qf_GroupContact_next");
57 $this->waitForElementPresent('link=Remove');
58
59 $firstName2 = substr(sha1(rand()), 0, 7);
60 $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
61
62 // add contact to group
63 // visit group tab
64 $this->click("css=li#tab_group a");
65 $this->waitForElementPresent("css=#group_id option");
66
67 // add to group
68 $this->select("group_id", "label=$groupName");
69 $this->click("_qf_GroupContact_next");
70 $this->waitForElementPresent('link=Remove');
71
72 // Enable CiviCampaign module if necessary
73 $this->enableComponents(array('CiviCampaign'));
74
75 // add the required permission
76 $this->changePermissions(array('edit-2-administer-civicampaign'));
77
78 // Log in as normal user
79 $this->webtestLogin();
80
81 $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
82 $this->waitForElementPresent('title');
83 $this->type("title", "Campaign $title");
84
85 // select the campaign type
86 $this->waitForElementPresent('campaign_type_id');
87 $this->select("campaign_type_id", "value=2");
88
89 // fill in the description
90 $this->type("description", "This is a test campaign");
91
92 // include groups for the campaign
93 $this->addSelection("includeGroups", "label=$groupName");
94 $this->click("//option[@value=4]");
95
96 // fill the end date for campaign
97 $this->webtestFillDate("end_date", "+1 year");
98
99 // select campaign status
100 $this->select("status_id", "value=2");
101
102 // click save
103 $this->click("_qf_Campaign_upload-bottom");
104 $this->waitForPageToLoad($this->getTimeoutMsec());
105
106 $this->waitForText('crm-notification-container', "$title");
107
108 // create a custom data set for activities -> survey
109 $this->openCiviPage('admin/custom/group', "action=add&reset=1", "_qf_Group_next-bottom");
110 // fill in a unique title for the custom group
111 $this->type("title", "Group $title");
112
113 // select the group this custom data set extends
114 $this->select("extends[0]", "value=Activity");
115 $this->waitForElementPresent("//select[@id='extends_1']");
116 $this->select("//select[@id='extends_1']", "label=Survey");
117
118 // save the custom group
119 $this->click("_qf_Group_next-bottom");
120 $this->waitForPageToLoad($this->getTimeoutMsec());
121
122 // add a custom field to the custom group
123 $this->waitForElementPresent('newCustomField');
124 $this->click('newCustomField');
125 $this->waitForElementPresent('label');
126 $this->type("label", "Field $title");
127
128 $this->select("data_type[1]", "value=Radio");
129
130 $this->waitForElementPresent("option_label_1");
131
132 // create a set of options
133 $this->type("option_label_1", "Option $title 1");
134 $this->type("option_value_1", "1");
135
136 $this->type("option_label_2", "Option $title 2");
137 $this->type("option_value_2", "2");
138
139 // save the custom field
140 $this->click("_qf_Field_done-bottom");
141
142 $this->waitForElementPresent("newCustomField");
143 $this->waitForText('crm-notification-container', "$title");
144
145 // create a profile for campaign
146 $this->openCiviPage("admin/uf/group/add", "action=add&reset=1", "_qf_Group_next-bottom");
147
148 // fill in a unique title for the profile
149 $this->type("title", "Profile $title");
150
151 // save the profile
152 $this->click("_qf_Group_next-bottom");
153
154 $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
155 $this->click("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
156
157 // add a profile field for activity
158 $this->waitForElementPresent('field_name[0]');
159 $this->select("field_name[0]", "value=Activity");
160 $this->waitForElementPresent("field_name[1]");
161 $this->select("field_name[1]", "label=Field $title :: Group $title");
162
163 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
164 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
165 $this->waitForText('crm-notification-container', "$title");
166
167 // create a survey
168 $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom");
169
170 // fill in a unique title for the survey
171 $this->type("title", "Survey $title");
172
173 // select the created campaign
174 $this->select("campaign_id", "label=Campaign $title");
175
176 // select the activity type
177 $this->select("activity_type_id", "label=Survey");
178
179 // fill in reserve survey respondents
180 $this->type("default_number_of_contacts", 50);
181
182 // fill in interview survey respondents
183 $this->type("max_number_of_contacts", 100);
184
185 // release frequency
186 $this->type("release_frequency", 2);
187
188 $this->click("_qf_Main_upload-bottom");
189 $this->waitForElementPresent("_qf_Questions_upload_next-bottom");
190
191 // Select the profile for the survey
192 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
193
194 // select the question created for the survey
195
196 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=Profile $title");
197 $this->click("_qf_Questions_upload_next-bottom");
198
199 // create a set of options for Survey Responses _qf_Results_upload_done-bottom
200 $this->waitForElementPresent('_qf_Results_upload_done-bottom');
201 $this->type("//input[@id='option_label_1']", "Label $title 1");
202 $this->type("//input[@id='option_value_1']", "1");
203
204 $this->type("//input[@id='option_label_2']", "Label $title 2");
205 $this->type("//input[@id='option_value_2']", "2");
206 $this->click('_qf_Results_upload_done-bottom');
207 $this->waitForElementPresent("//div[@id='search_form_survey']");
208 $this->waitForText('crm-notification-container', "Results");
209
210 // Reserve Respondents
211 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
212
213 // search for the respondents
214 $this->select("campaign_survey_id", "label=Survey $title");
215
216 $this->click("_qf_Search_refresh");
217 $this->waitForElementPresent('toggleSelect');
218 $this->click('toggleSelect');
219 $this->select('task', "Reserve Respondents");
220
221 $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
222 $this->click("_qf_Reserve_done_reserve-bottom");
223 $this->waitForPageToLoad($this->getTimeoutMsec());
224 $this->waitForText('crm-notification-container', "2 Contact\(s\) have been reserved");
225
226 // Interview Respondents
227 $this->openCiviPage("survey/search", "reset=1&op=interview", "_qf_Search_refresh");
228 // search for the respondents
229 $this->waitForElementPresent('campaign_survey_id');
230 $this->select("campaign_survey_id", "label=Survey $title");
231 $this->click("_qf_Search_refresh");
232
233 $this->waitForElementPresent('toggleSelect');
234 $this->click('toggleSelect');
235 $this->select('task', "Record Survey Responses");
236 $this->waitForElementPresent("_qf_Interview_cancel_interview");
237
238 $this->click("CIVICRM_QFID_1_2");
239 $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[8]/select","value=Label $title 1");
240 $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[9]/a");
241
242 $this->click("CIVICRM_QFID_2_8");
243
244 $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[8]/select","value=Label $title 2");
245 $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[9]/a");
246 $this->click("_qf_Interview_cancel_interview");
247 $this->waitForPageToLoad($this->getTimeoutMsec());
248
249 // add a contact to the group to test release respondents
250 $firstName3 = substr(sha1(rand()), 0, 7);
251 $this->webtestAddContact($firstName3, "James", "$firstName3.james@example.org");
252 $id = $this->urlArg('cid');
253 $sortName3 = "James, $firstName3";
254
255 // add contact to group
256 // visit group tab
257 $this->click("css=li#tab_group a");
258 $this->waitForElementPresent("css=#group_id option");
259
260 // add to group
261 $this->select("group_id", "label=$groupName");
262 $this->click("_qf_GroupContact_next");
263 $this->waitForElementPresent('link=Remove');
264
265 // Reserve Respondents
266 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
267
268 // search for the respondents
269 $this->select("campaign_survey_id", "label=Survey $title");
270
271 $this->click("_qf_Search_refresh");
272 $this->waitForElementPresent('toggleSelect');
273 $this->click('toggleSelect');
274 $this->waitForElementPresent('task');
275 $this->select('task', "Reserve Respondents");
276 $this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
277 $this->click("_qf_Reserve_done_reserve-bottom");
278 $this->waitForText('crm-notification-container', "1 Contact\(s\) have been reserved");
279
280 // Release Respondents
281 $this->openCiviPage("survey/search", "reset=1&op=release", "_qf_Search_refresh");
282
283 // search for the respondents
284 $this->select("campaign_survey_id", "label=Survey $title");
285
286 $this->click("_qf_Search_refresh");
287 $this->waitForElementPresent('toggleSelect');
288 $this->click('toggleSelect');
289 $this->waitForElementPresent('task');
290 $this->select("task", "label=Release Respondents");
291 $this->waitForElementPresent('_qf_Release_done-bottom');
292 $this->click("_qf_Release_done-bottom");
293 $this->waitForText('crm-notification-container', "released");
294
295 // check whether contact is available for reserving again
296 $this->openCiviPage("survey/search", "reset=1&op=reserve", "_qf_Search_refresh");
297
298 // search for the respondents
299 $this->select("campaign_survey_id", "label=Survey $title");
300
301 $this->waitForElementPresent('_qf_Search_refresh');
302 $this->click("_qf_Search_refresh");
303 $this->waitForPageToLoad($this->getTimeoutMsec());
304 $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]",'1 Result');
305 }
306
307 function testSurveyReportTest() {
308 $this->webtestLogin('admin');
309
310 // Enable CiviCampaign module if necessary
311 $this->enableComponents(array('CiviCampaign'));
312
313 // add the required permission
314 $this->changePermissions('edit-2-administer-civicampaign');
315
316 $this->webtestLogin();
317
318 // Create new group
319 $title = substr(sha1(rand()), 0, 7);
320 $groupName = $this->WebtestAddGroup();
321
322 // Adding contact
323 $firstName1 = substr(sha1(rand()), 0, 7);
324 $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
325 $id1 = $this->urlArg('cid');
326
327 // add contact to group
328 // visit group tab
329 $this->click("css=li#tab_group a");
330 $this->waitForElementPresent('css=#group_id option');
331
332 // add to group
333 $this->select("group_id", "label=$groupName");
334 $this->click("_qf_GroupContact_next");
335 $this->waitForElementPresent('link=Remove');
336
337 $firstName2 = substr(sha1(rand()), 0, 7);
338 $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
339 $id2 = $this->urlArg('cid');
340
341 // add contact to group
342 // visit group tab
343 $this->click("css=li#tab_group a");
344 $this->waitForElementPresent('css=#group_id option');
345
346 // add to group
347 $this->select("group_id", "label=$groupName");
348 $this->click("_qf_GroupContact_next");
349 $this->waitForElementPresent('link=Remove');
350
351 // Create custom group and add custom data fields
352 $this->openCiviPage("admin/custom/group", "reset=1");
353
354 $this->click("link=Add Set of Custom Fields");
355 $this->waitForElementPresent('_qf_Group_cancel-bottom');
356
357 $customGroup = "Custom Group $title";
358 $this->type('title', "$customGroup");
359 $this->select('extends[0]', "value=Contact");
360 $this->click('_qf_Group_next-bottom');
361 $this->waitForElementPresent('newCustomField');
362 $this->waitForText('crm-notification-container', $customGroup);
363
364 // Add custom fields
365 $this->click('newCustomField');
366 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
367 $field1 = "Checkbox $title";
368 $this->type('label', $field1);
369 $this->select('data_type[1]', "value=CheckBox");
370 $this->waitForElementPresent('option_label_2');
371
372 // add multiple choice options
373 $label1 = "Check $title One";
374 $value1 = 1;
375 $this->type('option_label_1', $label1);
376 $this->type('option_value_1', $value1);
377
378 $label2 = "Check $title Two";
379 $value2 = 2;
380 $this->type('option_label_2', $label2);
381 $this->type('option_value_2', $value2);
382
383 $this->click("link=another choice");
384
385 $label3 = "Check $title Three";
386 $value3 = 3;
387 $this->type('option_label_3', $label3);
388 $this->type('option_value_3', $value3);
389
390 $this->click("xpath=//*[@id='_qf_Field_done-bottom']");
391 $this->waitForElementPresent('newCustomField');
392 $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span[text()='{$field1}']");
393
394 // Create a profile for survey
395 $this->openCiviPage("admin/uf/group", "reset=1");
396
397 $this->click("link=Add Profile");
398 $this->waitForElementPresent('_qf_Group_cancel-bottom');
399
400 $surveyProfile = "Survey Profile $title";
401 $this->type('title', $surveyProfile);
402 $this->click('_qf_Group_next-bottom');
403 $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
404 $this->waitForText('crm-notification-container', $surveyProfile);
405
406 // Add fields to the profile
407 // Phone ( Primary )
408 $this->click("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
409 $this->waitForElementPresent('field_name[0]');
410 $this->select('field_name[0]', "value=Contact");
411 $this->waitForElementPresent('field_name[1]');
412 $this->select('field_name[1]', "value=phone");
413 $this->click('field_name[1]');
414 $this->select('visibility', "value=Public Pages and Listings");
415 $this->check('is_searchable');
416 $this->check('in_selector');
417 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
418 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
419
420 // Custom Data Fields
421 $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
422 $this->select('field_name[0]', "value=Contact");
423 $this->waitForElementPresent('field_name[1]');
424 $this->select('field_name[1]', "label=$field1 :: $customGroup");
425 $this->click('field_name[1]');
426 $this->select('visibility', "value=Public Pages and Listings");
427 $this->check('is_searchable');
428 $this->check('in_selector');
429 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
430 $this->waitForElementPresent("xpath=//table[@id='options']");
431 $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span", $field1);
432
433 // Create a survey
434 $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom");
435
436 // fill in a unique title for the survey
437 $surveyTitle = "Survey $title";
438 $this->waitForElementPresent('title');
439 $this->type('title', $surveyTitle);
440
441 // select the created campaign
442 //$this->select("campaign_id", "label=Campaign $title");
443
444 // select the activity type
445 $this->waitForElementPresent('activity_type_id');
446 $this->select("activity_type_id", "label=Survey");
447
448 // fill in reserve survey respondents
449 $this->type("default_number_of_contacts", 50);
450
451 // fill in interview survey respondents
452 $this->type("max_number_of_contacts", 100);
453
454 // release frequency
455 $this->type("release_frequency", 2);
456
457 $this->click("_qf_Main_upload-bottom");
458 $this->waitForElementPresent("_qf_Questions_upload_next-bottom");
459
460 //Select the profile for the survey
461 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
462
463 // select the question created for the survey
464
465 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[2]/td[2]/div/div/span/select", "label=$surveyProfile");
466 $this->click("_qf_Questions_upload_next-bottom");
467
468 // create a set of options for Survey Responses _qf_Results_upload_done-bottom
469 $this->waitForElementPresent('_qf_Results_upload_done-bottom');
470 $optionLabel1 = "Label $title 1";
471 $this->type("//input[@id='option_label_1']", "$optionLabel1");
472 $this->type("//input[@id='option_value_1']", "1");
473
474 $optionLabel2 = "Label $title 2";
475 $this->type("//input[@id='option_label_2']", "$optionLabel2");
476 $this->type("//input[@id='option_value_2']", "2");
477 $this->type("//input[@id='report_title']", "Survey $title");
478 $this->click('_qf_Results_upload_done-bottom');
479 $this->waitForElementPresent("//div[@id='search_form_survey']");
480 $this->assertTrue($this->isTextPresent("'Results' have been saved."),
481 "Status message didn't show up after saving survey!"
482 );
483
484 // Reserve Respondents
485 $this->openCiviPage("survey/search", "reset=1&op=reserve", '_qf_Search_refresh');
486
487 // search for the respondents
488 // select survey
489 $this->select('campaign_survey_id', "label=$surveyTitle");
490
491 // need to wait for Groups field to reload dynamically
492 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
493
494 // select group
495 $this->waitForElementPresent('group');
496 $this->click('group');
497 $this->waitForElementPresent('group');
498 $this->select('group', "label=$groupName");
499 $this->click('_qf_Search_refresh');
500
501 $this->waitForElementPresent('toggleSelect');
502 $this->click('toggleSelect');
503 $this->select('task', "Reserve Respondents");
504
505 $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom');
506
507 $this->clickLink('_qf_Reserve_done_reserve-bottom', 'access');
508 $this->waitForText('crm-notification-container', "2 Contact\(s\) have been reserved");
509
510 $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
511
512 // Select columns to be displayed
513 $this->check('fields[survey_id]');
514 $this->check('fields[survey_response]');
515 $this->select('survey_id_value', "label=$surveyTitle");
516 $this->select('status_id_value', "label=Reserved");
517 $this->click('_qf_SurveyDetails_submit');
518 $this->waitForElementPresent('_qf_SurveyDetails_submit_print');
519 $this->assertTrue($this->isTextPresent("Is equal to Reserved"));
520
521 // commenting out the print assertion as print dialog which appears breaks the webtest
522 // as it is OS-related and cannot be handled through webtest
523
524 // $this->click('_qf_SurveyDetails_submit_print');
525 // $this->waitForPageToLoad($this->getTimeoutMsec());
526
527 // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle"));
528 // $this->assertTrue($this->isTextPresent("Q1 = $field1"));
529 // $this->assertTrue($this->isTextPresent("$value1 | $value2 | $value3"));
530
531 // Interview Respondents
532 $this->openCiviPage("survey/search", "reset=1&op=interview", '_qf_Search_refresh');
533
534 // search for the respondents
535 // select survey
536 $this->select('campaign_survey_id', "label=$surveyTitle");
537
538 // need to wait for Groups field to reload dynamically
539 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
540
541 // select group
542 $this->click('group');
543 $this->select('group', "label=$groupName");
544 //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
545 $this->click('_qf_Search_refresh');
546
547 //$this->click("xpath=//*[@class='selector']//tbody//tr[@id='rowid{$id1}']/td[1]");
548 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
549 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
550 $this->waitForElementPresent('task');
551 $this->select('task', "Record Survey Responses");
552 $this->waitForElementPresent('_qf_Interview_cancel_interview');
553
554 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[6]/input[@type='text']");
555
556 $this->type("field_{$id1}_phone-Primary-1", 9876543210);
557 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]/../label[text()='$label1']");
558 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]/../label[text()='$label1']");
559
560 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]/../label[text()='$label2']");
561 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[6]/../label[text()='$label2']");
562
563 $this->select("field_{$id1}_result", $optionLabel1);
564 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[10]/a");
565 $this->click('_qf_Interview_cancel_interview');
566 // Because it tends to cause problems, all uses of sleep() must be justified in comments
567 // Sleep should never be used for wait for anything to load from the server
568 // Justification for this instance: FIXME
569 sleep(3);
570 // Survey Report
571 $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
572
573 // Select columns to be displayed
574 $this->check('fields[survey_id]');
575 $this->check('fields[survey_response]');
576 $this->select('survey_id_value', "label=$surveyTitle");
577 $this->select('status_id_value', "label=Interviewed");
578 $this->click('_qf_SurveyDetails_submit');
579 $this->waitForElementPresent('_qf_SurveyDetails_submit_print');
580 $this->assertTrue($this->isTextPresent("Is equal to Interviewed"));
581
582 // commenting out the print assertion as print dialog which appears breaks the webtest
583 // as it is OS-related and cannot be handled through webtest
584
585 // $this->click('_qf_SurveyDetails_submit_print');
586 // $this->waitForPageToLoad($this->getTimeoutMsec());
587
588 // $this->assertTrue($this->isTextPresent("Survey Title = $surveyTitle"));
589 // $this->assertTrue($this->isTextPresent("Q1 = $field1"));
590 // $this->assertTrue($this->isTextPresent("$value1"));
591
592 // use GOTV (campaign/gotv) to mark the respondents as voted
593 $this->openCiviPage("campaign/gotv", "reset=1");
594
595 // search for the respondents
596 // select survey
597 $this->select('campaign_survey_id', "label=$surveyTitle");
598 // need to wait for Groups field to reload dynamically
599 $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
600
601 // select group
602 $this->click('group');
603 $this->select('group', "label=$groupName");
604 //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
605 //$this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='Search']");
606 $this->click("link=Search");
607
608 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
609 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
610
611 // Check title of the activities created
612 $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
613 $this->waitForElementPresent('activity_survey_id');
614 $this->select('activity_survey_id', "label=$surveyTitle");
615 $this->click('_qf_Search_refresh');
616 $this->waitForPageToLoad($this->getTimeoutMsec());
617
618 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
619 $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]",
620 preg_quote("$surveyTitle - Respondent Interview")
621 );
622 $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]",
623 preg_quote("$surveyTitle - Respondent Reservation")
624 );
625 }
626 }
627