@@ -76,6 +76,16 @@ test('Can open Remove wizard and remove version from simple environment', async
76
76
. query ( true )
77
77
. reply ( 200 , environmentPathsData ) ;
78
78
79
+ const hostScope = nockInstance
80
+ . get ( hostURL )
81
+ . query ( true )
82
+ . reply ( 200 , affectedHostData ) ;
83
+
84
+ const activationKeysScope = nockInstance
85
+ . get ( activationKeyURL )
86
+ . query ( true )
87
+ . reply ( 200 , affectedActivationKeysData ) ;
88
+
79
89
const cvVersionRemoveParams = { id : 2 , environment_ids : [ 4 ] } ;
80
90
81
91
const versionRemovalScope = nockInstance
@@ -115,13 +125,19 @@ test('Can open Remove wizard and remove version from simple environment', async
115
125
assertNockRequest ( scope ) ;
116
126
assertNockRequest ( autocompleteScope ) ;
117
127
assertNockRequest ( envPathRemovalScope ) ;
128
+ assertNockRequest ( hostScope ) ;
129
+ assertNockRequest ( activationKeysScope ) ;
118
130
assertNockRequest ( versionRemovalScope , done ) ;
119
131
} ) ;
120
132
121
133
test ( 'Can open Remove wizard and remove version from environment with hosts' , async ( done ) => {
122
134
const autocompleteScope = mockAutocomplete ( nockInstance , autocompleteUrl ) ;
123
135
const hostAutocompleteUrl = '/hosts/auto_complete_search' ;
124
136
const hostAutocompleteScope = mockForemanAutocomplete ( nockInstance , hostAutocompleteUrl ) ;
137
+ const hostAutocompleteMock = nockInstance
138
+ . get ( foremanApi . getApiUrl ( hostAutocompleteUrl ) )
139
+ . query ( { organization_id : '1' , search : '' } )
140
+ . reply ( 200 , { results : [ ] } ) ;
125
141
126
142
const scope = nockInstance
127
143
. get ( cvVersions )
@@ -133,11 +149,21 @@ test('Can open Remove wizard and remove version from environment with hosts', as
133
149
. query ( true )
134
150
. reply ( 200 , environmentPathsData ) ;
135
151
152
+ const initialHostScope = nockInstance
153
+ . get ( hostURL )
154
+ . query ( { organization_id : '1' , search : 'content_view_id=2' } )
155
+ . reply ( 200 , { results : [ ] } ) ;
156
+
136
157
const hostScope = nockInstance
137
158
. get ( hostURL )
138
- . query ( true )
159
+ . query ( { organization_id : '1' , search : 'content_view_id=2 AND (lifecycle_environment_id=6)' } )
139
160
. reply ( 200 , affectedHostData ) ;
140
161
162
+ const activationKeysScope = nockInstance
163
+ . get ( activationKeyURL )
164
+ . query ( true )
165
+ . reply ( 200 , { results : [ ] } ) ;
166
+
141
167
const cVDropDownOptionsScope = nockInstance
142
168
. get ( cVDropDownOptionsPath )
143
169
. reply ( 200 , cVDropDownOptionsData ) ;
@@ -199,7 +225,10 @@ test('Can open Remove wizard and remove version from environment with hosts', as
199
225
assertNockRequest ( scope ) ;
200
226
assertNockRequest ( autocompleteScope ) ;
201
227
assertNockRequest ( hostAutocompleteScope ) ;
228
+ assertNockRequest ( hostAutocompleteMock ) ;
229
+ assertNockRequest ( initialHostScope ) ;
202
230
assertNockRequest ( hostScope ) ;
231
+ assertNockRequest ( activationKeysScope ) ;
203
232
assertNockRequest ( cVDropDownOptionsScope ) ;
204
233
assertNockRequest ( envPathRemovalScope ) ;
205
234
assertNockRequest ( versionRemovalScope , done ) ;
@@ -209,6 +238,10 @@ test('Can open Remove wizard and remove version from environment with activation
209
238
const autocompleteScope = mockAutocomplete ( nockInstance , autocompleteUrl ) ;
210
239
const akAutocompleteUrl = '/activation_keys/auto_complete_search' ;
211
240
const akAutocompleteScope = mockAutocomplete ( nockInstance , akAutocompleteUrl ) ;
241
+ const activationKeysAutocompleteMock = nockInstance
242
+ . get ( api . getApiUrl ( akAutocompleteUrl ) )
243
+ . query ( { organization_id : '1' , search : '' } )
244
+ . reply ( 200 , { results : [ ] } ) ;
212
245
213
246
const scope = nockInstance
214
247
. get ( cvVersions )
@@ -220,11 +253,21 @@ test('Can open Remove wizard and remove version from environment with activation
220
253
. query ( true )
221
254
. reply ( 200 , environmentPathsData ) ;
222
255
256
+ const initialActivationKeyScope = nockInstance
257
+ . get ( activationKeyURL )
258
+ . query ( { organization_id : '1' , search : 'content_view_id=2' } )
259
+ . reply ( 200 , { results : [ ] } ) ;
260
+
223
261
const activationKeysScope = nockInstance
224
262
. get ( activationKeyURL )
225
- . query ( true )
263
+ . query ( { organization_id : '1' , search : 'content_view_id = 2 AND ( environment=test2 )' } )
226
264
. reply ( 200 , affectedActivationKeysData ) ;
227
265
266
+ const hostScope = nockInstance
267
+ . get ( hostURL )
268
+ . query ( true )
269
+ . reply ( 200 , { results : [ ] } ) ;
270
+
228
271
const cVDropDownOptionsScope = nockInstance
229
272
. get ( cVDropDownOptionsPath )
230
273
. reply ( 200 , cVDropDownOptionsData ) ;
@@ -287,7 +330,10 @@ test('Can open Remove wizard and remove version from environment with activation
287
330
assertNockRequest ( scope ) ;
288
331
assertNockRequest ( autocompleteScope ) ;
289
332
assertNockRequest ( akAutocompleteScope ) ;
333
+ assertNockRequest ( activationKeysAutocompleteMock ) ;
334
+ assertNockRequest ( initialActivationKeyScope ) ;
290
335
assertNockRequest ( activationKeysScope ) ;
336
+ assertNockRequest ( hostScope ) ;
291
337
assertNockRequest ( cVDropDownOptionsScope ) ;
292
338
assertNockRequest ( envPathRemovalScope ) ;
293
339
assertNockRequest ( versionRemovalScope , done ) ;
0 commit comments