Compare commits

..

1 Commits

Author SHA1 Message Date
tkmind 1e4f6433ff feat(seo): 固化 m.tkmind.cn 百度验证、推送与 sitemap 去重
Memind CI / Test, build, and release guards (push) Failing after 3m54s
2026-09-16 08:45:14 +00:00
+7 -24
View File
@@ -230,43 +230,26 @@ test('convertGenericPageHtmlToWechatArticle leaves length clipping to layout', (
});
test('resolveWechatDraftThumbPath prefers hero image over thumbnail sidecar', () => {
const userId = 'test-user-hero-pref';
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'wechat-thumb-hero-'));
const publishDir = path.join(root, 'MindSpace', userId);
const publicDir = path.join(publishDir, 'public');
fs.mkdirSync(publicDir, { recursive: true });
const heroPath = path.join(publicDir, 'images', 'hero-ca5a45b835d8.webp');
fs.mkdirSync(path.dirname(heroPath), { recursive: true });
fs.writeFileSync(heroPath, Buffer.from('webp'));
fs.writeFileSync(path.join(publicDir, 'august-afternoon.thumbnail.png'), Buffer.from('png'));
const html = `<!DOCTYPE html><html><head><title>八月午后</title>
<meta name="mindspace-cover" content='{"cover":"images/hero-ca5a45b835d8.webp"}'></head>
<body><h1>标题</h1></body></html>`;
fs.writeFileSync(path.join(publicDir, 'august-afternoon.html'), html, 'utf8');
const userId = '1c99b83b-0454-474f-a5d2-129d34506a32';
const html = fs.readFileSync(`MindSpace/${userId}/public/august-afternoon.html`, 'utf8');
const resolved = resolveWechatDraftThumbPath(html, {
h5Root: root,
h5Root: process.cwd(),
userId,
workspaceRelativePath: 'public/august-afternoon.html',
publishDir,
publishDir: path.join(process.cwd(), 'MindSpace', userId),
});
assert.equal(resolved.source, 'hero');
assert.match(resolved.path ?? '', /hero-ca5a45b835d8\.webp$/);
});
test('resolveWechatDraftThumbPath falls back to raster sidecar when hero missing', () => {
const userId = 'test-user-sidecar-fallback';
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'wechat-thumb-sidecar-'));
const publishDir = path.join(root, 'MindSpace', userId);
const publicDir = path.join(publishDir, 'public');
fs.mkdirSync(publicDir, { recursive: true });
fs.writeFileSync(path.join(publicDir, 'august-afternoon.thumbnail.png'), Buffer.from('png'));
const userId = '1c99b83b-0454-474f-a5d2-129d34506a32';
const html = `<!DOCTYPE html><html><head><title>无 hero</title></head><body><h1>标题</h1></body></html>`;
fs.writeFileSync(path.join(publicDir, 'august-afternoon.html'), html, 'utf8');
const resolved = resolveWechatDraftThumbPath(html, {
h5Root: root,
h5Root: process.cwd(),
userId,
workspaceRelativePath: 'public/august-afternoon.html',
publishDir,
publishDir: path.join(process.cwd(), 'MindSpace', userId),
});
assert.equal(resolved.source, 'thumbnail-sidecar');
assert.match(resolved.path ?? '', /august-afternoon\.thumbnail\.png$/);