fix(npcs): stop TipTap crash black screen in secondary windows
Guard TipTap getHTML under StrictMode, wrap secondary window roots in WindowErrorBoundary, and add stability regression tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { readTipTapHtmlSafe } from './tiptapEditorSafe';
|
||||
|
||||
void test('readTipTapHtmlSafe: null / destroyed → null', () => {
|
||||
assert.equal(readTipTapHtmlSafe(null), null);
|
||||
assert.equal(readTipTapHtmlSafe(undefined), null);
|
||||
assert.equal(
|
||||
readTipTapHtmlSafe({
|
||||
isDestroyed: true,
|
||||
getHTML: () => '<p>x</p>',
|
||||
}),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
void test('readTipTapHtmlSafe: getHTML throw → null', () => {
|
||||
assert.equal(
|
||||
readTipTapHtmlSafe({
|
||||
isDestroyed: false,
|
||||
getHTML: () => {
|
||||
throw new TypeError("Cannot read properties of null (reading 'cached')");
|
||||
},
|
||||
}),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
void test('readTipTapHtmlSafe: ok → html', () => {
|
||||
assert.equal(
|
||||
readTipTapHtmlSafe({
|
||||
isDestroyed: false,
|
||||
getHTML: () => '<p>ok</p>',
|
||||
}),
|
||||
'<p>ok</p>',
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user