Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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 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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 | 27 | |
6a488035 | 28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
29 | |
30 | /** | |
31 | * Class WebTest_Generic_CheckDashboardTest | |
32 | */ | |
6a488035 TO |
33 | class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase { |
34 | ||
35 | protected function setUp() { | |
36 | parent::setUp(); | |
37 | } | |
38 | ||
00be9182 | 39 | public function testCheckDashboardElements() { |
6a488035 TO |
40 | |
41 | $this->webtestLogin(); | |
42 | ||
43 | $this->open($this->sboxPath . "civicrm"); | |
44 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
45 | $this->assertTrue($this->isElementPresent("link=Configure Your Dashboard")); | |
46 | ||
47 | // Test Activities widget enable and full screen. | |
48 | $this->_testActivityDashlet(); | |
49 | ||
50 | // More dashlet tests can be added here using the functions modeled below | |
51 | } | |
52 | ||
4cbe18b8 | 53 | /** |
100fef9d | 54 | * @param int $widgetConfigureID |
4cbe18b8 EM |
55 | * @param $widgetEnabledSelector |
56 | * @param $widgetTitle | |
57 | */ | |
00be9182 | 58 | public function _testAddDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle) { |
6a488035 | 59 | // Check if desired widget is already loaded on dashboard and remove it if it is so we can test adding it. |
efb29358 CW |
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 | |
6a488035 TO |
63 | sleep(10); |
64 | if ($this->isElementPresent($widgetEnabledSelector)) { | |
65 | $this->_testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle); | |
66 | }; | |
67 | $this->click("link=Configure Your Dashboard"); | |
68 | $this->waitForElementPresent("dashlets-header-col-0"); | |
69 | $this->mouseDownAt($widgetConfigureID, ""); | |
efb29358 CW |
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 | |
6a488035 TO |
73 | sleep(3); |
74 | $this->mouseMoveAt("existing-dashlets-col-1", ""); | |
efb29358 CW |
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 | |
6a488035 TO |
78 | sleep(3); |
79 | $this->mouseUpAt("existing-dashlets-col-1", ""); | |
efb29358 CW |
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 | |
6a488035 TO |
83 | sleep(3); |
84 | $this->click("link=Done"); | |
85 | $this->waitForElementPresent("link=Configure Your Dashboard"); | |
86 | $this->waitForTextPresent("$widgetTitle"); | |
87 | ||
88 | // click Full Screen icon and test full screen container | |
1ab787f1 | 89 | $this->waitForElementPresent("css=li#widget-2 a.fullscreen-icon"); |
6a488035 TO |
90 | $this->click("css=li#widget-2 a.fullscreen-icon"); |
91 | $this->waitForElementPresent("ui-id-1"); | |
44a0d8ea | 92 | $this->waitForTextPresent("$widgetTitle"); |
efb29358 CW |
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 | |
6a488035 | 96 | sleep(5); |
bf333c47 | 97 | $this->click("xpath=//button[@title='Close']"); |
6a488035 TO |
98 | } |
99 | ||
4cbe18b8 | 100 | /** |
100fef9d | 101 | * @param int $widgetConfigureID |
4cbe18b8 EM |
102 | * @param $widgetEnabledSelector |
103 | */ | |
00be9182 | 104 | public function _testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector) { |
6a488035 TO |
105 | $this->click("link=Configure Your Dashboard"); |
106 | $this->waitForElementPresent("dashlets-header-col-0"); | |
107 | $this->mouseDownAt("{$widgetConfigureID}", ""); | |
efb29358 CW |
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 | |
6a488035 TO |
111 | sleep(1); |
112 | $this->mouseMoveAt("available-dashlets", ""); | |
efb29358 CW |
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 | |
6a488035 TO |
116 | sleep(1); |
117 | $this->mouseUpAt("available-dashlets", ""); | |
efb29358 CW |
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 | |
6a488035 TO |
121 | sleep(1); |
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) | |
efb29358 CW |
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 | |
6a488035 TO |
128 | sleep(10); |
129 | $this->assertFalse($this->isElementPresent($widgetEnabledSelector)); | |
130 | } | |
131 | ||
00be9182 | 132 | public function _testActivityDashlet() { |
6a488035 TO |
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 = "2-0"; | |
138 | ||
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); | |
144 | ||
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 | |
bf333c47 | 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']"); |
6a488035 TO |
149 | } |
150 | else { | |
151 | // click 'Delete Activity' link | |
e390a377 | 152 | $this->click("//table[@class='contact-activity-selector-dashlet crm-ajax-table dataTable no-footer']/tbody/tr[1]/td[8]/span//a[text()='Delete']"); |
6a488035 TO |
153 | } |
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. | |
161 | // Issue filed: CRM- | |
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"); | |
166 | ||
167 | // cleanup by removing the widget | |
168 | $this->_testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector); | |
169 | } | |
96025800 | 170 | |
6a488035 | 171 | } |