75 行
2.4 KiB
JavaScript
75 行
2.4 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(" 钱包余额页面对齐黑金卡片与流水卡片流规格测试");
|
|
console.log("========================================================\n");
|
|
|
|
// 1. 验证 money.vue 存在性
|
|
const moneyVuePath = path.resolve(__dirname, '../uniapp/pages/user/wallet/money.vue');
|
|
assert(fs.existsSync(moneyVuePath), 'money.vue 文件存在');
|
|
const content = fs.readFileSync(moneyVuePath, 'utf-8');
|
|
|
|
// 2. 验证黑金尊享卡片结构
|
|
assert(
|
|
content.includes('asset-card') && content.includes('money-hero'),
|
|
'包含黑金资产卡片与核心大字数结构',
|
|
'未升级为 asset-card 结构'
|
|
);
|
|
|
|
// 3. 验证余额与资金操作按钮
|
|
assert(
|
|
content.includes('userInfo.money') &&
|
|
(content.includes('/pages/pay/recharge') || content.includes('onWithdraw') || content.includes('state.canWithdraw')),
|
|
'包含余额展示与资金操作入口',
|
|
'缺少余额绑定或资金操作入口'
|
|
);
|
|
|
|
// 4. 验证金额显隐切换
|
|
assert(
|
|
content.includes('showMoney') &&
|
|
(content.includes('cicon-eye') || content.includes('cicon-eye-off')),
|
|
'支持余额明文/掩码显隐切换',
|
|
'缺少显隐切换逻辑'
|
|
);
|
|
|
|
// 5. 验证流水列表卡片流升级
|
|
assert(
|
|
content.includes('log-card'),
|
|
'收支明细升级为独立 log-card 卡片流',
|
|
'仍采用普通边框单行列表'
|
|
);
|
|
|
|
// 6. 验证总收入与总支出统计
|
|
assert(
|
|
content.includes('pagination.income') && content.includes('pagination.expense'),
|
|
'包含当前筛选周期总收入与总支出统计',
|
|
'缺少收支统计'
|
|
);
|
|
|
|
// 7. 移除失效的 wallet_card_bg.png 依赖
|
|
assert(
|
|
!content.includes('wallet_card_bg.png'),
|
|
'移除对失效旧背景图 wallet_card_bg.png 的硬编码依赖',
|
|
'仍依赖旧版失效背景图'
|
|
);
|
|
|
|
console.log("\n--------------------------------------------------------");
|
|
console.log(`测试执行结果: 通过 ${passed} 项, 失败 ${failed} 项`);
|
|
console.log("========================================================");
|
|
|
|
process.exit(failed === 0 ? 0 : 1);
|