@@ -446,5 +446,56 @@ describe('App', () => {
446446 expect ( change ?. status ) . toEqual ( { from : 'done' , to : 'in-testing' } )
447447 expect ( change ?. qeVerify ) . toBeUndefined ( )
448448 } )
449+
450+ it ( 'should revert qe-verify when dragging from in-testing back to original column' , ( ) => {
451+ // This test simulates handleBugMove flow:
452+ // 1. User drags bug from 'todo' to 'in-testing' (auto-stages qe-verify+)
453+ // 2. User drags bug back to 'todo' (should revert ALL staged changes)
454+ const { stageChange, stageQeVerifyChange } = useStore . getState ( )
455+
456+ // Step 1: Simulate handleBugMove(123, 'todo', 'in-testing')
457+ // This stages status and auto-stages qe-verify+
458+ stageChange ( 123 , 'todo' , 'in-testing' )
459+ stageQeVerifyChange ( 123 , 'unknown' , 'plus' )
460+
461+ // Verify intermediate state
462+ let changes = useStore . getState ( ) . changes
463+ expect ( changes . get ( 123 ) ?. status ) . toEqual ( { from : 'todo' , to : 'in-testing' } )
464+ expect ( changes . get ( 123 ) ?. qeVerify ) . toEqual ( { from : 'unknown' , to : 'plus' } )
465+
466+ // Step 2: Simulate handleBugMove(123, 'in-testing', 'todo')
467+ // Capture existing change before stageChange (as handleBugMove does)
468+ const existingChange = useStore . getState ( ) . changes . get ( 123 )
469+ stageChange ( 123 , 'in-testing' , 'todo' )
470+
471+ // handleBugMove detects status was reverted and also reverts qeVerify
472+ const updatedChange = useStore . getState ( ) . changes . get ( 123 )
473+ if ( existingChange ?. qeVerify && ! updatedChange ?. status ) {
474+ stageQeVerifyChange ( 123 , 'unknown' , 'unknown' )
475+ }
476+
477+ // Expected: no changes should remain (both status and qeVerify reverted)
478+ changes = useStore . getState ( ) . changes
479+ expect ( changes . has ( 123 ) ) . toBe ( false )
480+ } )
481+
482+ it ( 'should keep qe-verify when moving from in-testing to a different column (not original)' , ( ) => {
483+ // Flow: todo -> in-testing -> done
484+ // qe-verify+ should persist since we're not reverting to original
485+ const { stageChange, stageQeVerifyChange } = useStore . getState ( )
486+
487+ // Step 1: todo -> in-testing
488+ stageChange ( 123 , 'todo' , 'in-testing' )
489+ stageQeVerifyChange ( 123 , 'unknown' , 'plus' )
490+
491+ // Step 2: in-testing -> done (different from original 'todo')
492+ stageChange ( 123 , 'in-testing' , 'done' )
493+
494+ // qe-verify should still be staged (we want it applied)
495+ const changes = useStore . getState ( ) . changes
496+ const change = changes . get ( 123 )
497+ expect ( change ?. status ) . toEqual ( { from : 'todo' , to : 'done' } )
498+ expect ( change ?. qeVerify ) . toEqual ( { from : 'unknown' , to : 'plus' } )
499+ } )
449500 } )
450501} )
0 commit comments