04c75cd725
Guard TipTap getHTML under StrictMode, wrap secondary window roots in WindowErrorBoundary, and add stability regression tests. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
886 B
TypeScript
39 lines
886 B
TypeScript
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>',
|
|
);
|
|
});
|