[editor-core] allow empty ranges on rawAddCommentOperation (#36073)

GitOrigin-RevId: 8674a2b458770439925047aab9a129242eb984d4
This commit is contained in:
Jakob Ackermann
2026-09-17 11:44:12 +00:00
committed by Copybot
parent 074c9a882a
commit 2f69caef63
2 changed files with 13 additions and 1 deletions
@@ -47,7 +47,7 @@ const rawRange = z.strictObject({
const rawAddCommentOperation = z.strictObject({
commentId: zz.objectId(),
ranges: z.array(rawRange).min(1),
ranges: z.array(rawRange),
resolved: z.boolean().optional(),
})
@@ -17,6 +17,18 @@ describe('AddCommentOperation', function () {
expect(op.resolved).to.be.true
})
it('constructs a collapsed AddCommentOperation fromJSON', function () {
const op = AddCommentOperation.fromJSON({
commentId: '123',
resolved: true,
ranges: [],
})
expect(op).to.be.instanceOf(AddCommentOperation)
expect(op.commentId).to.equal('123')
expect(op.ranges).to.be.deep.equal([])
expect(op.resolved).to.be.true
})
it('should convert to JSON', function () {
const op = new AddCommentOperation('123', [new Range(0, 1)])
expect(op.toJSON()).to.eql({