Files
memind/mindspace-geo-backfill.test.mjs
john acca846856
Memind CI / Test, build, and release guards (pull_request) Failing after 4m17s
feat(seo-geo): 全页面 SEO/GEO 回填、统一检查与 Plaza 注入
引入批量回填与审计工具链,强制 mindspace-geo 元数据,扩展 sitemap/llms 收录 /learn,并为 Plaza 壳页注入 canonical/OG/JSON-LD;本地 593 页已通过 check:mindspace-cover。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 09:36:01 +08:00

43 lines
1.8 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
backfillMindspaceSeoGeoHtml,
buildMindspaceGeoPayload,
ensureSeoGeoWarningsFixed,
upsertMindspaceGeoMeta,
} from './mindspace-geo-backfill.mjs';
test('buildMindspaceGeoPayload derives summary and faq from page content', () => {
const html = `<!doctype html><html><head><title>苏州攻略</title></head><body>
<h1>苏州攻略</h1>
<h2>最佳季节</h2><p>春秋两季最适合游览苏州园林与古镇。</p>
</body></html>`;
const payload = buildMindspaceGeoPayload(html);
assert.match(payload.summary, /苏州/);
assert.ok(payload.keywords.length >= 2);
assert.equal(payload.faq[0].q, '最佳季节');
});
test('backfillMindspaceSeoGeoHtml inserts mindspace-geo and description', () => {
const html = '<html><head><title>Demo</title></head><body><h1>Demo</h1></body></html>';
const next = backfillMindspaceSeoGeoHtml(html);
assert.match(next, /name="description"/);
assert.match(next, /name="mindspace-geo"/);
assert.match(next, /name="mindspace-cover"/);
});
test('ensureSeoGeoWarningsFixed adds brand footer, raster cover, and outline', () => {
const html = '<html><head><title>Demo Page</title></head><body><h1>Demo Page</h1></body></html>';
const next = ensureSeoGeoWarningsFixed(html);
assert.match(next, /data-mindspace-page-tag="platform-brand"/);
assert.match(next, /data-mindspace-seo-outline="1"/);
assert.match(next, /tkmind-icon\.png/);
});
test('upsertMindspaceGeoMeta replaces existing geo meta', () => {
const html = `<html><head><meta name="mindspace-geo" content='{"summary":"旧"}'></head></html>`;
const next = upsertMindspaceGeoMeta(html, { summary: '新摘要', keywords: ['a', 'b'], faq: [{ q: 'Q', a: 'A'.repeat(12) }] });
assert.match(next, /新摘要/);
assert.doesNotMatch(next, /旧/);
});