fix: recover procedure editor schema errors

This commit is contained in:
lucaronin
2026-05-14 09:55:20 +02:00
parent 3fa1d34c32
commit ff4939fb29
3 changed files with 80 additions and 0 deletions

View File

@@ -45,6 +45,9 @@ describe('isRecoverableEditorTransformError', () => {
it('recognizes ProseMirror transform and mismatched transaction failures', () => {
expect(isRecoverableEditorTransformError(transformError())).toBe(true)
expect(isRecoverableEditorTransformError(new RangeError('Applying a mismatched transaction'))).toBe(true)
expect(isRecoverableEditorTransformError(new RangeError(
'Invalid content for node blockContainer: <paragraph("Procedures are long-running"), blockGroup(blockContainer(bulletListItem("Step")))>',
))).toBe(true)
expect(isRecoverableEditorTransformError(new Error('unrelated'))).toBe(false)
})
})
@@ -74,6 +77,20 @@ describe('installRichEditorTransformErrorRecovery', () => {
})
})
it('recovers invalid-content schema transactions from mixed paragraph and list editing', () => {
const schemaError = new RangeError(
'Invalid content for node blockContainer: <paragraph("Procedures are long-running"), blockGroup(blockContainer(bulletListItem("Step")))>',
)
const { currentDoc, view } = createView(schemaError)
installRichEditorTransformErrorRecovery(view)
expect(() => view.dispatch({ before: currentDoc })).not.toThrow()
expect(trackEvent).toHaveBeenCalledWith('rich_editor_transform_error_recovered', {
reason: 'transform_error',
})
})
it('keeps non-ProseMirror dispatch failures visible', () => {
const { view } = createView(new Error('plugin failed'))