mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-23 17:33:13 +00:00
fix: allow change of accept edits in realtime connection
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
eebbb79d08
commit
3c1ea7bda9
2 changed files with 20 additions and 14 deletions
|
@ -84,21 +84,27 @@ describe('websocket connection', () => {
|
|||
expect(sut.getRealtimeUserStateAdapter()).toBe(realtimeUserStatus);
|
||||
});
|
||||
|
||||
it('returns the correct sync adapter', () => {
|
||||
const yDocSyncServerAdapter = Mock.of<YDocSyncServerAdapter>({});
|
||||
jest
|
||||
.spyOn(HedgeDocCommonsModule, 'YDocSyncServerAdapter')
|
||||
.mockImplementation(() => yDocSyncServerAdapter);
|
||||
it.each([true, false])(
|
||||
'creates a sync adapter with acceptEdits %s',
|
||||
(acceptEdits) => {
|
||||
const yDocSyncServerAdapter = Mock.of<YDocSyncServerAdapter>({});
|
||||
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(
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue