@@ -31,6 +31,7 @@ import Quill, { Delta, EmitterSource, Range } from 'quill';
31
31
import { User } from 'realtime-server/lib/esm/common/models/user' ;
32
32
import { createTestUser } from 'realtime-server/lib/esm/common/models/user-test-data' ;
33
33
import { WritingSystem } from 'realtime-server/lib/esm/common/models/writing-system' ;
34
+ import { Json0OpBuilder } from 'realtime-server/lib/esm/common/utils/json0-op-builder' ;
34
35
import { obj } from 'realtime-server/lib/esm/common/utils/obj-path' ;
35
36
import { RecursivePartial } from 'realtime-server/lib/esm/common/utils/type-utils' ;
36
37
import { BiblicalTerm } from 'realtime-server/lib/esm/scriptureforge/models/biblical-term' ;
@@ -70,6 +71,7 @@ import { CONSOLE } from 'xforge-common/browser-globals';
70
71
import { BugsnagService } from 'xforge-common/bugsnag.service' ;
71
72
import { createTestFeatureFlag , FeatureFlagService } from 'xforge-common/feature-flags/feature-flag.service' ;
72
73
import { GenericDialogComponent , GenericDialogOptions } from 'xforge-common/generic-dialog/generic-dialog.component' ;
74
+ import { MemoryRealtimeDocAdapter } from 'xforge-common/memory-realtime-remote-store' ;
73
75
import { UserDoc } from 'xforge-common/models/user-doc' ;
74
76
import { NoticeService } from 'xforge-common/notice.service' ;
75
77
import { OnlineStatusService } from 'xforge-common/online-status.service' ;
@@ -3373,7 +3375,7 @@ describe('EditorComponent', () => {
3373
3375
env . dispose ( ) ;
3374
3376
} ) ) ;
3375
3377
3376
- it ( 'should remove resolved notes after a remote update' , fakeAsync ( ( ) => {
3378
+ it ( 'should remove resolved notes after a remote update' , fakeAsync ( async ( ) => {
3377
3379
const env = new TestEnvironment ( ) ;
3378
3380
env . setProjectUserConfig ( ) ;
3379
3381
env . wait ( ) ;
@@ -3382,7 +3384,7 @@ describe('EditorComponent', () => {
3382
3384
let noteThreadEmbedCount = env . countNoteThreadEmbeds ( contents . ops ! ) ;
3383
3385
expect ( noteThreadEmbedCount ) . toEqual ( 5 ) ;
3384
3386
3385
- env . resolveNote ( 'project01' , 'dataid01' ) ;
3387
+ await env . resolveNote ( 'project01' , 'dataid01' , 'remote ') ;
3386
3388
contents = env . targetEditor . getContents ( ) ;
3387
3389
noteThreadEmbedCount = env . countNoteThreadEmbeds ( contents . ops ! ) ;
3388
3390
expect ( noteThreadEmbedCount ) . toEqual ( 4 ) ;
@@ -5594,10 +5596,19 @@ class TestEnvironment {
5594
5596
return noteEmbedCount ;
5595
5597
}
5596
5598
5597
- resolveNote ( projectId : string , threadId : string ) : void {
5599
+ async resolveNote ( projectId : string , threadId : string , origin : 'local' | 'remote' ) : Promise < void > {
5598
5600
const noteDoc : NoteThreadDoc = this . getNoteThreadDoc ( projectId , threadId ) ;
5599
- noteDoc . submitJson0Op ( op => op . set ( n => n . status , NoteStatus . Resolved ) ) ;
5600
- this . realtimeService . updateQueryAdaptersRemote ( ) ;
5601
+ const ops = op => op . set ( n => n . status , NoteStatus . Resolved ) ;
5602
+
5603
+ if ( origin === 'remote' ) {
5604
+ const docAdapter : MemoryRealtimeDocAdapter = noteDoc . adapter as MemoryRealtimeDocAdapter ;
5605
+ const builder = new Json0OpBuilder ( noteDoc . data ) ;
5606
+ ops ( builder ) ;
5607
+ const operations = builder . op ;
5608
+ this . realtimeService . simulateRemoteChange ( docAdapter , operations ) ;
5609
+ } else {
5610
+ await noteDoc . submitJson0Op ( ops ) ;
5611
+ }
5601
5612
this . wait ( ) ;
5602
5613
}
5603
5614
0 commit comments