fix: recover null editor transform errors
This commit is contained in:
@@ -16,6 +16,10 @@ function transformError(message = 'Invalid transform') {
|
||||
return error
|
||||
}
|
||||
|
||||
function nullFragmentAppendError(message = "null is not an object (evaluating 'o.fillBefore(e).append')") {
|
||||
return new TypeError(message)
|
||||
}
|
||||
|
||||
function createView(error?: Error) {
|
||||
const currentDoc = {
|
||||
eq: vi.fn((candidate: unknown) => candidate === currentDoc),
|
||||
@@ -94,6 +98,10 @@ describe('isRecoverableEditorTransformError', () => {
|
||||
expect(isRecoverableEditorTransformError(new Error(
|
||||
'Block with ID 6c1c3bb4-e218-4f00-aaf5-40606852d286 not found',
|
||||
))).toBe(true)
|
||||
expect(isRecoverableEditorTransformError(nullFragmentAppendError())).toBe(true)
|
||||
expect(isRecoverableEditorTransformError(new TypeError(
|
||||
"Cannot read properties of null (reading 'append')",
|
||||
))).toBe(false)
|
||||
expect(isRecoverableEditorTransformError(new RangeError(
|
||||
'Index 1 out of range for <paragraph("A")>',
|
||||
))).toBe(false)
|
||||
@@ -213,6 +221,13 @@ describe('installRichEditorTransformErrorRecovery', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('repairs null fragment append failures from invalid document model fills', () => {
|
||||
expectDocumentRepairRecovery(
|
||||
nullFragmentAppendError(),
|
||||
'null_fragment_append',
|
||||
)
|
||||
})
|
||||
|
||||
it('recovers stale block-reference transactions from toolbar actions', () => {
|
||||
const { currentDoc, view } = createView(new Error(
|
||||
'Block with ID 6c1c3bb4-e218-4f00-aaf5-40606852d286 not found',
|
||||
|
||||
Reference in New Issue
Block a user