- wechat-miniprogram: 原生小程序,品牌化拆约+玄龙logo,API 指向 https://xhermes.aibay.asia - yaoyue-sever: Express 单文件 server.js + better-sqlite3,GLM glm-5.3-flash(thinking disabled) - 排除 node_modules/.env/*.db
103 lines
3.9 KiB
JavaScript
103 lines
3.9 KiB
JavaScript
// 微信小程序自动化测试 - 精简版(无截图)
|
|
const automator = require('miniprogram-automator');
|
|
|
|
const logs = { errors: [], warnings: [] };
|
|
|
|
async function runTest() {
|
|
console.log('连接自动化端口...');
|
|
const mp = await automator.connect({ wsEndpoint: 'ws://localhost:9420' });
|
|
console.log('✅ 连接成功\n');
|
|
|
|
mp.on('console', msg => {
|
|
const args = msg.args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ');
|
|
if (msg.type === 'error') { logs.errors.push(args); }
|
|
else if (msg.type === 'warn') { logs.warnings.push(args); }
|
|
});
|
|
|
|
// 系统信息
|
|
console.log('[1] 系统信息...');
|
|
const sys = await mp.systemInfo();
|
|
console.log(` 设备: ${sys.model}, 系统: ${sys.system}, SDK: ${sys.SDKVersion}`);
|
|
|
|
// 当前页面
|
|
console.log('[2] 当前页面...');
|
|
const curPage = await mp.currentPage();
|
|
console.log(` 路径: ${curPage.path}`);
|
|
|
|
// 页面数据
|
|
console.log('[3] 首页数据...');
|
|
const homeData = await curPage.data();
|
|
console.log(` 活动数量: ${homeData.activities?.length || 0}`);
|
|
if (homeData.activities?.length > 0) {
|
|
console.log(` 第一个活动: ${homeData.activities[0].title}`);
|
|
}
|
|
|
|
// reLaunch 到活动详情
|
|
console.log('[4] reLaunch 到 activity-6...');
|
|
const detail = await mp.reLaunch('/pages/activity-detail/index?id=activity-6');
|
|
console.log(` ✅ 已到达: ${detail.path}`);
|
|
|
|
await new Promise(r => setTimeout(r, 8000));
|
|
|
|
console.log('[5] 活动详情数据...');
|
|
const detailData = await detail.data();
|
|
console.log(` 标题: ${detailData.activity?.title}`);
|
|
console.log(` 参与者数: ${detailData.activity?.participants?.length || 0} 人 (participantCount: ${detailData.activity?.participantCount})`);
|
|
if (detailData.activity?.participants?.length > 0) {
|
|
detailData.activity.participants.forEach((p, i) => {
|
|
console.log(` ${i + 1}. ${p.user?.nickname || p.userId}`);
|
|
});
|
|
}
|
|
console.log(` AI推荐: ${detailData.aiRecommendation ? '✅ 已加载' : '❌ 未加载'}`);
|
|
console.log(` AI加载中: ${detailData.aiLoading}`);
|
|
if (detailData.aiRecommendation) {
|
|
console.log(` AI建议参与者: ${detailData.aiRecommendation.participants?.length || 0}`);
|
|
console.log(` AI建议: ${(detailData.aiRecommendation.suggestions || '').substring(0, 100)}...`);
|
|
}
|
|
|
|
// activity-7
|
|
console.log('[6] reLaunch 到 activity-7...');
|
|
const detail2 = await mp.reLaunch('/pages/activity-detail/index?id=activity-7');
|
|
await new Promise(r => setTimeout(r, 8000));
|
|
const data2 = await detail2.data();
|
|
console.log(` 标题: ${data2.activity?.title}`);
|
|
console.log(` 参与者: ${data2.activity?.participants?.length || 0} 人`);
|
|
|
|
// activity-8
|
|
console.log('[7] reLaunch 到 activity-8...');
|
|
const detail3 = await mp.reLaunch('/pages/activity-detail/index?id=activity-8');
|
|
await new Promise(r => setTimeout(r, 8000));
|
|
const data3 = await detail3.data();
|
|
console.log(` 标题: ${data3.activity?.title}`);
|
|
console.log(` 参与者: ${data3.activity?.participants?.length || 0} 人`);
|
|
|
|
// 返回首页
|
|
console.log('[8] 返回首页...');
|
|
await mp.reLaunch('/pages/home/index');
|
|
await new Promise(r => setTimeout(r, 3000));
|
|
|
|
// 总结
|
|
console.log('\n========================================');
|
|
console.log('测试结果');
|
|
console.log('========================================');
|
|
console.log(`错误: ${logs.errors.length}`);
|
|
console.log(`警告: ${logs.warnings.length}`);
|
|
|
|
const dateWarnings = logs.warnings.filter(w => w.includes && w.includes('new Date'));
|
|
console.log(`iOS日期格式警告: ${dateWarnings.length}`);
|
|
|
|
if (logs.errors.length > 0) {
|
|
console.log('\n错误列表:');
|
|
logs.errors.slice(0, 5).forEach((e, i) => console.log(` ${i + 1}. ${e.substring(0, 150)}`));
|
|
}
|
|
console.log('========================================');
|
|
|
|
await mp.disconnect();
|
|
process.exit(0);
|
|
}
|
|
|
|
runTest().catch(e => {
|
|
console.error('失败:', e.message);
|
|
process.exit(1);
|
|
});
|