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