Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Activity_ContactContextAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Activity_ContactContextAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testContactContextActivityAdd() { |
f75b8467 | 39 | $this->markTestSkipped('Skipping for now as it works fine locally.'); |
6a488035 TO |
40 | $this->webtestLogin(); |
41 | ||
42 | // Adding Adding contact with randomized first name for test testContactContextActivityAdd | |
43 | // We're using Quick Add block on the main page for this. | |
44 | $firstName1 = substr(sha1(rand()), 0, 7); | |
45 | $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name"); | |
46 | $firstName2 = substr(sha1(rand()), 0, 7); | |
47 | $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); | |
6a488035 TO |
48 | $this->click("css=li#tab_activity a"); |
49 | ||
50 | // waiting for the activity dropdown to show up | |
51 | $this->waitForElementPresent("other_activity"); | |
52 | ||
53 | // Select the activity type from the activity dropdown | |
54 | $this->select("other_activity", "label=Meeting"); | |
55 | ||
6a488035 TO |
56 | // button at the end of this page to show up, to make sure it's fully loaded. |
57 | $this->waitForElementPresent("_qf_Activity_upload"); | |
58 | ||
6a488035 | 59 | // ...and verifying if the page contains properly formatted display name for chosen contact. |
cba9346d | 60 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", 'Anderson, ' . $firstName2); |
6a488035 TO |
61 | |
62 | // Now we're filling the "Assigned To" field. | |
63 | // Typing contact's name into the field (using typeKeys(), not type()!)... | |
cba9346d | 64 | $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input"); |
65 | $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " "); | |
66 | $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); | |
67 | $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); | |
6a488035 TO |
68 | |
69 | // ...waiting for drop down with results to show up... | |
cba9346d | 70 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
71 | |
72 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
cba9346d | 73 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
74 | |
75 | // ...again, waiting for the box with contact name to show up... | |
6c6e6187 | 76 | $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$firstName1"); |
6a488035 TO |
77 | |
78 | // ...and verifying if the page contains properly formatted display name for chosen contact. | |
cba9346d | 79 | $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Summerson, $firstName1", 'Contact not found in line ' . __LINE__); |
6a488035 | 80 | |
6a488035 TO |
81 | // Putting the contents into subject field - assigning the text to variable, it'll come in handy later |
82 | $subject = "This is subject of test activity being added through activity tab of contact summary screen."; | |
83 | // For simple input fields we can use field id as selector | |
84 | $this->type("subject", $subject); | |
85 | $this->type("location", "Some location needs to be put in this field."); | |
86 | ||
87 | // Choosing the Date. | |
88 | // Please note that we don't want to put in fixed date, since | |
89 | // we want this test to work in the future and not fail because | |
90 | // of date being set in the past. Therefore, using helper webtestFillDateTime function. | |
91 | $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM'); | |
92 | ||
93 | // Setting duration. | |
94 | $this->type("duration", "30"); | |
95 | ||
96 | // Putting in details. | |
97 | $this->type("details", "Really brief details information."); | |
98 | ||
99 | // Making sure that status is set to Scheduled (using value, not label). | |
100 | $this->select("status_id", "value=1"); | |
101 | ||
102 | // Setting priority. | |
103 | $this->select("priority_id", "value=1"); | |
104 | ||
105 | // Adding attachment | |
106 | // TODO TBD | |
107 | ||
108 | // Scheduling follow-up. | |
109 | $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header"); | |
110 | $this->select("followup_activity_type_id", "value=1"); | |
111 | $this->webtestFillDateTime('followup_date', '+2 months 10:00AM'); | |
112 | $this->type("followup_activity_subject", "This is subject of schedule follow-up activity"); | |
113 | ||
114 | // Clicking save. | |
115 | $this->click("_qf_Activity_upload"); | |
6a488035 TO |
116 | |
117 | // Is status message correct? | |
6c5f7368 | 118 | $this->waitForText('crm-notification-container', $subject); |
9fdcdf6f | 119 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[8]/span[1]/a[1][text()='View']"); |
6a488035 TO |
120 | |
121 | // click through to the Activity view screen | |
bfb4aadb | 122 | $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr//td/div[text()='$subject']/../../td[8]/span[1]/a[1][text()='View']"); |
6a488035 TO |
123 | $this->waitForElementPresent('_qf_Activity_cancel-bottom'); |
124 | ||
125 | // verify Activity created | |
126 | $this->webtestVerifyTabularData( | |
127 | array( | |
128 | 'Subject' => $subject, | |
129 | 'Location' => 'Some location needs to be put in this field.', | |
cba9346d | 130 | 'Activity Status' => 'Scheduled', |
6a488035 TO |
131 | 'Duration' => '30', |
132 | // Tough luck filling in WYSIWYG editor, so skipping verification for now. | |
133 | //'Details' => 'Really brief details information.', | |
134 | 'Priority' => 'Urgent', | |
135 | ), | |
136 | "/label" | |
137 | ); | |
138 | ||
139 | $this->webtestVerifyTabularData( | |
140 | array( | |
141 | 'With Contact' => "Anderson, {$firstName2}", | |
3bd48a28 | 142 | 'Assigned to' => "Summerson, {$firstName1}", |
cba9346d | 143 | ), |
144 | "/label" | |
6a488035 TO |
145 | ); |
146 | } | |
a679fd4d | 147 | |
00be9182 | 148 | public function testSeparateActivityForMultiTargetContacts() { |
a679fd4d RN |
149 | $this->webtestLogin(); |
150 | ||
151 | //creating contacts | |
152 | $firstName1 = substr(sha1(rand()), 0, 7); | |
153 | $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name"); | |
154 | $firstName2 = substr(sha1(rand()), 0, 7); | |
155 | $this->webtestAddContact($firstName2, "Andersonnn", $firstName2 . "@anderson.name"); | |
156 | $firstName3 = substr(sha1(rand()), 0, 7); | |
157 | $this->webtestAddContact($firstName3, "Anderson", $firstName3 . "@andersonnn.name"); | |
158 | ||
159 | $this->click("css=li#tab_activity a"); | |
160 | ||
161 | // waiting for the activity dropdown to show up | |
162 | $this->waitForElementPresent("other_activity"); | |
163 | ||
164 | // Select the activity type from the activity dropdown | |
165 | $this->select("other_activity", "label=Meeting"); | |
a679fd4d RN |
166 | |
167 | // ...and verifying if the page contains properly formatted display name for chosen contact. | |
cba9346d | 168 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", 'Anderson, ' . $firstName3, 'Contact not found in line ' . __LINE__); |
a679fd4d RN |
169 | |
170 | //filling the second target Contact | |
c543dff8 | 171 | $this->waitForAjaxContent(); |
cba9346d | 172 | $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input"); |
173 | $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " "); | |
174 | $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1); | |
175 | $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName1); | |
a679fd4d RN |
176 | |
177 | // ...waiting for drop down with results to show up... | |
cba9346d | 178 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
a679fd4d RN |
179 | |
180 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
cba9346d | 181 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
a679fd4d | 182 | |
a679fd4d | 183 | // ...and verifying if the page contains properly formatted display name for chosen contact. |
cba9346d | 184 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$firstName1", 'Contact not found in line ' . __LINE__); |
a679fd4d RN |
185 | |
186 | //filling the third target contact | |
c543dff8 | 187 | $this->waitForAjaxContent(); |
cba9346d | 188 | $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input"); |
189 | $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " "); | |
190 | $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName2); | |
191 | $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $firstName2); | |
a679fd4d RN |
192 | |
193 | // ...waiting for drop down with results to show up... | |
cba9346d | 194 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
a679fd4d RN |
195 | |
196 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
cba9346d | 197 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
a679fd4d | 198 | |
a679fd4d | 199 | // ...and verifying if the page contains properly formatted display name for chosen contact. |
cba9346d | 200 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", "$firstName2", 'Contact not found in line ' . __LINE__); |
a679fd4d RN |
201 | |
202 | //check the checkbox to create a separate activity for the selected target contacts | |
203 | $this->check('is_multi_activity'); | |
204 | ||
205 | $subject = "This is subject of test activity for creating a separate activity for contacts {$firstName1},{$firstName2} and {$firstName3}."; | |
206 | $this->type("subject", $subject); | |
b6708aeb | 207 | |
a679fd4d | 208 | $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM'); |
c543dff8 | 209 | $this->waitForAjaxContent(); |
a679fd4d RN |
210 | $this->select("status_id", "value=1"); |
211 | ||
212 | // Clicking save. | |
cba9346d | 213 | $this->click('_qf_Activity_upload'); |
a679fd4d RN |
214 | |
215 | // Is status message correct? | |
216 | $this->waitForText('crm-notification-container', $subject); | |
217 | ||
218 | //activity search page | |
219 | $this->openCiviPage('activity/search', 'reset=1'); | |
b6708aeb | 220 | |
a679fd4d | 221 | $this->type('activity_subject', $subject); |
b6708aeb | 222 | |
a679fd4d RN |
223 | $this->clickLink('_qf_Search_refresh'); |
224 | ||
86bfa4f6 | 225 | $targetContacts = array("Summerson, " . $firstName1, "Andersonnn, " . $firstName2, "Anderson, " . $firstName3); |
a679fd4d RN |
226 | |
227 | //check whether separate activities are created for the target contacts | |
228 | foreach ($targetContacts as $contact) { | |
229 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//tr/td[5]/a[text()='$contact']")); | |
230 | } | |
231 | } | |
96025800 | 232 | |
6a488035 | 233 | } |