@@ -494,6 +494,8 @@ describe("Proofreading (with mesh actions)", () => {
494494 // Execute the actual merge and wait for the finished mapping.
495495 yield put ( minCutPartitionsAction ( ) ) ;
496496 yield take ( "FINISH_MAPPING_INITIALIZATION" ) ;
497+ const version = yield select ( ( state ) => state . annotation . version ) ;
498+ console . log ( version ) ;
497499 // Checking optimistic merge is not necessary as no "foreign" update was injected.
498500 yield call ( ( ) => api . tracing . save ( ) ) ; // Also pulls newest version from backend.
499501 }
@@ -521,7 +523,6 @@ describe("Proofreading (with mesh actions)", () => {
521523 const { annotation } = Store . getState ( ) ;
522524 const { tracingId } = annotation . volumes [ 0 ] ;
523525
524- // TODOM: Test is failing because interfering things are problematic
525526 const task = startSaga ( function * task ( ) : Generator < any , void , any > {
526527 yield simulatePartitionedSplitAgglomeratesViaMeshes ( context ) ;
527528
@@ -561,8 +562,116 @@ describe("Proofreading (with mesh actions)", () => {
561562 [ 5 , 4 ] ,
562563 [ 6 , 6 ] ,
563564 [ 7 , 6 ] ,
564- [ 1337 , 1339 ] ,
565- [ 1338 , 1339 ] , // TODO: check why this is loaded
565+ [ 1337 , 1339 ] , // Loaded as this segment is part of a split proofreading action done in this test.
566+ [ 1338 , 1339 ] , // Loaded as this segment is part of a split proofreading action done in this test.
567+ ] ) ,
568+ ) ;
569+ } ) ;
570+
571+ await task . toPromise ( ) ;
572+ } ) ;
573+
574+ it ( "should result in not partitioned min cut if min-cutted edges are outdated due to interfering merge operations." , async ( context : WebknossosTestContext ) => {
575+ const { mocks } = context ;
576+ // Initial mapping should be
577+ // [[1, 1],
578+ // [2, 1],
579+ // [3, 1],
580+ // [4, 4],
581+ // [5, 4],
582+ // [6, 6],
583+ // [7, 6],
584+ // [1337, 1],
585+ // [1338, 1]]
586+ // Thus, there should be the following circle of edges: 1-2-3-1337-1338-1.
587+ const backendMock = mockInitialBucketAndAgglomerateData ( context , [
588+ [ 1 , 1338 ] ,
589+ [ 3 , 1337 ] ,
590+ ] ) ;
591+
592+ // Mapping after interference should be
593+ // [[1, 1],
594+ // [2, 1],
595+ // [3, 1],
596+ // [4, 1],
597+ // [5, 1],
598+ // [6, 6],
599+ // [7, 6],
600+ // [1337, 1],
601+ // [1338, 1]]
602+ // Contains two circles now but only one is split by the min-cut request.
603+ backendMock . planVersionInjection ( 7 , [
604+ {
605+ name : "mergeAgglomerate" ,
606+ value : {
607+ actionTracingId : "volumeTracingId" ,
608+ segmentId1 : 1 ,
609+ segmentId2 : 4 ,
610+ agglomerateId1 : 1 ,
611+ agglomerateId2 : 4 ,
612+ } ,
613+ } ,
614+ ] ) ;
615+
616+ backendMock . planVersionInjection ( 8 , [
617+ {
618+ name : "mergeAgglomerate" ,
619+ value : {
620+ actionTracingId : "volumeTracingId" ,
621+ segmentId1 : 5 ,
622+ segmentId2 : 1337 ,
623+ agglomerateId1 : 1 ,
624+ agglomerateId2 : 1 ,
625+ } ,
626+ } ,
627+ ] ) ;
628+
629+ mockEdgesForPartitionedAgglomerateMinCut ( mocks ) ;
630+
631+ const { annotation } = Store . getState ( ) ;
632+ const { tracingId } = annotation . volumes [ 0 ] ;
633+
634+ const task = startSaga ( function * task ( ) : Generator < any , void , any > {
635+ yield simulatePartitionedSplitAgglomeratesViaMeshes ( context ) ;
636+
637+ const mergeSaveActionBatch = context . receivedDataPerSaveRequest . at ( - 1 ) ! [ 0 ] ?. actions ;
638+
639+ expect ( mergeSaveActionBatch ) . toEqual ( [
640+ {
641+ name : "splitAgglomerate" ,
642+ value : {
643+ actionTracingId : "volumeTracingId" ,
644+ agglomerateId : 1 ,
645+ segmentId1 : 1 ,
646+ segmentId2 : 1338 ,
647+ } ,
648+ } ,
649+ {
650+ name : "splitAgglomerate" ,
651+ value : {
652+ actionTracingId : "volumeTracingId" ,
653+ agglomerateId : 1 ,
654+ segmentId1 : 3 ,
655+ segmentId2 : 1337 ,
656+ } ,
657+ } ,
658+ ] ) ;
659+ const finalMapping = yield select (
660+ ( state ) =>
661+ getMappingInfo ( state . temporaryConfiguration . activeMappingByLayer , tracingId ) . mapping ,
662+ ) ;
663+
664+ expect ( finalMapping ) . toEqual (
665+ new Map ( [
666+ [ 1 , 1 ] ,
667+ [ 2 , 1 ] ,
668+ [ 3 , 1 ] ,
669+ [ 4 , 1 ] ,
670+ [ 5 , 1 ] ,
671+ [ 6 , 6 ] ,
672+ [ 7 , 6 ] ,
673+ [ 1337 , 1 ] , // Loaded as this segment is part of a split proofreading action done in this test.
674+ [ 1338 , 1 ] , // Loaded as this segment is part of a split proofreading action done in this test.
566675 ] ) ,
567676 ) ;
568677 } ) ;
0 commit comments