@@ -90,9 +90,9 @@ describe("Proofreading (Poll only)", () => {
9090 // Checking that only the injected update action were received.
9191 expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 1 ) ;
9292 expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
93- const onlyExistingUpdateBatch = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
94- expect ( onlyExistingUpdateBatch . actions . length ) . toBe ( 1 ) ;
95- expect ( onlyExistingUpdateBatch . actions ) . toEqual ( [ foreignMergeAction ] ) ;
93+ const updateBatch = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
94+ expect ( updateBatch . actions . length ) . toBe ( 1 ) ;
95+ expect ( updateBatch . actions ) . toEqual ( [ foreignMergeAction ] ) ;
9696
9797 const activeTool = yield select ( ( state ) => state . uiInformation . activeTool ) ;
9898 expect ( activeTool ) . toBe ( AnnotationTool . PROOFREAD ) ;
@@ -175,9 +175,9 @@ describe("Proofreading (Poll only)", () => {
175175 // Checking that only the injected update action were received.
176176 expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 1 ) ;
177177 expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
178- const onlyExistingUpdateBatch = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
179- expect ( onlyExistingUpdateBatch . actions . length ) . toBe ( 1 ) ;
180- expect ( onlyExistingUpdateBatch . actions ) . toEqual ( [ foreignSplitAction ] ) ;
178+ const updateBatch1 = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
179+ expect ( updateBatch1 . actions . length ) . toBe ( 1 ) ;
180+ expect ( updateBatch1 . actions ) . toEqual ( [ foreignSplitAction ] ) ;
181181
182182 const foreignMergeAction = {
183183 name : "mergeAgglomerate" as const ,
@@ -216,14 +216,14 @@ describe("Proofreading (Poll only)", () => {
216216 // split action:
217217 expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 2 ) ;
218218 expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
219- const onlyExistingUpdateBatch2 = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
220- expect ( onlyExistingUpdateBatch2 . actions . length ) . toBe ( 1 ) ;
221- expect ( onlyExistingUpdateBatch2 . actions ) . toEqual ( [ foreignSplitAction ] ) ;
219+ const updateBatch2 = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
220+ expect ( updateBatch2 . actions . length ) . toBe ( 1 ) ;
221+ expect ( updateBatch2 . actions ) . toEqual ( [ foreignSplitAction ] ) ;
222222 // merge action:
223223 expect ( context . receivedDataPerSaveRequest [ 1 ] . length ) . toBe ( 1 ) ;
224- const onlyExistingUpdateBatch3 = context . receivedDataPerSaveRequest [ 1 ] [ 0 ] ;
225- expect ( onlyExistingUpdateBatch3 . actions . length ) . toBe ( 1 ) ;
226- expect ( onlyExistingUpdateBatch3 . actions ) . toEqual ( [ foreignMergeAction ] ) ;
224+ const updateBatch3 = context . receivedDataPerSaveRequest [ 1 ] [ 0 ] ;
225+ expect ( updateBatch3 . actions . length ) . toBe ( 1 ) ;
226+ expect ( updateBatch3 . actions ) . toEqual ( [ foreignMergeAction ] ) ;
227227 } ) ;
228228
229229 await task . toPromise ( ) ;
@@ -278,9 +278,9 @@ describe("Proofreading (Poll only)", () => {
278278 // Checking that only the injected update action were received.
279279 expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 1 ) ;
280280 expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
281- const onlyExistingUpdateBatch2 = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
282- expect ( onlyExistingUpdateBatch2 . actions . length ) . toBe ( 1 ) ;
283- expect ( onlyExistingUpdateBatch2 . actions ) . toEqual ( [ foreignSplitAction ] ) ;
281+ const updateBatch = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
282+ expect ( updateBatch . actions . length ) . toBe ( 1 ) ;
283+ expect ( updateBatch . actions ) . toEqual ( [ foreignSplitAction ] ) ;
284284 } ) ;
285285
286286 await task . toPromise ( ) ;
@@ -356,14 +356,14 @@ describe("Proofreading (Poll only)", () => {
356356 // split 1
357357 expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 2 ) ;
358358 expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
359- const onlyExistingUpdateBatch2 = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
360- expect ( onlyExistingUpdateBatch2 . actions . length ) . toBe ( 1 ) ;
361- expect ( onlyExistingUpdateBatch2 . actions ) . toEqual ( [ foreignSplitAction1 ] ) ;
359+ const updateBatch1 = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
360+ expect ( updateBatch1 . actions . length ) . toBe ( 1 ) ;
361+ expect ( updateBatch1 . actions ) . toEqual ( [ foreignSplitAction1 ] ) ;
362362 //split 2
363363 expect ( context . receivedDataPerSaveRequest [ 1 ] . length ) . toBe ( 1 ) ;
364- const onlyExistingUpdateBatch3 = context . receivedDataPerSaveRequest [ 1 ] [ 0 ] ;
365- expect ( onlyExistingUpdateBatch3 . actions . length ) . toBe ( 1 ) ;
366- expect ( onlyExistingUpdateBatch3 . actions ) . toEqual ( [ foreignSplitAction2 ] ) ;
364+ const updateBatch2 = context . receivedDataPerSaveRequest [ 1 ] [ 0 ] ;
365+ expect ( updateBatch2 . actions . length ) . toBe ( 1 ) ;
366+ expect ( updateBatch2 . actions ) . toEqual ( [ foreignSplitAction2 ] ) ;
367367 } ) ;
368368
369369 await task . toPromise ( ) ;
@@ -393,35 +393,27 @@ describe("Proofreading (Poll only)", () => {
393393 yield call ( ( ) => api . tracing . save ( ) ) ;
394394 context . receivedDataPerSaveRequest . length = 0 ;
395395
396- backendMock . injectVersion (
397- [
398- {
399- name : "mergeAgglomerate" ,
400- value : {
401- actionTracingId : "volumeTracingId" ,
402- segmentId1 : 7 ,
403- segmentId2 : 1337 ,
404- agglomerateId1 : 6 ,
405- agglomerateId2 : 1337 ,
406- } ,
407- } ,
408- ] ,
409- 4 ,
410- ) ;
411- backendMock . injectVersion (
412- [
413- {
414- name : "splitAgglomerate" ,
415- value : {
416- actionTracingId : "volumeTracingId" ,
417- segmentId1 : 1338 ,
418- segmentId2 : 1337 ,
419- agglomerateId : 6 ,
420- } ,
421- } ,
422- ] ,
423- 5 ,
424- ) ;
396+ const foreignMergeAction = {
397+ name : "mergeAgglomerate" as const ,
398+ value : {
399+ actionTracingId : "volumeTracingId" ,
400+ segmentId1 : 7 ,
401+ segmentId2 : 1337 ,
402+ agglomerateId1 : 6 ,
403+ agglomerateId2 : 1337 ,
404+ } ,
405+ } ;
406+ const foreignSplitAction = {
407+ name : "splitAgglomerate" as const ,
408+ value : {
409+ actionTracingId : "volumeTracingId" ,
410+ segmentId1 : 1338 ,
411+ segmentId2 : 1337 ,
412+ agglomerateId : 6 ,
413+ } ,
414+ } ;
415+ backendMock . injectVersion ( [ foreignMergeAction ] , 4 ) ;
416+ backendMock . injectVersion ( [ foreignSplitAction ] , 5 ) ;
425417
426418 yield call ( dispatchEnsureHasNewestVersionAsync , Store . dispatch ) ;
427419
@@ -444,7 +436,16 @@ describe("Proofreading (Poll only)", () => {
444436
445437 yield call ( ( ) => api . tracing . save ( ) ) ;
446438
447- expect ( context . receivedDataPerSaveRequest ) . toEqual ( [ ] ) ;
439+ // Checking that only the injected update actions were received.
440+ expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 2 ) ;
441+ expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
442+ const updateBatch1 = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
443+ expect ( updateBatch1 . actions . length ) . toBe ( 1 ) ;
444+ expect ( updateBatch1 . actions ) . toEqual ( [ foreignMergeAction ] ) ;
445+ expect ( context . receivedDataPerSaveRequest [ 1 ] . length ) . toBe ( 1 ) ;
446+ const updateBatch2 = context . receivedDataPerSaveRequest [ 1 ] [ 0 ] ;
447+ expect ( updateBatch2 . actions . length ) . toBe ( 1 ) ;
448+ expect ( updateBatch2 . actions ) . toEqual ( [ foreignSplitAction ] ) ;
448449 } ) ;
449450
450451 await task . toPromise ( ) ;
@@ -474,21 +475,17 @@ describe("Proofreading (Poll only)", () => {
474475 yield call ( ( ) => api . tracing . save ( ) ) ;
475476 context . receivedDataPerSaveRequest . length = 0 ;
476477
477- backendMock . injectVersion (
478- [
479- {
480- name : "mergeAgglomerate" ,
481- value : {
482- actionTracingId : "volumeTracingId" ,
483- segmentId1 : 1 ,
484- segmentId2 : 4 ,
485- agglomerateId1 : 1 ,
486- agglomerateId2 : 4 ,
487- } ,
488- } ,
489- ] ,
490- 4 ,
491- ) ;
478+ const foreignMergeAction = {
479+ name : "mergeAgglomerate" as const ,
480+ value : {
481+ actionTracingId : "volumeTracingId" ,
482+ segmentId1 : 1 ,
483+ segmentId2 : 4 ,
484+ agglomerateId1 : 1 ,
485+ agglomerateId2 : 4 ,
486+ } ,
487+ } ;
488+ backendMock . injectVersion ( [ foreignMergeAction ] , 4 ) ;
492489 yield call ( dispatchEnsureHasNewestVersionAsync , Store . dispatch ) ;
493490
494491 const mapping1 = yield select (
@@ -500,7 +497,12 @@ describe("Proofreading (Poll only)", () => {
500497
501498 yield call ( ( ) => api . tracing . save ( ) ) ;
502499
503- expect ( context . receivedDataPerSaveRequest ) . toEqual ( [ ] ) ;
500+ // Checking that only the injected update action was received.
501+ expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 1 ) ;
502+ expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
503+ const updateBatch = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
504+ expect ( updateBatch . actions . length ) . toBe ( 1 ) ;
505+ expect ( updateBatch . actions ) . toEqual ( [ foreignMergeAction ] ) ;
504506
505507 // Asserting no rebasing relevant actions were triggered.
506508 const rebasingActions = yield flush ( rebaseActionChannel ) ;
@@ -513,7 +515,10 @@ describe("Proofreading (Poll only)", () => {
513515 await task . toPromise ( ) ;
514516 } , 8000 ) ;
515517
516- it ( "should poll updates even when othersMayEdit it turned off and updating is not allowed by current user" , async ( context : WebknossosTestContext ) => {
518+ async function testPollWithUserNotAllowedToSave (
519+ context : WebknossosTestContext ,
520+ othersMayEdit : boolean ,
521+ ) {
517522 const { api } = context ;
518523 const backendMock = mockInitialBucketAndAgglomerateData ( context ) ;
519524
@@ -529,6 +534,10 @@ describe("Proofreading (Poll only)", () => {
529534 ) ;
530535 expect ( mapping0 ) . toEqual ( initialMapping ) ;
531536
537+ if ( othersMayEdit ) {
538+ yield put ( setOthersMayEditForAnnotationAction ( true ) ) ;
539+ }
540+
532541 yield call ( ( ) => api . tracing . save ( ) ) ;
533542 // Disable annotation saving: Simulating that this user does not edit the annotation but should be able to pull updates.
534543 yield put ( setIsUpdatingAnnotationCurrentlyAllowedAction ( false ) ) ;
@@ -561,16 +570,24 @@ describe("Proofreading (Poll only)", () => {
561570 // Checking that only the injected update action were received.
562571 expect ( context . receivedDataPerSaveRequest . length ) . toBe ( 1 ) ;
563572 expect ( context . receivedDataPerSaveRequest [ 0 ] . length ) . toBe ( 1 ) ;
564- const onlyExistingUpdateBatch = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
565- expect ( onlyExistingUpdateBatch . actions . length ) . toBe ( 1 ) ;
566- expect ( onlyExistingUpdateBatch . actions ) . toEqual ( [ foreignMergeAction ] ) ;
573+ const updateBatch = context . receivedDataPerSaveRequest [ 0 ] [ 0 ] ;
574+ expect ( updateBatch . actions . length ) . toBe ( 1 ) ;
575+ expect ( updateBatch . actions ) . toEqual ( [ foreignMergeAction ] ) ;
567576
568577 const activeTool = yield select ( ( state ) => state . uiInformation . activeTool ) ;
569578 expect ( activeTool ) . toBe ( AnnotationTool . PROOFREAD ) ;
570579 } ) ;
571580
572581 await task . toPromise ( ) ;
582+ }
583+
584+ it ( "should poll updates even when othersMayEdit it turned off and updating is not allowed by current user" , async ( context : WebknossosTestContext ) => {
585+ const othersMayEdit = false ;
586+ await testPollWithUserNotAllowedToSave ( context , othersMayEdit ) ;
573587 } , 8000 ) ;
574- } ) ;
575588
576- // TODOM: Test where OthersMayEdit = true is not needed
589+ it ( "should poll updates with othersMayEdit turned on but updating is not allowed by current user" , async ( context : WebknossosTestContext ) => {
590+ const othersMayEdit = true ;
591+ await testPollWithUserNotAllowedToSave ( context , othersMayEdit ) ;
592+ } , 8000 ) ;
593+ } ) ;
0 commit comments