Files
memind/mindspace-cover-meta.test.mjs
T
john e64cf52f23 fix(mindspace): restore publish guards and safe 103 goosed canary routing
Finish-sync guards now accept SEO/GEO disk enrichment instead of requiring
byte-identical HTML, and fragment writes no longer duplicate doctype. Users
canary mode keeps the full native pool while routing allowlisted identities
to :18015 without overriding memory settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-23 17:44:45 +08:00

30 lines
1.4 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { parseMindspaceCoverMeta, upsertMindspaceCoverMeta } from './mindspace-cover-meta.mjs';
test('upsertMindspaceCoverMeta replaces existing meta tag', () => {
const html = `<!doctype html><html><head>
<meta name="mindspace-cover" content='{"tag":"旧","emoji":"🌿"}'>
<title>Demo</title></head><body></body></html>`;
const next = upsertMindspaceCoverMeta(html, { tag: '旅行', emoji: '✈️', accent: '#eeb04e' });
const parsed = parseMindspaceCoverMeta(next);
assert.equal(parsed.tag, '旅行');
assert.equal(parsed.emoji, '✈️');
assert.equal(parsed.accent, '#eeb04e');
});
test('upsertMindspaceCoverMeta inserts meta into head when missing', () => {
const html = '<!doctype html><html><head><title>Demo</title></head><body></body></html>';
const next = upsertMindspaceCoverMeta(html, { tag: '美食', emoji: '🍜' });
assert.match(next, /name="mindspace-cover"/);
assert.equal(parseMindspaceCoverMeta(next).tag, '美食');
});
test('upsertMindspaceCoverMeta wraps fragments without duplicating doctype', () => {
const html = '<!doctype html><title>Guarded release</title>';
const next = upsertMindspaceCoverMeta(html, { tag: '精选页面', subtitle: 'Guarded release' });
assert.match(next, /^<!doctype html>/i);
assert.doesNotMatch(next, /<body>\s*<!doctype html>/i);
assert.match(next, /<title>Guarded release<\/title>/);
});