Files
memind/mindspace-visual-editor.test.mjs
T
John 25d9c8c364 Add MindSpace visual page editor and Plaza local Tunnel deployment.
In-preview HTML editing with undo/redo sync replaces Agent patch auto-save; Plaza runs on local Mac via Cloudflare Tunnel with embed height and CSP fixes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 22:57:22 -07:00

29 lines
1.1 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
MINDSPACE_PAGE_CONTENT_MESSAGE,
buildEditablePreviewDocument,
} from './src/utils/mindspaceVisualEditor.ts';
test('buildEditablePreviewDocument injects visual editor into body', () => {
const html = '<!doctype html><html><head></head><body><p>Hi</p></body></html>';
const result = buildEditablePreviewDocument(html);
assert.match(result, /mindspace-visual-editor-style/);
assert.match(result, /mindspace-visual-editor-script/);
assert.match(result, /data-mindspace-editing/);
assert.match(result, /<p>Hi<\/p>/);
assert.match(result, new RegExp(MINDSPACE_PAGE_CONTENT_MESSAGE.replace(':', '\\:')));
});
test('buildEditablePreviewDocument wraps fragment html', () => {
const result = buildEditablePreviewDocument('<section>块</section>');
assert.match(result, /<section>块<\/section>/);
assert.match(result, /<\/body>/);
});
test('buildEditablePreviewDocument provides blank fallback', () => {
const result = buildEditablePreviewDocument('');
assert.match(result, /空白页面/);
});