21
21
*/
22
22
describe ( 'Tests' , function ( ) {
23
23
beforeEach ( function ( ) {
24
- browser . get ( '/' ) ;
25
24
browser . ignoreSynchronization = true ;
26
25
} ) ;
27
26
afterEach ( function ( ) {
@@ -46,116 +45,140 @@ describe('Tests', function() {
46
45
47
46
//Apps tab
48
47
49
- describe ( 'When I navigate to "/tasks /apps" (default installation)' , function ( ) {
48
+ describe ( 'When I navigate to "/apps /apps" (default installation)' , function ( ) {
50
49
51
- it ( 'First delete all Apps' , function ( ) {
52
- browser . get ( '#/apps/apps' ) . then ( function ( ) {
53
- browser . driver . sleep ( 2000 ) ;
54
- var selectAllAppsCheckbox = element ( by . css ( '#selectAllAppsCheckbox' ) ) ;
55
-
56
- selectAllAppsCheckbox . click ( ) . then (
57
- function ( value ) {
58
- //console.log(value, value);
59
- //browser.driver.sleep(4000);
60
- var unregisterSelectedAppsButton = element ( by . css ( '#unregisterSelectedAppsButton' ) ) ;
61
-
62
- unregisterSelectedAppsButton . getAttribute ( 'disabled' ) . then ( function ( disabled ) {
63
- if ( ! disabled ) {
64
- unregisterSelectedAppsButton . click ( ) . then ( function ( value ) {
65
- browser . driver . sleep ( 2000 ) ;
66
- var unregisterAllAppsConfirmationButton = element ( by . css ( '#unregisterAllAppsConfirmationButton' ) ) ;
67
- unregisterAllAppsConfirmationButton . click ( ) ;
50
+ function waitForElement ( locator ) {
51
+ return browser . wait ( function ( ) {
52
+ return browser . isElementPresent ( locator ) . then ( function ( result ) {
53
+ if ( result ) {
54
+ return result ;
55
+ }
56
+ } ) ;
57
+ } , 10000 ) . thenCatch ( function ( err ) {
58
+ fail ( "Element '" + locator + "' was not found: ERROR is -" + err ) ;
59
+ } ) ;
60
+ }
61
+
62
+ it ( 'First delete all Apps if apps are listed' , function ( ) {
63
+ browser . get ( '#/apps/apps' ) . then ( function ( ) {
64
+ waitForElement ( element ( by . css ( '#dataflow-apps' ) ) ) . then ( function ( ) {
65
+ element . all ( by . css ( '#dataflow-apps table tbody tr' ) ) . count ( ) . then ( function ( value ) {
66
+ if ( value > 1 ) {
67
+ console . log ( 'removing ' + ( value - 1 ) + ' application(s).' ) ;
68
+ waitForElement ( element ( by . css ( '#selectAllAppsCheckbox' ) ) ) . then ( function ( ) {
69
+ var selectAllAppsCheckbox = element ( by . css ( '#selectAllAppsCheckbox' ) ) ;
70
+ browser . driver . sleep ( 5000 ) ;
71
+ selectAllAppsCheckbox . click ( ) . then ( function ( value ) {
72
+ waitForElement ( element ( by . css ( '#unregisterSelectedAppsButton' ) ) ) . then ( function ( ) {
73
+ var unregisterSelectedAppsButton = element ( by . css ( '#unregisterSelectedAppsButton' ) ) ;
74
+ unregisterSelectedAppsButton . getAttribute ( 'disabled' ) . then ( function ( disabled ) {
75
+ if ( ! disabled ) {
76
+ unregisterSelectedAppsButton . click ( ) . then ( function ( value ) {
77
+ waitForElement ( element ( by . css ( '#unregisterAllAppsConfirmationButton' ) ) ) . then ( function ( ) {
78
+ var unregisterAllAppsConfirmationButton = element ( by . css ( '#unregisterAllAppsConfirmationButton' ) ) ;
79
+ unregisterAllAppsConfirmationButton . click ( ) ;
80
+ } ) ;
81
+ } ) ;
82
+ }
83
+ } ) ;
84
+ } ) ;
68
85
} ) ;
69
- }
70
- } ) ;
86
+ } ) ;
87
+ }
71
88
} ) ;
89
+ } ) ;
72
90
} ) ;
73
91
} ) ;
92
+ } ) ;
74
93
75
- it ( 'there should be 3 tabs of which one is active' , function ( ) {
76
- browser . get ( '#/tasks/apps' ) . then ( function ( ) {
77
- expect ( element . all ( by . css ( '#dataflow-tasks ul.nav-tabs li' ) ) . count ( ) ) . toEqual ( 3 ) ;
78
- expect ( element . all ( by . css ( '#dataflow-tasks ul.nav-tabs li.active' ) ) . count ( ) ) . toEqual ( 1 ) ;
79
- } ) ;
80
- } ) ;
81
- it ( 'the active tab should be labelled "Apps"' , function ( ) {
82
- browser . get ( '#/tasks/apps' ) . then ( function ( ) {
83
- expect ( element ( by . css ( '#dataflow-tasks ul li.active a' ) ) . getText ( ) ) . toEqual ( 'Apps' ) ;
84
- } ) ;
85
- } ) ;
86
- it ( 'there should be 0 task modules being listed' , function ( ) {
87
- browser . get ( '#/tasks/apps' ) . then ( function ( ) {
88
- browser . driver . sleep ( 2000 ) ;
89
- expect ( element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . count ( ) ) . toBe ( 0 ) ;
90
- } ) ;
91
- } ) ;
94
+ //Tasks tab
95
+
96
+ describe ( 'When I navigate to "/tasks/apps" (default installation)' , function ( ) {
92
97
it ( 'We need to install the timestamp task' , function ( ) {
93
98
browser . get ( '#/apps/apps' ) . then ( function ( ) {
94
- browser . driver . sleep ( 3000 ) ;
99
+ browser . driver . sleep ( 8000 ) ;
100
+
95
101
var registerAppsButton = element ( by . css ( '#registerAppsButton' ) ) ;
96
- registerAppsButton . click ( ) . then ( function ( value ) {
97
- browser . driver . sleep ( 1000 ) ;
98
- var nameInputField = element ( by . css ( '#name_0' ) ) ;
99
- var typeSelectBox = element ( by . css ( '#type_0' ) ) ;
100
- var uriInputField = element ( by . css ( '#uri_0' ) ) ;
101
102
102
- nameInputField . clear ( ) ;
103
- nameInputField . sendKeys ( 'timestamp' ) ;
103
+ browser . wait ( protractor . ExpectedConditions . elementToBeClickable ( registerAppsButton ) , 10000 )
104
+ . then ( function ( ) {
105
+ browser . driver . sleep ( 2000 ) ;
106
+ registerAppsButton . click ( ) . then ( function ( ) {
107
+ browser . driver . sleep ( 1000 ) ;
108
+ var nameInputField = element ( by . css ( '#name_0' ) ) ;
109
+ var typeSelectBox = element ( by . css ( '#type_0' ) ) ;
110
+ var uriInputField = element ( by . css ( '#uri_0' ) ) ;
104
111
105
- typeSelectBox . element ( by . cssContainingText ( 'option' , 'Task' ) ) . click ( ) ;
112
+ nameInputField . clear ( ) ;
113
+ nameInputField . sendKeys ( 'timestamp' ) ;
106
114
107
- uriInputField . clear ( ) ;
108
- uriInputField . sendKeys ( 'maven://org.springframework.cloud.task.app:timestamp-task:1.0.0.BUILD-SNAPSHOT' ) ;
115
+ typeSelectBox . element ( by . cssContainingText ( 'option' , 'Task' ) ) . click ( ) ;
109
116
110
- browser . driver . sleep ( 2000 ) ;
111
- element ( by . css ( '#submit-button' ) ) . click ( )
112
- browser . driver . sleep ( 2000 ) ;
113
- } ) ;
117
+ uriInputField . clear ( ) ;
118
+ uriInputField . sendKeys ( 'maven://org.springframework.cloud.task.app:timestamp-task:1.0.0.BUILD-SNAPSHOT' ) ;
119
+
120
+ browser . driver . sleep ( 2000 ) ;
121
+ element ( by . css ( '#submit-button' ) ) . click ( )
122
+ browser . driver . sleep ( 2000 ) ;
123
+ } ) ;
124
+ } ) ;
125
+ } ) ;
126
+ } ) ;
127
+ it ( 'there should be 3 tabs of which one is active' , function ( ) {
128
+ browser . get ( '#/tasks/apps' ) . then ( function ( ) {
129
+ expect ( element . all ( by . css ( '#dataflow-tasks ul.nav-tabs li' ) ) . count ( ) ) . toEqual ( 3 ) ;
130
+ expect ( element . all ( by . css ( '#dataflow-tasks ul.nav-tabs li.active' ) ) . count ( ) ) . toEqual ( 1 ) ;
114
131
} ) ;
115
132
} ) ;
133
+ it ( 'the active tab should be labelled "Apps"' , function ( ) {
134
+ expect ( element ( by . css ( '#dataflow-tasks ul li.active a' ) ) . getText ( ) ) . toEqual ( 'Apps' ) ;
135
+ } ) ;
136
+ it ( 'there should be 1 task modules being listed' , function ( ) {
137
+ expect ( element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . count ( ) ) . toBe ( 1 ) ;
138
+ } ) ;
116
139
it ( 'there should a task app named timestamp' , function ( ) {
117
140
browser . get ( '#/tasks/apps' ) ;
118
141
browser . driver . sleep ( 2000 ) ;
119
142
// Check timestamp on the list
120
- expect ( element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . filter ( function ( e ) {
121
- return e . all ( by . css ( 'td:nth-child(1)' ) ) . getText ( ) . then ( function ( text ) {
122
- return ( '' + text === 'timestamp' ) ;
123
- } ) ;
124
- } ) . count ( ) ) . toEqual ( 1 ) ;
143
+ expect ( element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . filter ( function ( e ) {
144
+ return e . all ( by . css ( 'td:nth-child(1)' ) ) . getText ( ) . then ( function ( text ) {
145
+ return ( '' + text === 'timestamp' ) ;
146
+ } ) ;
147
+ } ) . count ( ) ) . toEqual ( 1 ) ;
125
148
} ) ;
126
149
it ( 'When I click on the Create Definition button for module timestamp, ' +
127
150
'the page should redirect to /tasks/apps/timestamp/create-definition' , function ( ) {
128
151
browser . get ( '#/tasks/apps' ) . then ( function ( ) {
129
- browser . sleep ( 3000 ) ;
152
+ browser . driver . sleep ( 6000 ) ;
130
153
expect ( element ( by . css ( '#dataflow-tasks table tbody tr td:nth-child(3) button' ) ) . getAttribute ( 'title' ) ) . toMatch ( 'Create Definition' ) ;
131
154
132
155
// Click create definition button in the timestamp row
133
- element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . filter ( function ( e ) {
134
- return e . all ( by . css ( 'td:nth-child(1)' ) ) . getText ( ) . then ( function ( text ) {
135
- return ( '' + text === 'timestamp' ) ;
136
- } ) ;
137
- } ) . first ( ) . all ( by . css ( 'td:nth-child(3) button' ) ) . click ( ) ;
156
+ element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . filter ( function ( e ) {
157
+ return e . all ( by . css ( 'td:nth-child(1)' ) ) . getText ( ) . then ( function ( text ) {
158
+ return ( '' + text === 'timestamp' ) ;
159
+ } ) ;
160
+ } ) . first ( ) . all ( by . css ( 'td:nth-child(3) button' ) ) . click ( ) ;
138
161
139
- browser . sleep ( 2000 ) ;
162
+ browser . driver . sleep ( 2000 ) ;
140
163
expect ( browser . getCurrentUrl ( ) ) . toContain ( '/tasks/apps/timestamp/create-definition' ) ;
141
164
} ) ;
142
165
} ) ;
143
166
it ( 'When I click on the Details button for app timestamp, ' +
144
167
'the page should redirect to /tasks/apps/timestamp' , function ( ) {
145
168
browser . get ( '#/tasks/apps' ) . then ( function ( ) {
146
169
147
- browser . sleep ( 2000 ) ;
170
+ browser . driver . sleep ( 9000 ) ;
148
171
149
172
expect ( element ( by . css ( '#dataflow-tasks table tbody tr:nth-child(1) td:nth-child(4) button' ) ) . getAttribute ( 'title' ) ) . toMatch ( 'Details' ) ;
150
- // element(by.css('#dataflow-tasks table tbody tr:nth-child(6) td:nth-child(4) button')).click();
151
- // Click details button in the timestamp row
152
- element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . filter ( function ( e ) {
173
+ // element(by.css('#dataflow-tasks table tbody tr:nth-child(6) td:nth-child(4) button')).click();
174
+ // Click details button in the timestamp row
175
+ element . all ( by . css ( '#dataflow-tasks table tbody tr' ) ) . filter ( function ( e ) {
153
176
return e . all ( by . css ( 'td:nth-child(1)' ) ) . getText ( ) . then ( function ( text ) {
154
177
return ( '' + text === 'timestamp' ) ;
155
178
} ) ;
156
179
} ) . first ( ) . all ( by . css ( 'td:nth-child(4) button' ) ) . click ( ) ;
157
-
158
- browser . sleep ( 2000 ) ;
180
+
181
+ browser . driver . sleep ( 2000 ) ;
159
182
expect ( browser . getCurrentUrl ( ) ) . toContain ( '/tasks/apps/timestamp' ) ;
160
183
} ) ;
161
184
} ) ;
@@ -166,11 +189,11 @@ describe('Tests', function() {
166
189
describe ( 'When I navigate to "/tasks/definitions"' , function ( ) {
167
190
it ( 'there should be 3 tabs of which one is active' , function ( ) {
168
191
browser . get ( '#/tasks/definitions' ) ;
192
+ browser . driver . sleep ( 4000 ) ;
169
193
expect ( element . all ( by . css ( '#dataflow-tasks ul li' ) ) . count ( ) ) . toEqual ( 3 ) ;
170
194
expect ( element . all ( by . css ( '#dataflow-tasks ul li.active' ) ) . count ( ) ) . toEqual ( 1 ) ;
171
195
} ) ;
172
196
it ( 'the active tab should be labelled "Definitions"' , function ( ) {
173
- browser . get ( '#/tasks/definitions' ) ;
174
197
expect ( element ( by . css ( '#dataflow-tasks ul li.active a' ) ) . getText ( ) ) . toEqual ( 'Definitions' ) ;
175
198
} ) ;
176
199
} ) ;
@@ -180,11 +203,11 @@ describe('Tests', function() {
180
203
describe ( 'When I navigate to "/jobs/executions"' , function ( ) {
181
204
it ( 'there should be 1 tab which is active' , function ( ) {
182
205
browser . get ( '#/jobs/executions' ) ;
206
+ browser . driver . sleep ( 4000 ) ;
183
207
expect ( element . all ( by . css ( '#dataflow-jobs ul li' ) ) . count ( ) ) . toEqual ( 1 ) ;
184
208
expect ( element . all ( by . css ( '#dataflow-jobs ul li.active' ) ) . count ( ) ) . toEqual ( 1 ) ;
185
209
} ) ;
186
210
it ( 'the active tab should be labelled "Executions"' , function ( ) {
187
- browser . get ( '#/jobs/executions' ) ;
188
211
expect ( element ( by . css ( '#dataflow-jobs ul li.active a' ) ) . getText ( ) ) . toEqual ( 'Executions' ) ;
189
212
} ) ;
190
213
} ) ;
@@ -194,6 +217,7 @@ describe('Tests', function() {
194
217
describe ( 'When I navigate to "/#/about"' , function ( ) {
195
218
it ( 'the main header should be labelled "About"' , function ( ) {
196
219
browser . get ( '#/about' ) ;
220
+ browser . driver . sleep ( 4000 ) ;
197
221
expect ( element ( by . css ( '#dataflow-content h1' ) ) . getText ( ) ) . toEqual ( 'About' ) ;
198
222
} ) ;
199
223
} ) ;
0 commit comments