3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
31 * Class WebTest_Generic_CheckDashboardTest
33 class WebTest_Generic_CheckDashboardTest
extends CiviSeleniumTestCase
{
35 protected function setUp() {
39 public function testCheckDashboardElements() {
41 $this->webtestLogin();
43 $this->open($this->sboxPath
. "civicrm");
44 $this->waitForPageToLoad($this->getTimeoutMsec());
45 $this->assertTrue($this->isElementPresent("link=Configure Your Dashboard"));
47 // Test Activities widget enable and full screen.
48 $this->_testActivityDashlet();
50 // More dashlet tests can be added here using the functions modeled below
54 * @param int $widgetConfigureID
55 * @param $widgetEnabledSelector
58 public function _testAddDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle) {
59 // Check if desired widget is already loaded on dashboard and remove it if it is so we can test adding it.
60 // Because it tends to cause problems, all uses of sleep() must be justified in comments
61 // Sleep should never be used for wait for anything to load from the server
62 // Justification for this instance: FIXME
64 if ($this->isElementPresent($widgetEnabledSelector)) {
65 $this->_testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle);
67 $this->click("link=Configure Your Dashboard");
68 $this->waitForElementPresent("dashlets-header-col-0");
69 $this->mouseDownAt($widgetConfigureID, "");
70 // Because it tends to cause problems, all uses of sleep() must be justified in comments
71 // Sleep should never be used for wait for anything to load from the server
72 // Justification for this instance: FIXME
74 $this->mouseMoveAt("existing-dashlets-col-1", "");
75 // Because it tends to cause problems, all uses of sleep() must be justified in comments
76 // Sleep should never be used for wait for anything to load from the server
77 // Justification for this instance: FIXME
79 $this->mouseUpAt("existing-dashlets-col-1", "");
80 // Because it tends to cause problems, all uses of sleep() must be justified in comments
81 // Sleep should never be used for wait for anything to load from the server
82 // Justification for this instance: FIXME
84 $this->click("link=Done");
85 $this->waitForElementPresent("link=Configure Your Dashboard");
86 $this->waitForTextPresent("$widgetTitle");
88 // click Full Screen icon and test full screen container
89 $this->waitForElementPresent("css=li#widget-3 a.fa-expand");
90 $this->click("css=li#widget-3 a.fa-expand");
91 $this->waitForElementPresent("ui-id-1");
92 $this->waitForTextPresent("$widgetTitle");
93 // Because it tends to cause problems, all uses of sleep() must be justified in comments
94 // Sleep should never be used for wait for anything to load from the server
95 // Justification for this instance: FIXME
97 $this->click("xpath=//button[@title='Close']");
101 * @param int $widgetConfigureID
102 * @param $widgetEnabledSelector
104 public function _testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector) {
105 $this->click("link=Configure Your Dashboard");
106 $this->waitForElementPresent("dashlets-header-col-0");
107 $this->mouseDownAt("{$widgetConfigureID}", "");
108 // Because it tends to cause problems, all uses of sleep() must be justified in comments
109 // Sleep should never be used for wait for anything to load from the server
110 // Justification for this instance: FIXME
112 $this->mouseMoveAt("available-dashlets", "");
113 // Because it tends to cause problems, all uses of sleep() must be justified in comments
114 // Sleep should never be used for wait for anything to load from the server
115 // Justification for this instance: FIXME
117 $this->mouseUpAt("available-dashlets", "");
118 // Because it tends to cause problems, all uses of sleep() must be justified in comments
119 // Sleep should never be used for wait for anything to load from the server
120 // Justification for this instance: FIXME
122 $this->click("link=Done");
123 $this->waitForElementPresent("link=Configure Your Dashboard");
124 // giving time for activity widget to load (and make sure it did NOT)
125 // Because it tends to cause problems, all uses of sleep() must be justified in comments
126 // Sleep should never be used for wait for anything to load from the server
127 // Justification for this instance: FIXME
129 $this->assertFalse($this->isElementPresent($widgetEnabledSelector));
132 public function _testActivityDashlet() {
133 // Add an activity that will show up in the widget
134 $this->WebtestAddActivity();
135 $widgetTitle = "Activities";
136 $widgetEnabledSelector = "contact-activity-selector-dashlet_wrapper";
137 $widgetConfigureID = "3-0";
139 // now add the widget
140 $this->open($this->sboxPath
. "civicrm");
141 $this->waitForPageToLoad($this->getTimeoutMsec());
142 $this->waitForTextPresent("Configure Your Dashboard");
143 $this->_testAddDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle);
145 // If CiviCase enabled, click 'more' link for context menu pop-up in the widget selector
146 if ($this->isElementPresent("//table[@id='contact-activity-selector-dashlet']/tbody/tr[1]/td[8]/span[text()='more ']")) {
147 // click 'Delete Activity' link
148 $this->click("//table[@class='contact-activity-selector-dashlet dataTable no-footer']/tbody/tr[1]/td[8]/span[text()='more ']/ul/li[2]/a[text()='Delete']");
151 // click 'Delete Activity' link
152 $this->click("//table[@class='contact-activity-selector-dashlet crm-ajax-table dataTable no-footer']/tbody/tr[1]/td[8]/span//a[text()='Delete']");
154 $this->waitForPageToLoad($this->getTimeoutMsec());
155 $this->waitForElementPresent("_qf_Activity_next-bottom");
156 $this->assertTrue($this->isTextPresent("Are you sure you want to delete"));
157 $this->click("_qf_Activity_next-bottom");
158 $this->waitForPageToLoad($this->getTimeoutMsec());
159 $this->assertTrue($this->isTextPresent("Selected Activity has been deleted successfully."));
160 // FIXMED: Currently there's a bug, dashboard context is ignored after delete so we should already be back on home dash.
162 // $this->assertTrue($this->isTextPresent("Configure Your Dashboard");
163 $this->open($this->sboxPath
. "civicrm");
164 $this->waitForPageToLoad($this->getTimeoutMsec());
165 $this->waitForTextPresent("Configure Your Dashboard");
167 // cleanup by removing the widget
168 $this->_testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector);