Files
memind/wechat/handlers/sync-replies.test.mjs
T
john 7f06361bd3 Ship the page-focused follow reply with the news and shop updates.
Replace the subscribe welcome with page-generation examples, add the trial news003 WeChat share card, and let OneShop checkout return to an order or recharge page.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-25 14:30:20 +08:00

59 lines
2.1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
buildPlazaDiscoveryLines,
buildSubscribeWelcomeText,
buildWechatTextLink,
DEFAULT_PRODUCTION_BIND_URL,
DEFAULT_SUBSCRIBE_PLAZA_PICKS,
DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES,
} from './sync-replies.mjs';
test('buildWechatTextLink renders WeChat anchor without exposing raw url', () => {
assert.equal(
buildWechatTextLink(DEFAULT_PRODUCTION_BIND_URL, '点我绑定'),
`<a href="${DEFAULT_PRODUCTION_BIND_URL}">点我绑定</a>`,
);
});
test('buildSubscribeWelcomeText asks for a page and a shareable link', () => {
const text = buildSubscribeWelcomeText({ bindUrl: DEFAULT_PRODUCTION_BIND_URL });
assert.match(text, /欢迎关注 TKMind 智趣/);
assert.match(text, /你想做的页面/);
assert.match(text, /马上就能分享/);
assert.match(text, /对方点开就能看/);
assert.match(text, /点开看看做好的页面/);
for (const example of DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES) {
assert.ok(example.prompt.includes('生成页面'));
assert.ok(text.includes(`「${example.prompt}」`));
assert.ok(text.includes(`<a href="${example.url}">${example.label}</a>`));
}
assert.match(
text,
/<a href="[^"]*auth\/wechat\/authorize\?intent=login">点我绑定<\/a>/,
);
assert.doesNotMatch(text, /\nhttps:\/\/m\.tkmind\.cn/);
assert.doesNotMatch(text, /每日推送订阅/);
assert.doesNotMatch(text, /M发现/);
assert.doesNotMatch(text, /问答、写作、翻译/);
});
test('buildPlazaDiscoveryLines renders curated plaza category links', () => {
const lines = buildPlazaDiscoveryLines();
const text = lines.join('\n');
assert.match(text, /M发现/);
for (const pick of DEFAULT_SUBSCRIBE_PLAZA_PICKS) {
assert.ok(text.includes(pick.label));
assert.ok(text.includes(`<a href="${pick.url}">${pick.label}</a>`));
}
});
test('buildSubscribeWelcomeText omits the bind line when bindUrl is empty', () => {
const text = buildSubscribeWelcomeText({ bindUrl: '' });
assert.match(text, /生成页面/);
assert.doesNotMatch(text, /点我绑定/);
});