Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Activity_StandaloneAddTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testStandaloneActivityAdd() { | |
6a488035 TO |
35 | $this->webtestLogin(); |
36 | ||
37 | // Adding Anderson, Anthony and Summerson, Samuel for testStandaloneActivityAdd test | |
38 | // We're using Quick Add block on the main page for this. | |
39 | $firstName1 = substr(sha1(rand()), 0, 7); | |
40 | $this->webtestAddContact("$firstName1", "Anderson", $firstName1 . "@anderson.com"); | |
41 | $firstName2 = substr(sha1(rand()), 0, 7); | |
42 | $this->webtestAddContact("$firstName2", "Summerson", $firstName2 . "@summerson.com"); | |
43 | ||
bb21371e | 44 | $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload"); |
6a488035 | 45 | |
6a488035 TO |
46 | // Select one of the options in Activity Type selector. Use option value, not label - since labels can be translated and test would fail |
47 | $this->select("activity_type_id", "value=1"); | |
48 | ||
49 | // We're filling in ajaxiefied "With Contact" field: | |
50 | // 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) | |
51 | // Typing contact's name into the field (using typeKeys(), not type()!)... | |
52 | $this->click("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1"); | |
53 | $this->type("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1", "$firstName1"); | |
54 | $this->typeKeys("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1", "$firstName1"); | |
55 | ||
56 | // ...waiting for drop down with results to show up... | |
57 | $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); | |
58 | $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); | |
59 | ||
60 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
61 | $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); | |
62 | ||
63 | // ...again, waiting for the box with contact name to show up (span with delete token class indicates that it's present)... | |
64 | $this->waitForElementPresent("css=tr.crm-activity-form-block-target_contact_id td ul li span.token-input-delete-token-facebook"); | |
65 | ||
66 | //..and verifying if the page contains properly formatted display name for chosen contact. | |
bb21371e | 67 | $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__); |
6a488035 TO |
68 | |
69 | // Now we're doing the same for "Assigned To" field. | |
70 | // Typing contact's name into the field (using typeKeys(), not type()!)... | |
71 | $this->click("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id"); | |
72 | $this->type("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", "$firstName2"); | |
73 | $this->typeKeys("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", "$firstName2"); | |
74 | ||
75 | // ...waiting for drop down with results to show up... | |
76 | $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); | |
77 | $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); | |
78 | ||
79 | //..need to use mouseDownAt on first result (which is a li element), click does not work | |
80 | $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); | |
81 | ||
82 | // ...again, waiting for the box with contact name to show up... | |
83 | $this->waitForElementPresent("css=tr.crm-activity-form-block-assignee_contact_id td ul li span.token-input-delete-token-facebook"); | |
84 | ||
85 | // ...and verifying if the page contains properly formatted display name for chosen contact. | |
bb21371e | 86 | $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__); |
6a488035 TO |
87 | |
88 | // Since we're here, let's check of screen help is being displayed properly | |
bb21371e | 89 | $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.'); |
6a488035 TO |
90 | |
91 | // Putting the contents into subject field - assigning the text to variable, it'll come in handy later | |
92 | $subject = "This is subject of test activity being added through standalone screen."; | |
93 | // For simple input fields we can use field id as selector | |
94 | $this->type("subject", $subject); | |
95 | ||
96 | $location = 'Some location needs to be put in this field.'; | |
97 | $this->type("location", $location); | |
98 | ||
99 | // Choosing the Date. | |
100 | // Please note that we don't want to put in fixed date, since | |
101 | // we want this test to work in the future and not fail because | |
102 | // of date being set in the past. Therefore, using helper webtestFillDate function. | |
103 | $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM'); | |
104 | ||
105 | // Setting duration. | |
106 | $this->type("duration", "30"); | |
107 | ||
108 | // Putting in details. | |
109 | $this->type("details", "Really brief details information."); | |
110 | ||
111 | // Making sure that status is set to Scheduled (using value, not label). | |
112 | $this->select("status_id", "value=1"); | |
113 | ||
114 | // Setting priority. | |
115 | $this->select("priority_id", "value=1"); | |
116 | ||
117 | // Adding attachment | |
118 | $this->click("css=.crm-activity-form-block-attachment div.crm-accordion-header"); | |
119 | //FIX ME: need to fix file uploading | |
120 | //$this->waitForElementPresent("attachFile_1"); | |
121 | //$filePath = $this->webtestAttachFile( "attachFile_1" ); | |
122 | ||
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"); | |
128 | ||
129 | // Clicking save. | |
35c48e1a | 130 | $this->clickLink('_qf_Activity_upload'); |
6a488035 TO |
131 | |
132 | // Is status message correct? | |
35c48e1a | 133 | $this->waitForText('crm-notification-container', "Activity '$subject' has been saved."); |
6a488035 | 134 | |
bb21371e | 135 | $this->openCiviPage("activity/search", "reset=1", "_qf_Search_refresh"); |
6a488035 TO |
136 | |
137 | $this->type("sort_name", $firstName1); | |
138 | $this->click("_qf_Search_refresh"); | |
139 | $this->waitForElementPresent("_qf_Search_next_print"); | |
140 | ||
141 | $this->click("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[3]/td[9]/span/a[text()='View']"); | |
142 | $this->waitForElementPresent("_qf_Activity_cancel-bottom"); | |
143 | ||
144 | $this->webtestVerifyTabularData( | |
145 | array( | |
146 | 'Subject' => $subject, | |
147 | 'Location' => $location, | |
148 | 'Status' => 'Scheduled', | |
149 | 'Duration' => '30', | |
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) | |
154 | ), | |
155 | "/label" | |
156 | ); | |
157 | ||
158 | $this->webtestVerifyTabularData( | |
159 | array( | |
160 | 'With Contact' => "Anderson, {$firstName1}", | |
161 | 'Assigned To' => "Summerson, {$firstName2}", | |
162 | ) | |
163 | ); | |
164 | } | |
6a488035 | 165 | |
c4e6d4e8 PJ |
166 | function testAjaxCustomGroupLoad() { |
167 | $this->webtestLogin(); | |
168 | $triggerElement = array('name' => 'activity_type_id', 'type' => 'select'); | |
169 | $customSets = array( | |
170 | array('entity' => 'Activity', 'subEntity' => 'Interview', 'triggerElement' => $triggerElement), | |
171 | array('entity' => 'Activity', 'subEntity' => 'Meeting', 'triggerElement' => $triggerElement) | |
172 | ); | |
173 | ||
174 | $pageUrl = array('url' => 'activity', 'args' => 'reset=1&action=add&context=standalone'); | |
175 | $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl); | |
176 | } | |
177 | } |