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