@@ -198,52 +198,66 @@ describe('Transforms', () => {
198
198
// Confirm we have our initial transform
199
199
cy . contains ( TRANSFORM_ID ) ;
200
200
201
- // Intercept different transform requests endpoints to wait before clicking disable and enable buttons
202
- cy . intercept ( `/api/ism/transforms/${ TRANSFORM_ID } ` ) . as ( 'getTransform' ) ;
203
- cy . intercept ( `/api/ism/transforms/${ TRANSFORM_ID } /_stop` ) . as (
204
- 'stopTransform'
205
- ) ;
206
-
207
201
// Click into transform job details page
208
202
cy . get ( `[data-test-subj="transformLink_${ TRANSFORM_ID } "]` ) . click ( {
209
203
force : true ,
210
204
} ) ;
211
205
212
206
cy . contains ( `${ TRANSFORM_ID } ` ) ;
213
207
214
- /* Wait required for page data to load, otherwise "Disable" button will
215
- * appear greyed out and unavailable. Cypress automatically retries,
216
- * but only after menu is open, doesn't re-render.
217
- */
218
- cy . wait ( '@getTransform' ) . wait ( 2000 ) ;
208
+ /* Wait required for page data to load */
209
+ cy . wait ( 1000 ) ;
219
210
220
211
// Click into Actions menu
221
212
cy . get ( `[data-test-subj="actionButton"]` ) . click ( { force : true } ) ;
222
213
223
- // Click Disable button
224
- cy . get ( `[data-test-subj="disableButton"]` )
225
- . should ( 'not.be.disabled' )
226
- . click ( ) ;
227
-
228
- cy . wait ( '@stopTransform' ) ;
229
- cy . wait ( '@getTransform' ) ;
230
-
231
- // Confirm we get toaster saying transform job is disabled
232
- cy . contains ( `"${ TRANSFORM_ID } " is disabled` ) ;
233
-
234
- // Extra wait required for page data to load, otherwise "Enable" button will be disabled
235
- cy . wait ( 2000 ) ;
236
-
237
- // Click into Actions menu
238
- cy . get ( `[data-test-subj="actionButton"]` ) . click ( { force : true } ) ;
239
-
240
- // Click Enable button
241
- cy . get ( `[data-test-subj="enableButton"]` )
242
- . should ( 'not.be.disabled' )
243
- . click ( { force : true } ) ;
244
-
245
- // Confirm we get toaster saying transform job is enabled
246
- cy . contains ( `"${ TRANSFORM_ID } " is enabled` ) ;
214
+ // Check which action is available (enable or disable)
215
+ cy . get (
216
+ '[data-test-subj="enableButton"], [data-test-subj="disableButton"]'
217
+ ) . then ( ( $buttons ) => {
218
+ const enableButton = $buttons . filter (
219
+ '[data-test-subj="enableButton"]:not([disabled])'
220
+ ) ;
221
+ const disableButton = $buttons . filter (
222
+ '[data-test-subj="disableButton"]:not([disabled])'
223
+ ) ;
224
+
225
+ if ( disableButton . length ) {
226
+ // If disable button is enabled, means transform is currently enabled
227
+ cy . get ( '[data-test-subj="disableButton"]' )
228
+ . should ( 'not.be.disabled' )
229
+ . click ( ) ;
230
+ cy . contains ( `"${ TRANSFORM_ID } " is disabled` ) ;
231
+
232
+ cy . wait ( 1000 ) ;
233
+
234
+ // Click into Actions menu again
235
+ cy . get ( `[data-test-subj="actionButton"]` ) . click ( { force : true } ) ;
236
+
237
+ // Then enable it
238
+ cy . get ( '[data-test-subj="enableButton"]' )
239
+ . should ( 'not.be.disabled' )
240
+ . click ( { force : true } ) ;
241
+ cy . contains ( `"${ TRANSFORM_ID } " is enabled` ) ;
242
+ } else if ( enableButton . length ) {
243
+ // If enable button is enabled, means transform is currently disabled
244
+ cy . get ( '[data-test-subj="enableButton"]' )
245
+ . should ( 'not.be.disabled' )
246
+ . click ( { force : true } ) ;
247
+ cy . contains ( `"${ TRANSFORM_ID } " is enabled` ) ;
248
+
249
+ cy . wait ( 1000 ) ;
250
+
251
+ // Click into Actions menu again
252
+ cy . get ( `[data-test-subj="actionButton"]` ) . click ( { force : true } ) ;
253
+
254
+ // Then disable it
255
+ cy . get ( '[data-test-subj="disableButton"]' )
256
+ . should ( 'not.be.disabled' )
257
+ . click ( ) ;
258
+ cy . contains ( `"${ TRANSFORM_ID } " is disabled` ) ;
259
+ }
260
+ } ) ;
247
261
} ) ;
248
262
} ) ;
249
263
0 commit comments