X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FMailing%2FMailingTest.php;h=2c542c7bebd3252fcd258f38c8ca76329f63b122;hb=HEAD;hp=426018b27beba8c85761b0c96f01e18de40ab533;hpb=87d422669cee2e65706fe72821613ad846cd0adb;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Mailing/MailingTest.php b/tests/phpunit/WebTest/Mailing/MailingTest.php index 426018b27b..7f067fc7f5 100644 --- a/tests/phpunit/WebTest/Mailing/MailingTest.php +++ b/tests/phpunit/WebTest/Mailing/MailingTest.php @@ -1,9 +1,9 @@ webtestLogin(); //----do create test mailing group @@ -78,60 +78,72 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { // configure default mail-box $this->setupDefaultMailbox(); - $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel"); + $this->openCiviPage("a/#/mailing/new"); //-------select recipients---------- + $tokens = ' {domain.address}{action.optOutUrl}'; // fill mailing name $mailingName = substr(sha1(rand()), 0, 7); - $this->type("name", "Mailing $mailingName Webtest"); + $this->waitForElementPresent("xpath=//input[@name='mailingName']"); + $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest"); // Add the test mailing group - $this->select("includeGroups", "$groupName"); + $this->select2("s2id_crmUiId_8", $groupName, TRUE); - // click next - $this->clickLink("_qf_Group_next", "_qf_Settings_cancel", FALSE); + // do check count for Recipient + $this->waitForTextPresent("~1 recipient"); - //--------track and respond---------- + // fill subject for mailing + $this->type("xpath=//input[@name='subject']", "Test subject {$mailingName} for Webtest"); - // check for default settings options - $this->assertChecked("url_tracking"); - $this->assertChecked("open_tracking"); + // HTML format message + $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest."; + $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens); - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); + // FIXME: Selenium can't access content in an iframe + //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); + //$this->waitForTextPresent($HTMLMessage); + //$this->waitForAjaxContent(); + //$this->click("xpath=//button[@title='Close']"); - // no need tracking for this test + // Open Plain-text Format pane and type text format msg + $this->click("//div[starts-with(text(),'Plain Text')]"); + $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens"); - // click next with default settings - $this->clickLink("_qf_Settings_next", "_qf_Upload_cancel"); + $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); + $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest."); + $this->waitForAjaxContent(); + $this->click("xpath=//button[@title='Close']"); - //--------Mailing content------------ - // let from email address be default + // select default header and footer ( with label ) + $this->click("xpath=//ul/li/a[text()='Header and Footer']"); + $this->select2("s2id_crmUiId_10", "Mailing Header"); + $this->select2("s2id_crmUiId_11", "Mailing Footer"); - // fill subject for mailing - $this->type("subject", "Test subject {$mailingName} for Webtest"); + //--------track and respond---------- - // check for default option enabled - $this->assertChecked("CIVICRM_QFID_1_upload_type"); + // check for default settings options + $this->click("xpath=//ul/li/a[text()='Tracking']"); + $this->assertChecked("url_tracking"); + $this->assertChecked("open_tracking"); - // HTML format message - $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest."; - $this->fillRichTextField("html_message", $HTMLMessage); + // click next with default settings + $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']"); - // Open Plain-text Format pane and type text format msg - $this->click("//fieldset[@id='compose_id']/div[2]/div[1]"); - $this->type("text_message", "This is text formatted content for Mailing {$mailingName} Webtest."); + $this->waitForTextPresent("Mailing $mailingName Webtest"); + $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']"); + $this->webtestVerifyTabularData(array("$firstName Mailson" => "mailino$firstName@mailson.co.in")); + $this->click("xpath=//button[@title='Close']"); + $this->waitForTextPresent("(Include: $groupName)"); - // select default header and footer ( with label ) - $this->select("header_id", "label=Mailing Header"); - $this->select("footer_id", "label=Mailing Footer"); + //----------Schedule or Send------------ - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); + // do check for default option enabled + $this->assertChecked("xpath=//input[@id='schedule-send-now']"); // click next with nominal content - $this->clickLink("_qf_Upload_upload", "_qf_Test_cancel"); + $this->click("xpath=//center/a/div[text()='Submit Mailing']"); //---------------Test------------------ @@ -150,27 +162,10 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { //////// - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); - - // click next - $this->clickLink("_qf_Test_next", "_qf_Schedule_cancel"); - - //----------Schedule or Send------------ - - // do check for default option enabled - $this->assertChecked("now"); - - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); - - // finally schedule the mail by clicking submit - $this->clickLink("_qf_Schedule_next"); - //----------end New Mailing------------- //check redirected page to Scheduled and Sent Mailings and verify for mailing name - $this->assertElementContainsText('page-title', "Find Mailings"); + $this->waitForTextPresent("Find Mailings"); $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody//tr//td", "Mailing $mailingName Webtest"); //--------- mail delivery verification--------- @@ -214,10 +209,10 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->clickLink("link=Successful Deliveries"); // check for open page - $this->assertElementContainsText( 'page-title', "Successful Deliveries"); + $this->waitForTextPresent("Successful Deliveries"); // verify email - $this->verifyText("xpath=//table[@id='mailing_event']/tbody//tr/td[2]", preg_quote("mailino$firstName@mailson.co.in")); + $this->verifyText("xpath=//table[@id='mailing_event']/tbody//tr/td[3]", preg_quote("mailino$firstName@mailson.co.in")); $eventQueue = new CRM_Mailing_Event_DAO_Queue(); $eventQueue->contact_id = $contactId; @@ -228,7 +223,10 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->webtestLogout(); // build forward url - $forwardUrl = array("mailing/forward", "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}"); + $forwardUrl = array( + "mailing/forward", + "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}", + ); $this->openCiviPage($forwardUrl[0], $forwardUrl[1], NULL); $this->type("email_0", substr(sha1(rand()), 0, 7) . '@example.com'); @@ -255,7 +253,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { //------end delivery verification--------- // //------ check with unsubscribe ------- - // // FIX ME: there is an issue with DSN setting for Webtest, need to handle by seperate DSN setting for Webtests + // // FIX ME: there is an issue with DSN setting for Webtest, need to handle by separate DSN setting for Webtests // // build unsubscribe link // require_once 'CRM/Mailing/Event/DAO/Queue.php'; // $eventQueue = new CRM_Mailing_Event_DAO_Queue( ); @@ -286,7 +284,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { // //------ end unsubscribe ------- } - function testAdvanceSearchAndReportCheck() { + public function testAdvanceSearchAndReportCheck() { $this->webtestLogin(); @@ -333,79 +331,77 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->select('protocol', 'value=1'); $this->clickLink('_qf_MailSettings_next-bottom'); - // Go to Schedule and Send Mailing form - $this->openCiviPage('mailing/send', 'reset=1', '_qf_Group_cancel'); + $this->openCiviPage("a/#/mailing/new"); //-------select recipients---------- + $tokens = ' {domain.address}{action.optOutUrl}'; // fill mailing name $mailingName = substr(sha1(rand()), 0, 7); - $this->type("name", "Mailing $mailingName Webtest"); + $this->waitForElementPresent("xpath=//input[@name='mailingName']"); + $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest"); // Add the test mailing group - $this->select("includeGroups", "$groupName"); - - // click next - $this->click("_qf_Group_next"); - $this->waitForElementPresent("_qf_Settings_cancel"); - - //--------track and respond---------- - - // check for default settings options - $this->assertChecked("url_tracking"); - $this->assertChecked("open_tracking"); + $this->select2("s2id_crmUiId_8", $groupName, TRUE); // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); - - // click next with default settings - $this->clickLink("_qf_Settings_next"); + $this->waitForTextPresent("~1 recipient"); // fill subject for mailing - $this->type("subject", "Test subject {$mailingName} for Webtest"); - - // check for default option enabled - $this->assertChecked("CIVICRM_QFID_1_upload_type"); + $this->type("xpath=//input[@name='subject']", "Test subject {$mailingName} for Webtest"); // HTML format message $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest."; - $this->fillRichTextField("html_message", $HTMLMessage); + $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens); + + // FIXME: Selenium can't access content in an iframe + //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); + //$this->waitForElementPresent($HTMLMessage); + //$this->waitForAjaxContent(); + //$this->click("xpath=//button[@title='Close']"); // Open Plain-text Format pane and type text format msg - $this->click("//fieldset[@id='compose_id']/div[2]/div[1]"); - $this->type("text_message", "This is text formatted content for Mailing {$mailingName} Webtest."); + $this->click("//div[starts-with(text(),'Plain Text')]"); + $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens"); + + $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); + $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest."); + $this->waitForAjaxContent(); + $this->click("xpath=//button[@title='Close']"); // select default header and footer ( with label ) - $this->select("header_id", "label=Mailing Header"); - $this->select("footer_id", "label=Mailing Footer"); + $this->click("xpath=//ul/li/a[text()='Header and Footer']"); + $this->select2("s2id_crmUiId_10", "Mailing Header"); + $this->select2("s2id_crmUiId_11", "Mailing Footer"); - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); + //--------track and respond---------- - // click next with nominal content - $this->clickLink("_qf_Upload_upload", "_qf_Test_cancel"); + // check for default settings options + $this->click("xpath=//ul/li/a[text()='Tracking']"); + $this->assertChecked("url_tracking"); + $this->assertChecked("open_tracking"); - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); + // click next with default settings + $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']"); - // click next - $this->clickLink("_qf_Test_next", "_qf_Schedule_cancel"); + $this->waitForTextPresent("Mailing $mailingName Webtest"); + $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']"); + $this->webtestVerifyTabularData(array("$firstName Mailson" => "mailino$firstName@mailson.co.in")); + $this->click("xpath=//button[@title='Close']"); + $this->waitForTextPresent("(Include: $groupName)"); //----------Schedule or Send------------ // do check for default option enabled - $this->assertChecked("now"); - - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); + $this->assertChecked("xpath=//input[@id='schedule-send-now']"); - // finally schedule the mail by clicking submit - $this->clickLink("_qf_Schedule_next"); + // click next with nominal content + $this->click("xpath=//center/a/div[text()='Submit Mailing']"); //----------end New Mailing------------- //check redirected page to Scheduled and Sent Mailings and verify for mailing name - $this->assertElementContainsText('page-title', "Find Mailings"); + $this->waitForTextPresent("Find Mailings"); $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody//tr//td", "Mailing $mailingName Webtest"); // directly send schedule mailing -- not working right now @@ -421,13 +417,23 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { // verify successful deliveries $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)")); - $summaryInfoLinks = array('Intended Recipients', 'Successful Deliveries', 'Tracked Opens', 'Click-throughs', 'Forwards', 'Replies', 'Bounces', 'Unsubscribe Requests','Opt-out Requests'); + $summaryInfoLinks = array( + 'Intended Recipients', + 'Successful Deliveries', + 'Tracked Opens', + 'Click-throughs', + 'Forwards', + 'Replies', + 'Bounces', + 'Unsubscribe Requests', + 'Opt-out Requests', + ); //check for report and adv search links - foreach($summaryInfoLinks as $value) { + foreach ($summaryInfoLinks as $value) { $this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[1][text()='Report']"), "Report link missing for {$value}"); $this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[2][text()='Advanced Search']"), "Advance Search link missing for {$value}"); -} + } // verify mailing name $this->verifyText("xpath=//table//tr[td[1]/text()='Mailing Name']/descendant::td[2]", preg_quote("Mailing $mailingName Webtest")); @@ -435,59 +441,85 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->verifyText("xpath=//table//tr[td[1]/text()='Subject']/descendant::td[2]", preg_quote("Test subject $mailingName for Webtest")); // after asserts do clicks and confirm filters - $criteriaCheck = - array( - 'Intended Recipients' => - array( - 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest") + $criteriaCheck = array( + 'Intended Recipients' => array( + 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest"), + ), + 'Successful Deliveries' => array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + "Delivery Status" => " Successful", + ), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing Delivery -' => "Successful", + ), + ), + 'Tracked Opens' => array( + 'report' => array('report_name' => 'Mail Opened', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: Trackable Opens -' => "Opened", ), - 'Successful Deliveries' => - array( - 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest", - "Delivery Status" => " Successful"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing Delivery -' => "Successful") + ), + 'Click-throughs' => array( + 'report' => array('report_name' => 'Mail Clickthroughs', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: Trackable URL Clicks -' => "Clicked", ), - 'Tracked Opens' => - array( - 'report' => array('report_name' => 'Mail Opened', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable Opens -' => "Opened") + ), + 'Forwards' => array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Forwarded' => 'Is equal to Yes', ), - 'Click-throughs' => - array( - 'report' => array('report_name' => 'Mail Clickthroughs', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable URL Clicks -' => "Clicked") + 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Forwards"), + ), + 'Replies' => array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Replied' => 'Is equal to Yes', ), - 'Forwards' => - array( - 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest", - 'Forwarded' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Forwards") + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: Trackable Replies -' => "Replied", ), - 'Replies' => - array( - 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest", - 'Replied' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable Replies -' => "Replied") + ), + 'Bounces' => array( + 'report' => array('report_name' => 'Mail Bounces', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing Delivery -' => "Bounced", ), - 'Bounces' => - array( - 'report' => array('report_name' => 'Mail Bounces', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing Delivery -' => "Bounced") + ), + 'Unsubscribe Requests' => array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Unsubscribed' => 'Is equal to Yes', ), - 'Unsubscribe Requests' => - array( - 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest", - 'Unsubscribed' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Unsubscribe Requests") + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: -' => "Unsubscribe Requests", ), - 'Opt-out Requests' => - array( - 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest", - 'Opted-out' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Opt-out Requests") + ), + 'Opt-out Requests' => array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Opted-out' => 'Is equal to Yes', ), - ); + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: -' => "Opt-out Requests", + ), + ), + ); $this->criteriaCheck($criteriaCheck, $mailingReportUrl); } @@ -495,16 +527,17 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { * @param $criteriaCheck * @param $mailingReportUrl */ - function criteriaCheck($criteriaCheck, $mailingReportUrl) { - foreach($criteriaCheck as $key => $infoFilter) { - foreach($infoFilter as $entity => $dataToCheck) { + public function criteriaCheck($criteriaCheck, $mailingReportUrl) { + foreach ($criteriaCheck as $key => $infoFilter) { + foreach ($infoFilter as $entity => $dataToCheck) { $this->open($mailingReportUrl); if ($entity == "report") { $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[1][text()='Report']"); - } else { + } + else { $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[2][text()='Advanced Search']"); } - $this-> _verifyCriteria($key, $dataToCheck, $entity); + $this->_verifyCriteria($key, $dataToCheck, $entity); } } } @@ -514,22 +547,24 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { * @param $dataToCheck * @param $entity */ - function _verifyCriteria($summaryInfo, $dataToCheck, $entity) { - foreach($dataToCheck as $key => $value) { + public function _verifyCriteria($summaryInfo, $dataToCheck, $entity) { + foreach ($dataToCheck as $key => $value) { if ($entity == 'report') { if ($key == 'report_name') { - $this->assertElementContainsText('page-title', "{$value}"); + $this->waitForTextPresent("{$value}"); continue; } - $this->assertTrue($this->isElementPresent("xpath=//form//div[3]/table/tbody//tr/th[contains(text(),'{$key}')]/../td[contains(text(),'{$value}')]"),"Criteria check for {$key} failed for Report for {$summaryInfo}"); - } else { - $this->assertElementContainsText('page-title', "Advanced Search"); + $this->assertTrue($this->isElementPresent("xpath=//form//div[3]/table/tbody//tr/th[contains(text(),'{$key}')]/../td[contains(text(),'{$value}')]"), "Criteria check for {$key} failed for Report for {$summaryInfo}"); + } + else { + $this->waitForTextPresent("Advanced Search"); $assertedValue = $this->isElementPresent("xpath=//div[@class='crm-results-block']//div[@class='qill'][contains(text(),'{$key} {$value}')]"); if (!$assertedValue) { $assertedValue = $this->isTextPresent("{$key} {$value}"); } - $this->assertTrue($assertedValue,"Criteria check for {$key} failed for Advance Search for {$summaryInfo}"); + $this->assertTrue($assertedValue, "Criteria check for {$key} failed for Advance Search for {$summaryInfo}"); } } } + }