3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Activity_StandaloneAddTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testStandaloneActivityAdd() {
36 $this->webtestLogin();
38 // Adding Anderson, Anthony and Summerson, Samuel for testStandaloneActivityAdd test
39 // We're using Quick Add block on the main page for this.
40 $firstName1 = substr(sha1(rand()), 0, 7);
41 $this->webtestAddContact("$firstName1", "Anderson", $firstName1 . "@anderson.com");
42 $firstName2 = substr(sha1(rand()), 0, 7);
43 $this->webtestAddContact("$firstName2", "Summerson", $firstName2 . "@summerson.com");
45 $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
47 // Select one of the options in Activity Type selector. Use option value, not label - since labels can be translated and test would fail
48 $this->select("activity_type_id", "value=1");
50 // We're filling in ajaxiefied "With Contact" field:
51 // 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)
52 // Typing contact's name into the field (using typeKeys(), not type()!)...
53 $this->click("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1");
54 $this->type("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1", "$firstName1");
55 $this->typeKeys("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1", "$firstName1");
57 // ...waiting for drop down with results to show up...
58 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
59 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
61 // ...need to use mouseDownAt on first result (which is a li element), click does not work
62 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
64 // ...again, waiting for the box with contact name to show up (span with delete token class indicates that it's present)...
65 $this->waitForElementPresent("css=tr.crm-activity-form-block-target_contact_id td ul li span.token-input-delete-token-facebook");
67 //..and verifying if the page contains properly formatted display name for chosen contact.
68 $this->assertElementContainsText('css=tr.crm-activity-form-block-target_contact_id td ul li.token-input-token-facebook', "Anderson, $firstName1", 'Contact not found in line ' . __LINE__
);
70 // Now we're doing the same for "Assigned To" field.
71 // Typing contact's name into the field (using typeKeys(), not type()!)...
72 $this->click("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id");
73 $this->type("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", "$firstName2");
74 $this->typeKeys("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", "$firstName2");
76 // ...waiting for drop down with results to show up...
77 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
78 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
80 //..need to use mouseDownAt on first result (which is a li element), click does not work
81 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
83 // ...again, waiting for the box with contact name to show up...
84 $this->waitForElementPresent("css=tr.crm-activity-form-block-assignee_contact_id td ul li span.token-input-delete-token-facebook");
86 // ...and verifying if the page contains properly formatted display name for chosen contact.
87 $this->assertElementContainsText('css=tr.crm-activity-form-block-assignee_contact_id td ul li.token-input-token-facebook', "Summerson, $firstName2", 'Contact not found in line ' . __LINE__
);
89 // Since we're here, let's check of screen help is being displayed properly
90 $this->assertElementContainsText('css=tr.crm-activity-form-block-assignee_contact_id td span.description', 'You can optionally assign this activity to someone', 'Help text is missing.');
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 $this->click("css=.crm-activity-form-block-attachment div.crm-accordion-header");
120 //FIX ME: need to fix file uploading
121 //$this->waitForElementPresent("attachFile_1");
122 //$filePath = $this->webtestAttachFile( "attachFile_1" );
124 // Scheduling follow-up.
125 $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
126 $this->select("followup_activity_type_id", "value=1");
127 $this->webtestFillDateTime('followup_date', '+2 months 10:00AM');
128 $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
131 $this->click("_qf_Activity_upload");
132 $this->waitForPageToLoad($this->getTimeoutMsec());
134 // Is status message correct?
135 $this->assertTrue($this->isTextPresent("Activity '$subject' has been saved."), "Status message didn't show up after saving!");
137 $this->openCiviPage("activity/search", "reset=1", "_qf_Search_refresh");
139 $this->type("sort_name", $firstName1);
140 $this->click("_qf_Search_refresh");
141 $this->waitForElementPresent("_qf_Search_next_print");
143 $this->click("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[3]/td[9]/span/a[text()='View']");
144 $this->waitForElementPresent("_qf_Activity_cancel-bottom");
146 $this->webtestVerifyTabularData(
148 'Subject' => $subject,
149 'Location' => $location,
150 'Status' => 'Scheduled',
152 // Tough luck filling in WYSIWYG editor, so skipping verification for now.
153 //'Details' => 'Really brief details information.',
154 'Priority' => 'Urgent',
155 //'Current Attachment(s)' => basename($filePath)
160 $this->webtestVerifyTabularData(
162 'With Contact' => "Anderson, {$firstName1}",
163 'Assigned To' => "Summerson, {$firstName2}",