28
28
class AppsManagementContext implements Context, ActorAwareInterface {
29
29
use ActorAware;
30
30
31
+ /**
32
+ * @return Locator
33
+ */
34
+ public static function appsList () {
35
+ return Locator::forThe ()->xpath ("//main[@id='app-content' or contains(@class, 'app-content')]//div[@id='apps-list'] " )->
36
+ describedAs ("Apps list in Apps Management " );
37
+ }
38
+
31
39
/**
32
40
* @return Locator
33
41
*/
34
42
public static function enableButtonForApp ($ app ) {
35
43
return Locator::forThe ()->button ("Enable " )->
36
- descendantOf (self ::rowForApp ($ app ))->
37
- describedAs ("Enable button in the app list for $ app " );
44
+ descendantOf (self ::rowForApp ($ app ))->
45
+ describedAs ("Enable button in the app list for $ app " );
46
+ }
47
+
48
+ /**
49
+ * @return Locator
50
+ */
51
+ public static function enableButtonForAnyApp () {
52
+ return Locator::forThe ()->button ("Enable " )->
53
+ descendantOf (self ::appsList ())->
54
+ describedAs ("Enable button in the app list for any app " );
38
55
}
39
56
40
57
/**
41
58
* @return Locator
42
59
*/
43
60
public static function downloadAndEnableButtonForApp ($ app ) {
44
61
return Locator::forThe ()->button ("Download and enable " )->
45
- descendantOf (self ::rowForApp ($ app ))->
46
- describedAs ("Download & enable button in the app list for $ app " );
62
+ descendantOf (self ::rowForApp ($ app ))->
63
+ describedAs ("Download & enable button in the app list for $ app " );
47
64
}
48
65
49
66
/**
50
67
* @return Locator
51
68
*/
52
69
public static function disableButtonForApp ($ app ) {
53
70
return Locator::forThe ()->button ("Disable " )->
54
- descendantOf (self ::rowForApp ($ app ))->
55
- describedAs ("Disable button in the app list for $ app " );
71
+ descendantOf (self ::rowForApp ($ app ))->
72
+ describedAs ("Disable button in the app list for $ app " );
73
+ }
74
+
75
+ /**
76
+ * @return Locator
77
+ */
78
+ public static function disableButtonForAnyApp () {
79
+ return Locator::forThe ()->button ("Disable " )->
80
+ descendantOf (self ::appsList ())->
81
+ describedAs ("Disable button in the app list for any app " );
56
82
}
57
83
58
84
/**
59
85
* @return Locator
60
86
*/
61
- public static function bundleButton ($ bundle ) {
62
- return Locator::forThe ()->xpath ("//main[@id='app-content' or contains(@class, 'app-content')]//div[@class='apps-header']/h2[normalize-space() = ' $ bundle']/input " )->
63
- describedAs ("Button to enable / disable bundles " );
87
+ public static function enableAllBundleButton ($ bundle ) {
88
+ return Locator::forThe ()->xpath ("//div[@class='apps-header']/h2[normalize-space() = ' $ bundle']/input[@value='Enable all'] " )->
89
+ descendantOf (self ::appsList ())->
90
+ describedAs ("Button to enable bundles " );
64
91
}
65
92
66
93
/**
67
94
* @return Locator
68
95
*/
69
96
public static function rowForApp ($ app ) {
70
- return Locator::forThe ()->xpath ("//main[@id='app-content' or contains(@class, 'app-content')]//div[@class='app-name'][normalize-space() = ' $ app']/.. " )->
97
+ return Locator::forThe ()->xpath ("//div[@class='app-name'][normalize-space() = ' $ app']/.. " )->
98
+ descendantOf (self ::appsList ())->
71
99
describedAs ("Row for app $ app in Apps Management " );
72
100
}
73
101
74
102
/**
75
103
* @return Locator
76
104
*/
77
105
public static function emptyAppList () {
78
- return Locator::forThe ()->xpath ("//main[@id='app-content' or contains(@class, 'app-content')]//div[@id='apps-list-empty'] " )->
79
- describedAs ("Empty apps list view " );
106
+ return Locator::forThe ()->xpath ("//div[@id='apps-list-empty'] " )->
107
+ descendantOf (self ::appsList ())->
108
+ describedAs ("Empty apps list view " );
80
109
}
81
110
82
111
/**
83
112
* @return Locator
84
113
*/
85
114
public static function appEntries () {
86
- return Locator::forThe ()->xpath ("//main[@id='app-content' or contains(@class, 'app-content')]//div[@class='section'] " )->
87
- describedAs ("Entries in apps list " );
115
+ return Locator::forThe ()->xpath ("//div[@class='section'] " )->
116
+ descendantOf (self ::appsList ())->
117
+ describedAs ("Entries in apps list " );
88
118
}
89
119
90
120
/**
91
121
* @return Locator
92
122
*/
93
123
public static function disabledAppEntries () {
94
124
return Locator::forThe ()->button ("Disable " )->
95
- descendantOf (self ::appEntries ())->
96
- describedAs ("Disable button in the app list " );
125
+ descendantOf (self ::appEntries ())->
126
+ describedAs ("Disable button in the app list " );
97
127
}
98
128
99
129
/**
100
130
* @return Locator
101
131
*/
102
132
public static function enabledAppEntries () {
103
133
return Locator::forThe ()->button ("Enable " )->
104
- descendantOf (self ::appEntries ())->
105
- describedAs ("Enable button in the app list " );
134
+ descendantOf (self ::appEntries ())->
135
+ describedAs ("Enable button in the app list " );
106
136
}
107
137
108
138
/**
109
139
* @return Locator
110
140
*/
111
141
public static function sidebar () {
112
142
return Locator::forThe ()->xpath ("//*[@id= \"app-sidebar \" or contains(@class, 'app-sidebar')] " )->
113
- describedAs ("Sidebar in apps management " );
143
+ describedAs ("Sidebar in apps management " );
114
144
}
115
145
116
146
@@ -140,15 +170,19 @@ public function iDisableTheApp($app) {
140
170
*/
141
171
public function iSeeThatTheAppHasBeenEnabled ($ app ) {
142
172
// TODO: Find a way to check if the enable button is removed
143
- $ this ->actor ->find (self ::disableButtonForApp ($ app ), 10 );
173
+ PHPUnit_Framework_Assert::assertTrue (
174
+ $ this ->actor ->find (self ::disableButtonForApp ($ app ), 10 )->isVisible ()
175
+ );
144
176
}
145
177
146
178
/**
147
179
* @Then I see that the :app app has been disabled
148
180
*/
149
181
public function iSeeThatTheAppHasBeenDisabled ($ app ) {
150
182
// TODO: Find a way to check if the disable button is removed
151
- $ this ->actor ->find (self ::enableButtonForApp ($ app ), 10 );
183
+ PHPUnit_Framework_Assert::assertTrue (
184
+ $ this ->actor ->find (self ::enableButtonForApp ($ app ), 10 )->isVisible ()
185
+ );
152
186
}
153
187
154
188
/**
@@ -164,7 +198,12 @@ public function iSeeThatThereAreNoAvailableUpdates() {
164
198
* @Then /^I see that there some apps listed from the app store$/
165
199
*/
166
200
public function iSeeThatThereSomeAppsListedFromTheAppStore () {
167
- WaitFor::elementToBeEventuallyShown ($ this ->actor , self ::appEntries (), 10 );
201
+ if (!WaitFor::elementToBeEventuallyShown (
202
+ $ this ->actor ,
203
+ self ::appEntries (),
204
+ $ timeout = 10 * $ this ->actor ->getFindTimeoutMultiplier ())) {
205
+ PHPUnit_Framework_Assert::fail ("The apps from the app store were not shown yet after $ timeout seconds " );
206
+ }
168
207
}
169
208
170
209
/**
@@ -178,38 +217,52 @@ public function iClickOnTheApp($app) {
178
217
* @Given /^I see that there are only disabled apps$/
179
218
*/
180
219
public function iSeeThatThereAreOnlyDisabledApps () {
181
- $ buttons = $ this ->actor ->getSession ()->getDriver ()->find ("//input[@value = 'Disable'] " );
182
- PHPUnit \Framework \Assert::assertEmpty ($ buttons , 'Found disabled apps ' );
220
+ try {
221
+ $ this ->actor ->find (self ::disableButtonForAnyApp (), 2 );
222
+
223
+ PHPUnit_Framework_Assert::fail ("Found enabled apps " );
224
+ } catch (NoSuchElementException $ exception ) {
225
+ }
183
226
}
184
227
185
228
/**
186
229
* @Given /^I see that there are only enabled apps$/
187
230
*/
188
231
public function iSeeThatThereAreOnlyEnabledApps () {
189
- $ buttons = $ this ->actor ->getSession ()->getDriver ()->find ("//input[@value = 'Enable'] " );
190
- PHPUnit \Framework \Assert::assertEmpty ($ buttons , 'Found disabled apps ' );
232
+ try {
233
+ $ this ->actor ->find (self ::enableButtonForAnyApp (), 2 );
234
+
235
+ PHPUnit_Framework_Assert::fail ("Found disabled apps " );
236
+ } catch (NoSuchElementException $ exception ) {
237
+ }
191
238
}
192
239
193
240
/**
194
241
* @Given /^I see the app bundles$/
195
242
*/
196
243
public function iSeeTheAppBundles () {
197
- $ this ->actor ->find (self ::rowForApp ('Auditing / Logging ' ), 2 );
198
- $ this ->actor ->find (self ::rowForApp ('LDAP user and group backend ' ), 2 );
244
+ PHPUnit_Framework_Assert::assertTrue (
245
+ $ this ->actor ->find (self ::rowForApp ('Auditing / Logging ' ), 2 )->isVisible ()
246
+ );
247
+ PHPUnit_Framework_Assert::assertTrue (
248
+ $ this ->actor ->find (self ::rowForApp ('LDAP user and group backend ' ), 2 )->isVisible ()
249
+ );
199
250
}
200
251
201
252
/**
202
253
* @When /^I enable all apps from the "([^"]*)"$/
203
254
*/
204
255
public function iEnableAllAppsFromThe ($ bundle ) {
205
- $ this ->actor ->find (self ::bundleButton ($ bundle ), 2 )->click ();
256
+ $ this ->actor ->find (self ::enableAllBundleButton ($ bundle ), 2 )->click ();
206
257
}
207
258
208
259
/**
209
260
* @Given /^I see that the "([^"]*)" is disabled$/
210
261
*/
211
262
public function iSeeThatTheIsDisabled ($ bundle ) {
212
- PHPUnit \Framework \Assert::assertEquals ('Enable all ' , $ this ->actor ->find (self ::bundleButton ($ bundle ))->getValue ());
263
+ PHPUnit_Framework_Assert::assertTrue (
264
+ $ this ->actor ->find (self ::enableAllBundleButton ($ bundle ), 2 )->isVisible ()
265
+ );
213
266
}
214
267
215
268
/**
0 commit comments