Files
memind/mindspace-geo-tags.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.6 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
buildGeoStructuredData,
injectGeoTags,
} from './mindspace-geo-tags.mjs';
test('buildGeoStructuredData returns Article schema', () => {
const html = `<!doctype html><html><head>
<title>仙居玩水</title>
<meta name="description" content="淡竹白溪攻略">
</head><body><h1>仙居玩水</h1></body></html>`;
const payload = buildGeoStructuredData(html, {
origin: 'https://m.tkmind.cn',
pageUrl: 'https://m.tkmind.cn/u/john/pages/demo',
publication: { publicUrl: '/u/john/pages/demo' },
});
assert.equal(payload['@type'], 'Article');
assert.equal(payload.headline, '仙居玩水');
assert.match(payload.description, /淡竹白溪/);
});
test('buildGeoStructuredData auto extracts FAQ from headings', () => {
const html = `<!doctype html><html><head><title>Demo</title></head><body>
<h2>适合谁去</h2><p>适合亲子家庭与轻徒步爱好者,全程难度较低。</p>
</body></html>`;
const payload = buildGeoStructuredData(html, {
origin: 'https://m.tkmind.cn',
pageUrl: 'https://m.tkmind.cn/u/john/pages/demo',
});
assert.equal(payload.hasPart['@type'], 'FAQPage');
assert.equal(payload.hasPart.mainEntity[0].name, '适合谁去');
});
test('injectGeoTags appends json-ld script', () => {
const html = '<html><head><title>Demo</title></head><body></body></html>';
const next = injectGeoTags(html, {
origin: 'https://m.tkmind.cn',
pageUrl: 'https://m.tkmind.cn/u/john/pages/demo',
});
assert.match(next, /<script type="application\/ld\+json">/);
});