mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #36361 from overleaf/ar-fix-postdoc-validation-errors
[docstore][document-updater] fix POST doc validation errors GitOrigin-RevId: 9b5fbc667a3b56b30077ea8de9d81c17253db273
This commit is contained in:
@@ -14,17 +14,22 @@ import { z } from '@overleaf/validation-tools'
|
||||
// - history restores send id-less changes and comment ops with a `resolved`
|
||||
// flag (stripped again by RangeManager), and detached comments without an
|
||||
// id, see overleaf-editor-core/lib/doc_updater_compatible_ranges.js
|
||||
// - old tracked changes created while the fixedRemoveChange flag existed
|
||||
// (removed in https://github.com/overleaf/internal/pull/23993) still carry
|
||||
// it in their op until accepted/rejected
|
||||
|
||||
const insertOp = z.strictObject({
|
||||
i: z.string(),
|
||||
p: z.number().int().min(0),
|
||||
u: z.boolean().optional(),
|
||||
fixedRemoveChange: z.boolean().optional(),
|
||||
})
|
||||
|
||||
const deleteOp = z.strictObject({
|
||||
d: z.string(),
|
||||
p: z.number().int().min(0),
|
||||
u: z.boolean().optional(),
|
||||
fixedRemoveChange: z.boolean().optional(),
|
||||
})
|
||||
|
||||
const commentOp = z.strictObject({
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { ranges } from '../../../app/js/schemas.js'
|
||||
|
||||
describe('schemas', function () {
|
||||
describe('ranges', function () {
|
||||
it('accepts a legacy fixedRemoveChange flag on an insert op', function () {
|
||||
const result = ranges.safeParse({
|
||||
changes: [{ op: { i: 'foo', p: 0, fixedRemoveChange: true } }],
|
||||
})
|
||||
expect(result.success).to.equal(true)
|
||||
})
|
||||
|
||||
it('accepts a legacy fixedRemoveChange flag on a delete op', function () {
|
||||
const result = ranges.safeParse({
|
||||
changes: [{ op: { d: 'foo', p: 0, fixedRemoveChange: true } }],
|
||||
})
|
||||
expect(result.success).to.equal(true)
|
||||
})
|
||||
|
||||
it('rejects an unrecognized key on an insert op', function () {
|
||||
const result = ranges.safeParse({
|
||||
changes: [{ op: { i: 'foo', p: 0, somethingElse: true } }],
|
||||
})
|
||||
expect(result.success).to.equal(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -11,17 +11,23 @@ const { z, zz } = require('@overleaf/validation-tools')
|
||||
// schemas model them explicitly: comments/changes preloaded from web may lack `id`.
|
||||
// Tightening these is tracked as part of moving the shared editor payload
|
||||
// schemas into overleaf-editor-core.
|
||||
//
|
||||
// Old tracked changes created while the fixedRemoveChange flag existed
|
||||
// (removed in https://github.com/overleaf/internal/pull/23993) still carry
|
||||
// it in their op until accepted/rejected.
|
||||
|
||||
const insertOp = z.strictObject({
|
||||
i: z.string(),
|
||||
p: z.number().int().min(0),
|
||||
u: z.boolean().optional(),
|
||||
fixedRemoveChange: z.boolean().optional(),
|
||||
})
|
||||
|
||||
const deleteOp = z.strictObject({
|
||||
d: z.string(),
|
||||
p: z.number().int().min(0),
|
||||
u: z.boolean().optional(),
|
||||
fixedRemoveChange: z.boolean().optional(),
|
||||
})
|
||||
|
||||
const commentOp = z.strictObject({
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
const { expect } = require('chai')
|
||||
const { insertOp, deleteOp } = require('../../../app/js/schemas')
|
||||
|
||||
describe('schemas', function () {
|
||||
describe('insertOp', function () {
|
||||
it('accepts a legacy fixedRemoveChange flag', function () {
|
||||
const result = insertOp.safeParse({
|
||||
i: 'foo',
|
||||
p: 0,
|
||||
fixedRemoveChange: true,
|
||||
})
|
||||
expect(result.success).to.equal(true)
|
||||
})
|
||||
|
||||
it('rejects an unrecognized key', function () {
|
||||
const result = insertOp.safeParse({ i: 'foo', p: 0, somethingElse: true })
|
||||
expect(result.success).to.equal(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('deleteOp', function () {
|
||||
it('accepts a legacy fixedRemoveChange flag', function () {
|
||||
const result = deleteOp.safeParse({
|
||||
d: 'foo',
|
||||
p: 0,
|
||||
fixedRemoveChange: true,
|
||||
})
|
||||
expect(result.success).to.equal(true)
|
||||
})
|
||||
|
||||
it('rejects an unrecognized key', function () {
|
||||
const result = deleteOp.safeParse({ d: 'foo', p: 0, somethingElse: true })
|
||||
expect(result.success).to.equal(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user