@@ -317,6 +317,7 @@ describe('Flows with queryBuilderUseMetadataCaching flag on', () => {
317317 )
318318
319319 const flowName = 'Flowbooks'
320+ const flowCloneNamePrefix = `${ flowName } (cloned at `
320321
321322 cy . getByTestID ( 'preset-new' )
322323 . first ( )
@@ -400,9 +401,6 @@ describe('Flows with queryBuilderUseMetadataCaching flag on', () => {
400401
401402 cy . getByTestID ( 'resource-editable-name' ) . contains ( `${ flowName } ` )
402403
403- const d = Date . UTC ( 2018 , 10 , 30 )
404- cy . clock ( d , [ 'Date' ] )
405-
406404 cy . getByTestID ( `flow-card--${ flowName } ` ) . within ( ( ) => {
407405 cy . getByTestID ( `context-menu-flow` ) . click ( )
408406 } )
@@ -411,25 +409,37 @@ describe('Flows with queryBuilderUseMetadataCaching flag on', () => {
411409
412410 cy . getByTestID ( 'time-machine-submit-button' ) . should ( 'be.visible' )
413411
414- const clone = `${ flowName } (cloned at 11-30-2018:00:00:00)`
415-
416412 // Should redirect the user to the newly cloned flow
417413 // Validates that the selected clone is the clone
418- cy . getByTestID ( 'page-title' ) . contains ( `${ clone } ` )
414+ cy . getByTestID ( 'page-title' )
415+ . first ( )
416+ . then ( cloneNameElement => {
417+ const cloneName = cloneNameElement . text ( )
418+ const cloneTime = cloneName . slice (
419+ flowCloneNamePrefix . length ,
420+ cloneName . length - 1
421+ )
422+ const cloneTimeAsDate = new Date ( cloneTime )
423+ expect ( cloneTimeAsDate . toTimeString ( ) ) . not . to . equal ( 'Invalid Date' )
424+ expect ( cloneTimeAsDate . valueOf ( ) ) . to . equal ( cloneTimeAsDate . valueOf ( ) )
425+ } )
419426
420427 cy . clickNavBarItem ( 'nav-item-flows' )
421428
422429 cy . get ( '.cf-resource-card' ) . should ( 'have.length' , 2 )
423430 cy . get ( '.cf-resource-editable-name' )
424431 . first ( )
425- . contains ( ` ${ clone } ` )
432+ . contains ( flowCloneNamePrefix )
426433
427434 // Delete the cloned flow
428- cy . getByTestID ( `flow-card--${ clone } ` ) . within ( ( ) => {
435+ cy . getByTestIDHead ( `flow-card--${ flowCloneNamePrefix } ` ) . within ( ( ) => {
429436 cy . getByTestID ( `context-delete-menu--button` ) . click ( )
430437 } )
431438 cy . getByTestID ( `context-delete-menu--confirm-button` ) . click ( )
432439
440+ cy . getByTestID ( 'notification-success' ) . should ( 'be.visible' )
441+ cy . getByTestID ( 'notification-success--dismiss' ) . click ( )
442+
433443 cy . get ( '.cf-resource-card' ) . should ( 'have.length' , 1 )
434444 cy . getByTestID ( 'resource-editable-name' ) . contains ( `${ flowName } ` )
435445
@@ -442,16 +452,28 @@ describe('Flows with queryBuilderUseMetadataCaching flag on', () => {
442452 // Should redirect the user to the newly cloned flow
443453 cy . getByTestID ( 'time-machine-submit-button' ) . should ( 'be.visible' )
444454 cy . wait ( '@updateNotebook' )
445- cy . getByTestID ( 'page-title' ) . contains ( `${ clone } ` )
455+ cy . getByTestID ( 'page-title' )
456+ . first ( )
457+ . then ( cloneNameElement => {
458+ const cloneName = cloneNameElement . text ( )
459+ const cloneTime = cloneName . slice (
460+ flowCloneNamePrefix . length ,
461+ cloneName . length - 1
462+ )
463+ const cloneTimeAsDate = new Date ( cloneTime )
464+ expect ( cloneTimeAsDate . toTimeString ( ) ) . not . to . equal ( 'Invalid Date' )
465+ expect ( cloneTimeAsDate . valueOf ( ) ) . to . equal ( cloneTimeAsDate . valueOf ( ) )
466+ } )
446467
447468 // Delete the cloned flow inside the notebook
448469 cy . getByTestID ( 'flow-menu-button' ) . click ( )
449470 cy . getByTestID ( 'flow-menu-button-delete' ) . should ( 'be.visible' )
450471 cy . getByTestID ( 'flow-menu-button-delete' ) . click ( )
451472
473+ cy . getByTestID ( 'notification-success' ) . should ( 'be.visible' )
474+
452475 cy . get ( '.cf-resource-card' ) . should ( 'have.length' , 1 )
453476 cy . get ( '.cf-resource-editable-name' ) . should ( 'have.length' , 1 )
454477 cy . get ( '.cf-resource-editable-name' ) . contains ( `${ flowName } ` )
455- cy . clock ( ) . invoke ( 'restore' )
456478 } )
457479} )
0 commit comments