Files
DndGamePlayer/app/renderer/npcs/tiptapEditorSafe.test.ts
Ivan Fontosh 04c75cd725 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>
2026-07-30 09:10:47 +08:00

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>',
);
});