87 行
2.9 KiB
JavaScript
87 行
2.9 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
let passed = 0;
|
|
let failed = 0;
|
|
|
|
function assert(condition, testName, detail = '') {
|
|
if (condition) {
|
|
console.log(` [PASS] ${testName}`);
|
|
passed++;
|
|
} else {
|
|
console.error(` [FAIL] ${testName} - ${detail}`);
|
|
failed++;
|
|
}
|
|
}
|
|
|
|
console.log("========================================================");
|
|
console.log(" 我的dmepa页面高端重构与「马币市值」规范 TDD 自动化测试");
|
|
console.log("========================================================\n");
|
|
|
|
const madowPagePath = path.resolve(__dirname, '../uniapp/pages/commission/madow.vue');
|
|
assert(fs.existsSync(madowPagePath), 'madow.vue 页面文件存在');
|
|
|
|
const content = fs.readFileSync(madowPagePath, 'utf-8');
|
|
|
|
// 1. 文案升级契约:文案去掉“马币”二字,更新为“市值 1 dmepa”
|
|
assert(
|
|
/市值\s*1\s*DMEPA\s*≈/i.test(content),
|
|
'页面包含核心文案「市值 1 DMEPA ≈」'
|
|
);
|
|
assert(
|
|
!content.includes('马币市值 1 dmepa'),
|
|
'旧文案「马币市值」中“马币”已彻底移除'
|
|
);
|
|
|
|
// 2. 资产卡片结构与指标展示
|
|
assert(
|
|
content.includes('formatInt') && content.includes('state.info.madow'),
|
|
'卡片核心指标正确绑定持仓dmepa且保留整数格式化 formatInt'
|
|
);
|
|
assert(
|
|
content.includes('state.info.madow_rate'),
|
|
'卡片正确展示马币市值单价 state.info.madow_rate'
|
|
);
|
|
assert(
|
|
content.includes('state.info.madow_value'),
|
|
'卡片正确展示折合市值/预估市值 state.info.madow_value'
|
|
);
|
|
|
|
// 3. 高端交互与规则弹窗
|
|
assert(
|
|
content.includes('su-popup') && (content.includes('showHelp') || content.includes('showRule')),
|
|
'规则说明升级为 su-popup 优雅弹窗结构'
|
|
);
|
|
assert(
|
|
(content.includes('市值') || content.includes('马币市值')) && (content.includes('随全平台订单') || content.includes('增值') || content.includes('核算')),
|
|
'规则说明文字中涵盖市值与增值核算说明'
|
|
);
|
|
|
|
// 4. 每日明细流水卡片与数据标签
|
|
assert(
|
|
content.includes('v-for="') && content.includes('state.list'),
|
|
'每日明细流水正确遍历 state.list'
|
|
);
|
|
assert(
|
|
content.includes('user_count') && content.includes('gmv'),
|
|
'明细卡片保留当日参与人数与 GMV 展示'
|
|
);
|
|
assert(
|
|
content.includes('s-empty') && content.includes('uni-load-more'),
|
|
'保留优雅空状态 s-empty 与加载更多 uni-load-more'
|
|
);
|
|
|
|
// 5. 数据交互方法
|
|
assert(
|
|
content.includes('getMadow') && content.includes('onPullDownRefresh') && content.includes('onReachBottom'),
|
|
'包含完整的下拉刷新与触底分页加载逻辑'
|
|
);
|
|
|
|
console.log("\n--------------------------------------------------------");
|
|
console.log(`测试执行结果: 通过 ${passed} 项, 失败 ${failed} 项`);
|
|
console.log("========================================================\n");
|
|
|
|
if (failed > 0) {
|
|
process.exit(1);
|
|
}
|