3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Activity_StandaloneAddTest
32 class WebTest_Activity_StandaloneAddTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 function testStandaloneActivityAdd() {
39 $this->webtestLogin();
41 // Adding Anderson, Anthony and Summerson, Samuel for testStandaloneActivityAdd test
42 // We're using Quick Add block on the main page for this.
43 $firstName1 = substr(sha1(rand()), 0, 7);
44 $this->webtestAddContact("$firstName1", "Anderson", $firstName1 . "@anderson.com");
45 $firstName2 = substr(sha1(rand()), 0, 7);
46 $this->webtestAddContact("$firstName2", "Summerson", $firstName2 . "@summerson.com");
48 $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
50 // Select one of the options in Activity Type selector. Use option value, not label - since labels can be translated and test would fail
51 $this->select("activity_type_id", "value=1");
53 // We're filling in ajaxiefied "With Contact" field:
54 // We can not use id as selector for these input widgets. Use css selector, starting with the table row containing this field (which will have a unique class)
55 // Typing contact's name into the field (using typeKeys(), not type()!)...
56 $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
57 $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
58 $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1);
59 $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1);
61 // ...waiting for drop down with results to show up...
62 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
64 // ...need to use mouseDownAt on first result (which is a li element), click does not work
65 $this->clickAt("xpath=//div[@class='select2-result-label']");
67 // ...again, waiting for the box with contact name to show up (span with delete token class indicates that it's present)...
68 $this->waitForText("xpath=//div[@id='s2id_target_contact_id']","$firstName1");
70 //..and verifying if the page contains properly formatted display name for chosen contact.
71 $this->assertElementContainsText("xpath=//div[@id='s2id_target_contact_id']", "Anderson, $firstName1", 'Contact not found in line ' . __LINE__
);
73 // Now we're doing the same for "Assigned To" field.
74 // Typing contact's name into the field (using typeKeys(), not type()!)...
75 $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
76 $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
77 $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName2);
78 $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName2);
80 // ...waiting for drop down with results to show up...
81 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
83 //..need to use mouseDownAt on first result (which is a li element), click does not work
84 $this->clickAt("xpath=//div[@class='select2-result-label']");
86 // ...again, waiting for the box with contact name to show up...
87 $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']","$firstName2");
89 // ...and verifying if the page contains properly formatted display name for chosen contact.
90 $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Summerson, $firstName2", 'Contact not found in line ' . __LINE__
);
92 // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
93 $subject = "This is subject of test activity being added through standalone screen.";
94 // For simple input fields we can use field id as selector
95 $this->type("subject", $subject);
97 $location = 'Some location needs to be put in this field.';
98 $this->type("location", $location);
100 // Choosing the Date.
101 // Please note that we don't want to put in fixed date, since
102 // we want this test to work in the future and not fail because
103 // of date being set in the past. Therefore, using helper webtestFillDate function.
104 $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
107 $this->type("duration", "30");
109 // Putting in details.
110 $this->type("details", "Really brief details information.");
112 // Making sure that status is set to Scheduled (using value, not label).
113 $this->select("status_id", "value=1");
116 $this->select("priority_id", "value=1");
119 //FIX ME: need to fix file uploading
120 //$this->waitForElementPresent("attachFile_1");
121 //$filePath = $this->webtestAttachFile( "attachFile_1" );
123 // Scheduling follow-up.
124 $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
125 $this->select("followup_activity_type_id", "value=1");
126 $this->webtestFillDateTime('followup_date', '+2 months 10:00AM');
127 $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
130 $this->clickLink('_qf_Activity_upload');
132 // Is status message correct?
133 $this->waitForText('crm-notification-container', "Activity '$subject' has been saved.");
135 $this->openCiviPage("activity/search", "reset=1", "_qf_Search_refresh");
137 $this->type("sort_name", $firstName1);
138 $this->click("_qf_Search_refresh");
140 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr/td[6]/a[text()='Summerson, $firstName2']/../../td[9]/span/a[text()='View']");
141 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[6]/a[text()='Summerson, $firstName2']/../../td[9]/span/a[text()='View']");
142 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
144 $this->VerifyTabularData(
146 'Subject' => $subject,
147 'Location' => $location,
148 'Activity Status' => 'Scheduled',
150 // Tough luck filling in WYSIWYG editor, so skipping verification for now.
151 //'Details' => 'Really brief details information.',
152 'Priority' => 'Urgent',
153 //'Current Attachment(s)' => basename($filePath)
158 $this->VerifyTabularData(
160 'With Contact' => "Anderson, {$firstName1}",
161 'Assigned to' => "Summerson, {$firstName2}",
167 function testAjaxCustomGroupLoad() {
168 $this->webtestLogin();
169 $triggerElement = array('name' => 'activity_type_id', 'type' => 'select');
171 array('entity' => 'Activity', 'subEntity' => 'Interview', 'triggerElement' => $triggerElement),
172 array('entity' => 'Activity', 'subEntity' => 'Meeting', 'triggerElement' => $triggerElement)
175 $pageUrl = array('url' => 'activity', 'args' => 'reset=1&action=add&context=standalone');
176 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
181 * @param null $xpathPrefix
183 function VerifyTabularData($expected, $xpathPrefix = NULL) {
184 foreach ($expected as $label => $value) {
185 $this->waitForElementPresent("xpath=//table/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td/span");
186 $this->verifyText("xpath=//table/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td/span", preg_quote($value), 'In line ' . __LINE__
);