Merge pull request #11087 from yashodha/CRM-19850
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / ABMailingTest.php
CommitLineData
d1a27213 1<?php
2/*
3 +--------------------------------------------------------------------+
81621fee 4 | CiviCRM version 4.7 |
d1a27213 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
d1a27213 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
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29/**
30 * Class WebTest_Mailing_ABMailingTest
31 */
32class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
f13a7d55 38 public function testWithDifferentSubject() {
a6f95222 39 $this->markTestSkipped('Skipping for now as it works fine locally.');
d1a27213 40 $this->webtestLogin();
41
42 //----do create test mailing group
43 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
44
45 // make group name
46 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
47
48 // fill group name
49 $this->type("title", $groupName);
50
51 // fill description
52 $this->type("description", "New mailing group for Webtest");
53
54 // enable Mailing List
55 $this->click("group_type[2]");
56
57 // select Visibility as Public Pages
58 $this->select("visibility", "value=Public Pages");
59
60 // Clicking save.
61 $this->clickLink("_qf_Edit_upload");
62
63 // Is status message correct?
64 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
65
66 // no. of user to add into group
67 $totalUser = 10;
68
69 //---- create mailing contact and add to mailing Group
82647609 70 for ($i = 1; $i <= $totalUser; $i++) {
d1a27213 71 $firstName = substr(sha1(rand()), 0, 7);
72 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
73
74 // Get contact id from url.
75 $contactId = $this->urlArg('cid');
76
77 // go to group tab and add to mailing group
78 $this->click("css=li#tab_group a");
79 $this->waitForElementPresent("_qf_GroupContact_next");
80 $this->select("group_id", "$groupName");
81 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
82 }
83 // configure default mail-box
84 $this->setupDefaultMailbox();
85
86 $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
87 $this->waitForElementPresent("xpath=//input[@name='abName']");
88
89 $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
90 $this->type("xpath=//input[@name='abName']", "$ABTestName");
91
92 $this->click("xpath=//input[@value='subject']");
93
94 //click on next
95 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
96
97 // Add the test mailing group
98 $this->select2("s2id_crmUiId_13", $groupName, TRUE);
99
100 //$this->fireEvent('xpath=//div[@class="ui-slider-range"]', 'drag');
101
102 //click on next
103 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
104 $this->waitForElementPresent("xpath=//input[@name='subjectA']");
105
106 //-------Compose Mail----------
c79c8ec8 107 $tokens = ' {domain.address}{action.optOutUrl}';
d1a27213 108
109 // fill subject for mailing
110 $MailingSubject = substr(sha1(rand()), 0, 7);
111 $this->type("xpath=//input[@name='subjectA']", "Test subject {$MailingSubject} for A");
82647609 112 $this->type("xpath=//input[@name='subjectB']", "Test subject {$MailingSubject} for B");
d1a27213 113
114 // HTML format message
115 $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest.";
c79c8ec8 116 $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
d1a27213 117
c79c8ec8
CW
118 // FIXME: Selenium can't access content in an iframe
119 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
120 //$this->waitForTextPresent($HTMLMessage);
121 //$this->waitForAjaxContent();
122 //$this->click("xpath=//button[@title='Close']");
d1a27213 123
124 // Open Plain-text Format pane and type text format msg
c79c8ec8
CW
125 $this->click("//div[starts-with(text(),'Plain Text')]");
126 $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens");
d1a27213 127
128 $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
ea83a78e 129 $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.");
d1a27213 130 $this->waitForAjaxContent();
131 $this->click("xpath=//button[@title='Close']");
132
133 // click next with default settings
134 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
135
136 // click next with nominal content
137 $this->click("xpath=//center/a/div[text()='Submit Mailing']");
138
139 $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
140 $this->click("xpath=//button[text()='Select as Final']");
141 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
142 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
143
144 //----------end New Mailing-------------
145
146 $this->waitForAjaxContent();
147
148 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
149 $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
150 $this->waitForTextPresent("Find Mailings");
151
152 //--------- mail delivery verification---------
153
154 // click report link of created mailing
a488ca1a 155 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
d1a27213 156
157 // directly send schedule mailing -- not working right now
158 $this->openCiviPage("mailing/queue", "reset=1");
159
160 //click report link of created mailing
a488ca1a 161 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
d1a27213 162
163 //get actual number of user for mailing
4961a013 164 $mailedUser = round($totalUser * ($totalUser / 100));
d1a27213 165
166 //---- check for delivery detail--
167
82647609 168 $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
d1a27213 169 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
170 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
171
172 //check value for Mailing A
82647609 173 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
174 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $MailingSubject . ' for A');
175 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
d1a27213 176
177 ////check value for Mailing B
2ae100d8 178 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
179 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $MailingSubject . ' for B');
d1a27213 180
181 //check value for Mailing Final
2ae100d8 182 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
82647609 183 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $MailingSubject . ' for A');
2ae100d8 184 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
d1a27213 185 }
186
187 public function testWithDifferentFrom() {
a6f95222 188 $this->markTestSkipped('Skipping for now as it works fine locally.');
d1a27213 189 $this->webtestLogin();
190
191 //----do create test mailing group
192 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
193
194 // make group name
195 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
196
197 // fill group name
198 $this->type("title", $groupName);
199
200 // fill description
201 $this->type("description", "New mailing group for Webtest");
202
203 // enable Mailing List
204 $this->click("group_type[2]");
205
206 // select Visibility as Public Pages
207 $this->select("visibility", "value=Public Pages");
208
209 // Clicking save.
210 $this->clickLink("_qf_Edit_upload");
211
212 // Is status message correct?
213 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
214
215 // no. of user to add into group
216 $totalUser = 10;
217
218 //---- create mailing contact and add to mailing Group
82647609 219 for ($i = 1; $i <= $totalUser; $i++) {
d1a27213 220 $firstName = substr(sha1(rand()), 0, 7);
221 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
222
223 // Get contact id from url.
224 $contactId = $this->urlArg('cid');
225
226 // go to group tab and add to mailing group
227 $this->click("css=li#tab_group a");
228 $this->waitForElementPresent("_qf_GroupContact_next");
229 $this->select("group_id", "$groupName");
230 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
231 }
232 // configure default mail-box
233 $this->setupDefaultMailbox();
234
235 // configure new Form
236 $this->openCiviPage("admin/options/from_email_address", "reset=1");
237 $this->waitForElementPresent("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
238 $this->click("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
82647609 239 $this->waitForAjaxContent();
d1a27213 240
241 // make Form Email address
242 $formEmailAddressA = 'ABMailing_' . substr(sha1(rand()), 0, 7);
82647609 243 $aEmailID = '"' . $formEmailAddressA . '" <' . $formEmailAddressA . '@abtest.org>';
f13a7d55 244 $this->type("xpath=//input[@name='label']", "$aEmailID");
245 $this->click("xpath=//button/span[text()='Save']");
d1a27213 246
82647609 247 // make Form Email address
d1a27213 248 $this->click("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
82647609 249 $this->waitForAjaxContent();
d1a27213 250 $formEmailAddressB = 'ABMailing_' . substr(sha1(rand()), 0, 7);
4961a013 251 $bEmailID = '"' . $formEmailAddressB . '" <' . $formEmailAddressB . '@abtest.org>';
f13a7d55 252 $this->type("xpath=//input[@name='label']", "$bEmailID");
253 $this->click("xpath=//button/span[text()='Save']");
d1a27213 254
f13a7d55 255 $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
256 $this->waitForElementPresent("xpath=//input[@name='abName']");
d1a27213 257
82647609 258 $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
f13a7d55 259 $this->type("xpath=//input[@name='abName']", "$ABTestName");
d1a27213 260
f13a7d55 261 $this->click("xpath=//input[@value='from']");
d1a27213 262
f13a7d55 263 //click on next
264 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
d1a27213 265
f13a7d55 266 // Add the test mailing group
d1a27213 267 $this->select2("s2id_crmUiId_13", $groupName, TRUE);
268
82647609 269 //click on next
f13a7d55 270 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
271 $this->waitForElementPresent("xpath=//input[@name='subject']");
d1a27213 272
82647609 273 //-------Compose Mail----------
c79c8ec8 274 $tokens = ' {domain.address}{action.optOutUrl}';
d1a27213 275
276 // fill subject for mailing
277 $MailingSubject = substr(sha1(rand()), 0, 7);
278 $this->type("xpath=//input[@name='subject']", "Test subject {$MailingSubject} for webtest");
279 $this->waitForElementPresent("xpath=//div[@id='s2id_crmUiId_20']");
280
281 // choose form email address for A
f75b8467 282 $this->select("crmUiId_20", "value=$aEmailID");
d1a27213 283
284 // choose form email address for B
f75b8467 285 $this->select("crmUiId_21", "value=$bEmailID");
d1a27213 286
287 // HTML format message
288 $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest.";
c79c8ec8 289 $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
d1a27213 290
c79c8ec8
CW
291 // FIXME: Selenium can't access content in an iframe
292 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
293 //$this->waitForTextPresent($HTMLMessage);
294 //$this->waitForAjaxContent();
295 //$this->click("xpath=//button[@title='Close']");
d1a27213 296
297 // Open Plain-text Format pane and type text format msg
c79c8ec8
CW
298 $this->click("//div[starts-with(text(),'Plain Text')]");
299 $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens");
d1a27213 300
301 $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
ea83a78e 302 $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.");
d1a27213 303 $this->waitForAjaxContent();
304 $this->click("xpath=//button[@title='Close']");
305
306 // click next with default settings
307 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
308
309 // click next with nominal content
310 $this->click("xpath=//center/a/div[text()='Submit Mailing']");
311
312 $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
313 $this->click("xpath=//button[text()='Select as Final']");
314 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
315 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
316
317 //----------end New Mailing-------------
318
319 $this->waitForAjaxContent();
320
321 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
322 $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
323 $this->waitForTextPresent("Find Mailings");
324
325 //--------- mail delivery verification---------
326
327 // click report link of created mailing
a488ca1a 328 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
d1a27213 329
330 // directly send schedule mailing -- not working right now
331 $this->openCiviPage("mailing/queue", "reset=1");
332
333 //click report link of created mailing
a488ca1a 334 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
d1a27213 335
336 //get actual number of user for mailing
4961a013 337 $mailedUser = round($totalUser * ($totalUser / 100));
d1a27213 338
339 //---- check for delivery detail--
82647609 340 $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
d1a27213 341 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
342 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
343
344 //check value for Mailing A
82647609 345 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
d1a27213 346 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[2]", "$aEmailID");
82647609 347 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $MailingSubject . ' for webtest');
348 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
d1a27213 349
350 //check value for Mailing B
82647609 351 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
d1a27213 352 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[3]", "$bEmailID");
82647609 353 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $MailingSubject . ' for webtest');
d1a27213 354
355 //check value for Mailing Final
82647609 356 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
d1a27213 357 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[4]", "$aEmailID");
82647609 358 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $MailingSubject . ' for webtest');
359 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
d1a27213 360 }
361
362 public function testWithDifferentABMailing() {
a6f95222 363 $this->markTestSkipped('Skipping for now as it works fine locally.');
d1a27213 364 $this->webtestLogin();
365
366 //----do create test mailing group
367 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
368
369 // make group name
370 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
371
372 // fill group name
373 $this->type("title", $groupName);
374
375 // fill description
376 $this->type("description", "New mailing group for Webtest");
377
378 // enable Mailing List
379 $this->click("group_type[2]");
380
381 // select Visibility as Public Pages
382 $this->select("visibility", "value=Public Pages");
383
384 // Clicking save.
385 $this->clickLink("_qf_Edit_upload");
386
387 // Is status message correct?
388 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
389
390 // no. of user to add into group
391 $totalUser = 10;
392
393 //---- create mailing contact and add to mailing Group
82647609 394 for ($i = 1; $i <= $totalUser; $i++) {
d1a27213 395 $firstName = substr(sha1(rand()), 0, 7);
396 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
397
398 // Get contact id from url.
399 $contactId = $this->urlArg('cid');
400
401 // go to group tab and add to mailing group
402 $this->click("css=li#tab_group a");
403 $this->waitForElementPresent("_qf_GroupContact_next");
404 $this->select("group_id", "$groupName");
405 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
406 }
407 // configure default mail-box
408 $this->setupDefaultMailbox();
409
410 $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
411 $this->waitForElementPresent("xpath=//input[@name='abName']");
412
413 $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
414 $this->type("xpath=//input[@name='abName']", "$ABTestName");
415
416 $this->click("xpath=//input[@value='full_email']");
417
418 //click on next
419 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
420
421 // Add the test mailing group
422 $this->select2("s2id_crmUiId_13", $groupName, TRUE);
423
424 //click on next
425 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
426 $this->waitForElementPresent("xpath=//input[@name='subjectA']");
427
428 //-------Compose A----------
c79c8ec8 429 $tokens = ' {domain.address}{action.optOutUrl}';
d1a27213 430
431 // fill subject for mailing
432 $AMailingSubject = substr(sha1(rand()), 0, 7);
433 $this->type("xpath=//input[@name='subjectA']", "Test subject {$AMailingSubject} for Webtest");
434
435 // HTML format message
436 $AHTMLMessage = "This is HTML formatted content for Mailing {$AMailingSubject} Webtest.";
c79c8ec8 437 $this->fillRichTextField("crmUiId_19", $AHTMLMessage . $tokens);
d1a27213 438
c79c8ec8
CW
439 // FIXME: Selenium can't access content in an iframe
440 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
441 //$this->waitForTextPresent($AHTMLMessage);
442 //$this->waitForAjaxContent();
443 //$this->click("xpath=//button[@title='Close']");
d1a27213 444
445 // Open Plain-text Format pane and type text format msg
c79c8ec8
CW
446 $this->click("//div[starts-with(text(),'Plain Text')]");
447 $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$AMailingSubject} Webtest.$tokens");
d1a27213 448
449 $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
450 $this->waitForTextPresent("This is text formatted content for Mailing {$AMailingSubject} Webtest.");
451 $this->waitForAjaxContent();
452 $this->click("xpath=//button[@title='Close']");
453
454 // click next with default settings
455 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
456 $this->waitForElementPresent("xpath=//input[@name='subjectB']");
457
458 //-------Compose B----------
459
460 // fill subject for mailing
461 $BMailingSubject = substr(sha1(rand()), 0, 7);
462 $this->type("xpath=//input[@name='subjectB']", "Test subject {$BMailingSubject} for Webtest");
d1a27213 463
464 // HTML format message
465 $BHTMLMessage = "This is HTML formatted content for Mailing {$BMailingSubject} Webtest.";
c79c8ec8 466 $this->fillRichTextField("crmUiId_28", $BHTMLMessage . $tokens);
d1a27213 467
c79c8ec8
CW
468 // FIXME: Selenium can't access content in an iframe
469 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
470 //$this->waitForTextPresent($BHTMLMessage);
471 //$this->waitForAjaxContent();
472 //$this->click("xpath=//button[@title='Close']");
d1a27213 473
474 // Open Plain-text Format pane and type text format msg
ea83a78e 475 $this->waitForElementPresent("xpath=//div[@id='tab-mailingB']//div[contains(text(), 'Plain Text')]");
476 $this->click("xpath=//div[@id='tab-mailingB']//div[contains(text(), 'Plain Text')]");
c79c8ec8 477 $this->type("xpath=//div[@id='tab-mailingB']//*[@name='body_text']", "This is text formatted content for Mailing {$BMailingSubject} Webtest.$tokens");
d1a27213 478
479 $this->click("xpath=//div[@crm-mailing='abtest.mailings.b']//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
480 $this->waitForTextPresent("This is text formatted content for Mailing {$BMailingSubject} Webtest.");
481 $this->waitForAjaxContent();
482 $this->click("xpath=//button[@title='Close']");
483
484 // click next with default settings
485 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
486
487 // click next with nominal content
488 $this->click("xpath=//center/a/div[text()='Submit Mailing']");
489
490 $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
491 $this->click("xpath=//button[text()='Select as Final']");
492 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
493 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
494
495 //----------end New Mailing-------------
496
497 $this->waitForAjaxContent();
498
499 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
500 $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
501 $this->waitForTextPresent("Find Mailings");
502
503 //--------- mail delivery verification---------
504
505 // click report link of created mailing
a488ca1a 506 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
d1a27213 507
508 // directly send schedule mailing -- not working right now
509 $this->openCiviPage("mailing/queue", "reset=1");
510
511 //click report link of created mailing
a488ca1a 512 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
d1a27213 513
514 //get actual number of user for mailing
4961a013 515 $mailedUser = round($totalUser * ($totalUser / 100));
d1a27213 516
517 //---- check for delivery detail--
82647609 518 $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
d1a27213 519 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
520 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
521
522 //check value for Mailing A
82647609 523 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
524 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $AMailingSubject . ' for Webtest');
525 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
d1a27213 526
527 //check value for Mailing B
82647609 528 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
529 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $BMailingSubject . ' for Webtest');
d1a27213 530
531 //check value for Mailing Final
2ae100d8 532 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
533 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $AMailingSubject . ' for Webtest');
534 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
d1a27213 535 }
82647609 536
537}