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 = `苏州攻略

苏州攻略

最佳季节

春秋两季最适合游览苏州园林与古镇。

`; 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 = 'Demo

Demo

'; 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 = 'Demo Page

Demo Page

'; 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 = ``; const next = upsertMindspaceGeoMeta(html, { summary: '新摘要', keywords: ['a', 'b'], faq: [{ q: 'Q', a: 'A'.repeat(12) }] }); assert.match(next, /新摘要/); assert.doesNotMatch(next, /旧/); });