diff --git a/backend/src/realtime/realtime-note/realtime-connection.spec.ts b/backend/src/realtime/realtime-note/realtime-connection.spec.ts index 7c17567e6..167c611ee 100644 --- a/backend/src/realtime/realtime-note/realtime-connection.spec.ts +++ b/backend/src/realtime/realtime-note/realtime-connection.spec.ts @@ -84,21 +84,27 @@ describe('websocket connection', () => { expect(sut.getRealtimeUserStateAdapter()).toBe(realtimeUserStatus); }); - it('returns the correct sync adapter', () => { - const yDocSyncServerAdapter = Mock.of({}); - jest - .spyOn(HedgeDocCommonsModule, 'YDocSyncServerAdapter') - .mockImplementation(() => yDocSyncServerAdapter); + it.each([true, false])( + 'creates a sync adapter with acceptEdits %s', + (acceptEdits) => { + const yDocSyncServerAdapter = Mock.of({}); + jest + .spyOn(HedgeDocCommonsModule, 'YDocSyncServerAdapter') + .mockImplementation((messageTransporter, doc, acceptEditsProvider) => { + expect((acceptEditsProvider as () => boolean)()).toBe(acceptEdits); + return yDocSyncServerAdapter; + }); - const sut = new RealtimeConnection( - mockedMessageTransporter, - mockedUser, - mockedRealtimeNote, - true, - ); + const sut = new RealtimeConnection( + mockedMessageTransporter, + mockedUser, + mockedRealtimeNote, + acceptEdits, + ); - expect(sut.getSyncAdapter()).toBe(yDocSyncServerAdapter); - }); + expect(sut.getSyncAdapter()).toBe(yDocSyncServerAdapter); + }, + ); it('removes the client from the note on transporter disconnect', () => { const sut = new RealtimeConnection( diff --git a/backend/src/realtime/realtime-note/realtime-connection.ts b/backend/src/realtime/realtime-note/realtime-connection.ts index 9c2e5fac8..d91fc23a6 100644 --- a/backend/src/realtime/realtime-note/realtime-connection.ts +++ b/backend/src/realtime/realtime-note/realtime-connection.ts @@ -35,7 +35,7 @@ export class RealtimeConnection { messageTransporter: MessageTransporter, private user: User | null, private realtimeNote: RealtimeNote, - private acceptEdits: boolean, + public acceptEdits: boolean, ) { this.displayName = user?.displayName ?? generateRandomName(); this.transporter = messageTransporter;