Skip to content

Commit e2b6597

Browse files
caio-pizzolsuperdoc-oss-port[bot]
authored andcommitted
test(super-editor): sync comment feedback regression coverage (#496)
Ported-From-Source-Repo: superdoc/orbit Ported-From-Source-Commit: 959b898bb4bb3d017a47e0e82bf0db2692ff9856 Ported-Public-Prefix: superdoc/public
1 parent c3ff74e commit e2b6597

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

packages/super-editor/src/editors/v1/extensions/comment/comments-plugin.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,30 @@ describe('CommentsPlugin state', () => {
766766
expect(editor.emit).not.toHaveBeenCalled();
767767
});
768768

769+
it('settles when the selected event is echoed back to the plugin', () => {
770+
const { view, editor } = createPluginStateEnvironment();
771+
772+
editor.emit.mockImplementation((event, update) => {
773+
if (event === 'commentsUpdate' && update.type === comments_module_events.SELECTED) {
774+
setActiveComment(view, update.activeCommentId);
775+
}
776+
});
777+
778+
setActiveComment(view, 'comment-1');
779+
setActiveComment(view, 'comment-2');
780+
setActiveComment(view, 'comment-3');
781+
782+
vi.runAllTimers();
783+
784+
expect(editor.emit).toHaveBeenCalledTimes(1);
785+
expect(editor.emit).toHaveBeenCalledWith('commentsUpdate', {
786+
type: comments_module_events.SELECTED,
787+
activeCommentId: 'comment-3',
788+
});
789+
expect(CommentsPluginKey.getState(view.state).activeThreadId).toBe('comment-3');
790+
expect(vi.getTimerCount()).toBe(0);
791+
});
792+
769793
it('does not emit when the editor is destroyed before a deferred notification runs', () => {
770794
const { view, editor } = createPluginStateEnvironment();
771795

0 commit comments

Comments
 (0)