fix: recover WeChat page thumbnail delivery
Memind CI / Test, build, and release guards (pull_request) Successful in 5m1s
Memind CI / Test, build, and release guards (pull_request) Successful in 5m1s
This commit is contained in:
+12
-18
@@ -864,11 +864,13 @@ test('loadWechatMpConfig requires full config and enable flag', () => {
|
||||
assert.equal(config.enabled, true);
|
||||
assert.equal(config.bindPath, '/auth/wechat/authorize?intent=login');
|
||||
assert.equal(config.requireFreshPageThumbnail, true);
|
||||
assert.equal(config.repairFreshPageThumbnail, false);
|
||||
assert.deepEqual(config.generatedImagePublicBaseUrls, [
|
||||
'https://example.com',
|
||||
'https://img.example.com',
|
||||
]);
|
||||
assert.equal(loadWechatMpConfig({ H5_WECHAT_MP_FRESH_PAGE_THUMBNAILS: '0' }).requireFreshPageThumbnail, false);
|
||||
assert.equal(loadWechatMpConfig({ H5_WECHAT_MP_FRESH_THUMBNAIL_REPAIR: '1' }).repairFreshPageThumbnail, true);
|
||||
});
|
||||
|
||||
test('verifyWechatMpSignature accepts valid signature', () => {
|
||||
@@ -4949,7 +4951,7 @@ test('wechat mp service exposes route status and can recreate route for bound us
|
||||
assert.equal(calls.includes('upserted'), true);
|
||||
});
|
||||
|
||||
test('wechat mp page delivery requires and verifies a current-run fresh thumbnail', async () => {
|
||||
test('wechat mp page delivery repairs one unambiguous fresh thumbnail missing from disk metadata', async () => {
|
||||
const token = 'token';
|
||||
const timestamp = '1710000000';
|
||||
const nonce = 'nonce';
|
||||
@@ -4958,6 +4960,7 @@ test('wechat mp page delivery requires and verifies a current-run fresh thumbnai
|
||||
const wechatPayloads = [];
|
||||
const generated = {
|
||||
ok: true,
|
||||
purpose: 'hero',
|
||||
jobId: 'job-fresh-page',
|
||||
source: { mimeType: 'image/webp', width: 1280, height: 720 },
|
||||
asset: {
|
||||
@@ -4967,18 +4970,13 @@ test('wechat mp page delivery requires and verifies a current-run fresh thumbnai
|
||||
workspaceRelativePath: 'public/images/fresh-page.webp',
|
||||
},
|
||||
};
|
||||
const pageHtml = previewReadyPageHtml({
|
||||
title: 'Fresh',
|
||||
subtitle: '本轮新缩略图',
|
||||
cover: generated.asset.htmlSrc,
|
||||
});
|
||||
const pageImage = await sharp({
|
||||
create: { width: 64, height: 64, channels: 3, background: '#3366cc' },
|
||||
}).webp().toBuffer();
|
||||
const eventFrame = (event) => `data: ${JSON.stringify(event)}\n\n`;
|
||||
const service = createBoundWechatService({
|
||||
token,
|
||||
config: { requireFreshPageThumbnail: true },
|
||||
config: { requireFreshPageThumbnail: true, repairFreshPageThumbnail: true },
|
||||
userAuth: {
|
||||
async resolveWorkingDir() {
|
||||
return workspaceRoot;
|
||||
@@ -5031,16 +5029,6 @@ test('wechat mp page delivery requires and verifies a current-run fresh thumbnai
|
||||
value: { content: [{ type: 'text', text: JSON.stringify(generated) }] },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'call-write-page',
|
||||
type: 'toolRequest',
|
||||
toolCall: {
|
||||
value: {
|
||||
name: 'sandbox-fs__write_file',
|
||||
arguments: { path: 'public/fresh.html', content: pageHtml },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
@@ -5073,10 +5061,12 @@ test('wechat mp page delivery requires and verifies a current-run fresh thumbnai
|
||||
assert.equal(body.user_message.metadata.memindRun.inlineImageMode, 'auto');
|
||||
assert.match(body.user_message.content[0].text, /服务号页面新缩略图硬要求/);
|
||||
assert.match(body.user_message.content[0].text, /本轮新生成资产/);
|
||||
assert.match(body.user_message.content[0].text, /禁止编造用户未提供的产品指标/);
|
||||
assert.match(body.user_message.content[0].text, /Agent 层只调用一次 generate_image/);
|
||||
fs.mkdirSync(path.dirname(htmlPath), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
htmlPath,
|
||||
pageHtml,
|
||||
previewReadyPageHtml({ title: 'Fresh', subtitle: '交付前磁盘副本' }),
|
||||
'utf8',
|
||||
);
|
||||
fs.mkdirSync(path.join(workspaceRoot, 'public', 'images'), { recursive: true });
|
||||
@@ -5116,6 +5106,10 @@ test('wechat mp page delivery requires and verifies a current-run fresh thumbnai
|
||||
assert.equal(result.status, 200);
|
||||
await result.task;
|
||||
assert.equal(fs.existsSync(path.join(workspaceRoot, 'public', 'fresh.thumbnail.svg')), true);
|
||||
assert.match(
|
||||
fs.readFileSync(htmlPath, 'utf8'),
|
||||
/"cover":"images\/fresh-page\.webp"/,
|
||||
);
|
||||
} finally {
|
||||
crypto.randomUUID = originalRandomUuid;
|
||||
fs.rmSync(workspaceRoot, { recursive: true, force: true });
|
||||
|
||||
Reference in New Issue
Block a user