Merge pull request #2927 from pratik-joshi/CRM-14269
[civicrm-core.git] / tests / phpunit / WebTest / Generic / CheckActivityTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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. |
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
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Generic_CheckActivityTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testCheckDashboardElements() {
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
37
38 // Adding contact with randomized first name
39 // We're using Quick Add block on the main page for this.
40 $contactFirstName1 = substr(sha1(rand()), 0, 7);
41 $this->webtestAddContact($contactFirstName1, "Devis", TRUE);
42
43 // Adding another contact with randomized first name
44 // We're using Quick Add block on the main page for this.
45 $contactFirstName2 = substr(sha1(rand()), 0, 7);
46 $this->webtestAddContact($contactFirstName2, "Anderson", TRUE);
47 $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload");
48
49 $this->select("activity_type_id", "label=Meeting");
50
51 $this->click("xpath=//div[@id='s2id_target_contact_id']/ul/li/input");
52 $this->keyDown("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", " ");
53 $this->type("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contactFirstName1);
54 $this->typeKeys("xpath=//div[@id='s2id_target_contact_id']/ul/li/input", $contactFirstName1);
55
56 // ...waiting for drop down with results to show up...
57 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
58
59 // ...need to use mouseDownAt on first result (which is a li element), click does not work
60 $this->clickAt("xpath=//div[@class='select2-result-label']");
61
62 // ...again, waiting for the box with contact name to show up (span with delete token class indicates that it's present)...
63 $this->waitForText("xpath=//div[@id='s2id_target_contact_id']","$contactFirstName1");
64
65 // Now we're doing the same for "Assigned To" field.
66 // Typing contact's name into the field (using typeKeys(), not type()!)...
67 $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input");
68 $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " ");
69 $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contactFirstName2);
70 $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $contactFirstName2);
71
72 // ...waiting for drop down with results to show up...
73 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
74
75 //..need to use mouseDownAt on first result (which is a li element), click does not work
76 $this->clickAt("xpath=//div[@class='select2-result-label']");
77
78 // ...again, waiting for the box with contact name to show up...
79 $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']","$contactFirstName2");
80 }
81 }
82