fix(wechat): repair share preview on disk for sanitized delivery artifacts
Memind CI / Test, build, and release guards (push) Failing after 6s
Memind CI / Test, build, and release guards (push) Failing after 6s
Production WeChat delivery strips localPath from artifacts, so share-preview auto-repair never wrote back to HTML. Resolve paths via publishDir + relativePath, repair at materialize and delivery prep, and pass h5Root from Portal so page.generate can patch missing meta before sending links. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -215,6 +215,32 @@ test('repairSharePreviewHtml injects missing description, cover, and platform br
|
||||
assert.match(repaired, /data-mindspace-page-tag="platform-brand"/);
|
||||
});
|
||||
|
||||
test('resolvePageGenerateOutcome repairs sanitized artifact using publishDir + relativePath', () => {
|
||||
const publishDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wechat-sanitized-'));
|
||||
const file = path.join(publishDir, 'public', 'page.html');
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
file,
|
||||
`<!doctype html><html><head><title>安吉攻略</title></head><body><main>${'x'.repeat(600)}</main></body></html>`,
|
||||
'utf8',
|
||||
);
|
||||
const artifact = {
|
||||
relativePath: 'public/page.html',
|
||||
url: 'https://m.tkmind.cn/MindSpace/u/public/page.html',
|
||||
exists: true,
|
||||
isHtmlDocument: true,
|
||||
sharePreview: { ok: false, reason: 'missing_mindspace_cover' },
|
||||
};
|
||||
const outcome = resolvePageGenerateOutcome({
|
||||
reply: { text: '页面已生成' },
|
||||
confirmedArtifacts: [artifact],
|
||||
topic: '帮我把这个安吉攻略生成页面',
|
||||
repairContext: { publishDir },
|
||||
});
|
||||
assert.equal(outcome.action, 'send');
|
||||
assert.equal(verifyArtifactSharePreview(artifact, { publishDir }).ok, true);
|
||||
});
|
||||
|
||||
test('resolvePageGenerateOutcome repairs and sends when html lacks share preview meta', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'wechat-preview-'));
|
||||
const file = path.join(dir, 'page.html');
|
||||
|
||||
Reference in New Issue
Block a user