Files
memind/mindspace-seo-geo-disk.test.mjs
T
john 357e26ab49
Memind CI / Test, build, and release guards (pull_request) Failing after 7m12s
Memind CI / Test, build, and release guards (push) Has been cancelled
feat(seo-geo): 落盘自动补齐与 143 全量回填支持
Finish/交付写盘前自动回填 mindspace-geo,扩展 storage publications 扫描与 geo meta 解析,并增加 143 生产回填脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 10:26:02 +08:00

34 lines
1.2 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import test from 'node:test';
import {
materializeMindspaceSeoGeoOnDisk,
prepareMindspacePublicHtmlForDisk,
} from './mindspace-seo-geo-disk.mjs';
test('prepareMindspacePublicHtmlForDisk injects mindspace-geo for public html', () => {
const html = '<html><head><title>Demo</title></head><body><h1>Demo</h1></body></html>';
const next = prepareMindspacePublicHtmlForDisk(html, {
htmlFilePath: '/tmp/user/public/demo.html',
});
assert.match(next, /name="mindspace-geo"/);
assert.match(next, /name="description"/);
});
test('materializeMindspaceSeoGeoOnDisk writes backfilled html to disk', () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'seo-geo-disk-'));
const filePath = path.join(dir, 'public', 'page.html');
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(
filePath,
'<html><head><title>Disk Demo</title></head><body><h1>Disk Demo</h1></body></html>',
'utf8',
);
const result = materializeMindspaceSeoGeoOnDisk(filePath);
assert.equal(result.changed, true);
const saved = fs.readFileSync(filePath, 'utf8');
assert.match(saved, /name="mindspace-geo"/);
});