Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webtests fixes #82

Merged
merged 2 commits into from
Mar 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ function testTemplateAdd($useTokens = FALSE, $msgTitle = NULL) {
$this->waitForPageToLoad($this->getTimeoutMsec());

// Is status message correct
$this->assertTrue($this->isTextPresent("The Message Template '$msgTitle' has been saved."));
$this->assertElementContainsText('crm-notification-container', "The Message Template '$msgTitle' has been saved.");

// Verify text.
$this->assertTrue($this->isTextPresent($msgTitle));
$this->assertTrue($this->isElementPresent("xpath=id('user')/div[2]/div/table/tbody//tr/td[1][contains(text(), '$msgTitle')]"),
'Message Template Title not found!');
if (!$useTokens) {
$this->assertTrue($this->isTextPresent($msgSubject));
$this->assertTrue($this->isElementPresent("xpath=id('user')/div[2]/div/table/tbody//tr/td[2][contains(text(), '$msgSubject')]"),
'Message Subject not found!');
}
}

Expand Down Expand Up @@ -137,7 +139,7 @@ function testAddMailingWithMessageTemplate() {
$this->assertChecked("open_tracking");

// do check count for Recipient
$this->assertTrue($this->isTextPresent("Total Recipients: 1"));
$this->assertElementContainsText('css=.messages', "Total Recipients: 1");
$this->click("_qf_Settings_next");
$this->waitForElementPresent("_qf_Upload_cancel");

Expand All @@ -152,13 +154,13 @@ function testAddMailingWithMessageTemplate() {
$this->select('footer_id', "label=Mailing Footer");

// do check count for Recipient
$this->assertTrue($this->isTextPresent("Total Recipients: 1"));
$this->assertElementContainsText('css=.messages', "Total Recipients: 1");

// click next with nominal content
$this->click("_qf_Upload_upload");
$this->waitForElementPresent("_qf_Test_cancel");

$this->assertTrue($this->isTextPresent("Total Recipients: 1"));
$this->assertElementContainsText('css=.messages', "Total Recipients: 1");

// click next
$this->click("_qf_Test_next");
Expand All @@ -167,15 +169,15 @@ function testAddMailingWithMessageTemplate() {
$this->assertChecked("now");

// do check count for Recipient
$this->assertTrue($this->isTextPresent("Total Recipients: 1"));
$this->assertElementContainsText('css=.messages', "Total Recipients: 1");

// finally schedule the mail by clicking submit
$this->click("_qf_Schedule_next");
$this->waitForPageToLoad($this->getTimeoutMsec());

//check redirected page to Scheduled and Sent Mailings and verify for mailing name
$this->assertTrue($this->isTextPresent("Scheduled and Sent Mailings"));
$this->assertTrue($this->isTextPresent("Mailing $mailingName Webtest"));
$this->assertElementContainsText('page-title', "Scheduled and Sent Mailings");
$this->assertElementContainsText("xpath=//table[@class='selector']/tbody//tr//td", "Mailing $mailingName Webtest");
$this->openCiviPage('mailing/queue', 'reset=1');

// verify status
Expand All @@ -190,6 +192,6 @@ function testAddMailingWithMessageTemplate() {

$this->click("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']");
$this->waitForElementPresent("_qf_ActivityView_next");
$this->assertTrue($this->isTextPresent("Bulk Email Sent."), "Status message didn't show up after saving!");
$this->assertElementContainsText('help', "Bulk Email Sent.", "Status message didn't show up after saving!");
}
}
}
47 changes: 10 additions & 37 deletions tests/phpunit/WebTest/Mailing/AddNewMailingComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ function testHeaderAdd() {
$this->webtestLogin();

// Go directly to the URL of the screen that you will be testing (Add New Mailing Component).
$this->open($this->sboxPath . "civicrm/admin/component?action=add&reset=1");

$this->openCiviPage("admin/component", "action=add&reset=1");

// fill component name.
$componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
Expand Down Expand Up @@ -75,14 +74,10 @@ function testHeaderAdd() {
$this->waitForPageToLoad($this->getTimeoutMsec());

// Is status message correct.
$this->assertTrue($this->isTextPresent("The mailing component '$componentName' has been saved."));
$this->assertElementContainsText('crm-notification-container', "The mailing component '$componentName' has been saved.");

// Verify text.
$this->assertTrue($this->isTextPresent($componentName));
$this->assertTrue($this->isTextPresent("Header"));
$this->assertTrue($this->isTextPresent($subject));
$this->assertTrue($this->isTextPresent($txtMsg));
$this->assertTrue($this->isTextPresent($htmlMsg));
$this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[text()='{$componentName}']/../td[2][text()='Header']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
}

function testFooterAdd() {
Expand All @@ -91,16 +86,10 @@ function testFooterAdd() {
// class attributes.
$this->open($this->sboxPath);

// Logging in. Remember to wait for page to load. In most cases,
// you can rely on 30000 as the value that allows your test to pass, however,
// sometimes your test might fail because of this. In such cases, it's better to pick one element
// somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
// page contents loaded and you can continue your test execution.
$this->webtestLogin();

// Go directly to the URL of the screen that you will be testing (Add New Mailing Component).
$this->open($this->sboxPath . "civicrm/admin/component?action=add&reset=1");

$this->openCiviPage("admin/component", "action=add&reset=1");

// fill component name.
$componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
Expand Down Expand Up @@ -128,14 +117,10 @@ function testFooterAdd() {
$this->waitForPageToLoad($this->getTimeoutMsec());

// Is status message correct.
$this->assertTrue($this->isTextPresent("The mailing component '$componentName' has been saved."));
$this->assertElementContainsText('crm-notification-container', "The mailing component '$componentName' has been saved.");

// Verify text.
$this->assertTrue($this->isTextPresent($componentName));
$this->assertTrue($this->isTextPresent("Footer"));
$this->assertTrue($this->isTextPresent($subject));
$this->assertTrue($this->isTextPresent($txtMsg));
$this->assertTrue($this->isTextPresent($htmlMsg));
$this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[text()='{$componentName}']/../td[2][text()='Footer']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
}

function testAutomatedAdd() {
Expand All @@ -144,16 +129,10 @@ function testAutomatedAdd() {
// class attributes.
$this->open($this->sboxPath);

// Logging in. Remember to wait for page to load. In most cases,
// you can rely on 30000 as the value that allows your test to pass, however,
// sometimes your test might fail because of this. In such cases, it's better to pick one element
// somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
// page contents loaded and you can continue your test execution.
$this->webtestLogin();

// Go directly to the URL of the screen that you will be testing (Add New Mailing Component).
$this->open($this->sboxPath . "civicrm/admin/component?action=add&reset=1");

$this->openCiviPage("admin/component", "action=add&reset=1");

// fill component name.
$componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
Expand Down Expand Up @@ -181,15 +160,9 @@ function testAutomatedAdd() {
$this->waitForPageToLoad($this->getTimeoutMsec());

// Is status message correct.
$this->assertTrue($this->isTextPresent("The mailing component '$componentName' has been saved."));
$this->assertElementContainsText('crm-notification-container', "The mailing component '$componentName' has been saved.");

// Verify text
$this->assertTrue($this->isTextPresent($componentName));
$this->assertTrue($this->isTextPresent("Reply"));
$this->assertTrue($this->isTextPresent($subject));
$this->assertTrue($this->isTextPresent($txtMsg));
$this->assertTrue($this->isTextPresent($htmlMsg));
$this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[text()='{$componentName}']/../td[2][text()='Reply']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
}
}


}
Loading