Files
memind/wechat-cursor-page-delivery.test.mjs
T
john 644f7fc632
Memind CI / Test, build, and release guards (push) Has been cancelled
fix(wechat): add cursor channel modules required by wechat-mp imports
Ship the WeChat Cursor executor helpers referenced by the page delivery path so tests and runtime imports resolve consistently.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-26 21:14:36 +08:00

39 lines
1.6 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import {
isWechatCursorChannelReply,
prepareWechatCursorPageDelivery,
} from './wechat-cursor-page-delivery.mjs';
test('prepareWechatCursorPageDelivery repairs recent cursor html for wechat delivery', () => {
const publishDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wechat-cursor-delivery-'));
fs.mkdirSync(path.join(publishDir, 'public'), { recursive: true });
const htmlPath = path.join(publishDir, 'public', 'cursor-page.html');
fs.writeFileSync(htmlPath, '<html><head><title>Cursor Page</title></head><body><main>hi</main></body></html>');
const now = Date.now();
fs.utimesSync(htmlPath, now / 1000, now / 1000);
const reply = prepareWechatCursorPageDelivery({
reply: {
text: '已由 TKMind 智趣完成执行,并通过平台文件验收。',
requestMessages: [],
},
intent: { agentText: '帮我做一个简单测试页面', displayText: '帮我做一个简单测试页面' },
publishDir,
requestStartedAt: now - 1000,
topic: '简单测试页面',
buildCanonicalUrl: (relativePath) =>
`https://example.com/MindSpace/user-1/${String(relativePath).replace(/^\/+/, '')}`,
});
assert.equal(isWechatCursorChannelReply(reply), true);
assert.match(reply.text, /https:\/\/example.com\/MindSpace\/user-1\//);
const content = fs.readFileSync(htmlPath, 'utf8');
assert.match(content, /mindspace-cover/i);
assert.match(content, /platform-brand/i);
assert.ok(Buffer.byteLength(content, 'utf8') >= 512);
});