125 行
9.0 KiB
JavaScript
125 行
9.0 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. 验证 UserFilter.php 筛选器
|
|
const filterPath = path.resolve(__dirname, '../addons/shopro/filter/user/UserFilter.php');
|
|
assert(fs.existsSync(filterPath), 'UserFilter.php 文件存在');
|
|
const filterContent = fs.readFileSync(filterPath, 'utf-8');
|
|
|
|
assert(filterContent.includes('function identity('), 'UserFilter.php 包含 identity 多维身份筛选方法');
|
|
assert(filterContent.includes("'taster'"), 'UserFilter.php identity 支持品酒师筛选');
|
|
assert(filterContent.includes("'maker'"), 'UserFilter.php identity 支持创客筛选');
|
|
assert(filterContent.includes("'venue'"), 'UserFilter.php identity 支持酒道馆筛选');
|
|
assert(filterContent.includes("'county'"), 'UserFilter.php identity 支持区县代理筛选');
|
|
assert(filterContent.includes("'partner'"), 'UserFilter.php identity 支持合伙股东筛选');
|
|
assert(filterContent.includes('function makerLevel('), 'UserFilter.php 包含 makerLevel 创客级别细分筛选');
|
|
assert(filterContent.includes('function active30d('), 'UserFilter.php 包含 active30d 30天自购活跃状态筛选');
|
|
assert(filterContent.includes('function hasAgent('), 'UserFilter.php 包含 hasAgent 分销/收益档案筛选');
|
|
assert(filterContent.includes('function parentUser('), 'UserFilter.php 包含 parentUser 推荐人筛选');
|
|
|
|
// 2. 验证 User.php 控制器
|
|
const controllerPath = path.resolve(__dirname, '../application/admin/controller/shopro/user/User.php');
|
|
assert(fs.existsSync(controllerPath), 'User.php 控制器文件存在');
|
|
const controllerContent = fs.readFileSync(controllerPath, 'utf-8');
|
|
|
|
assert(controllerContent.includes("'rewards'"), 'User.php noNeedRight 包含 rewards 豁免配置');
|
|
assert(controllerContent.includes("'voucherPlans'"), 'User.php noNeedRight 包含 voucherPlans 豁免配置');
|
|
assert(controllerContent.includes("'team'"), 'User.php noNeedRight 包含 team 豁免配置');
|
|
assert(controllerContent.includes('IdentityService::attachProfile'), 'User.php index/detail 关联装配 IdentityService 身份和资产');
|
|
assert(controllerContent.includes('stats'), 'User.php index 返回包含 stats 数据概览');
|
|
assert(controllerContent.includes('voucher_available'), 'User.php 装配 voucher_available 可用券资产');
|
|
assert(controllerContent.includes('madow_value'), 'User.php 装配 madow_value dmepa预估估值');
|
|
assert(controllerContent.includes('push3Amounts'), 'User.php detail 包含推三返一循环金额计算');
|
|
assert(controllerContent.includes('next_push3_amount'), 'User.php detail 返回下一单预计返现金额');
|
|
assert(controllerContent.includes('active_status_text'), 'User.php detail 包含30天自购活跃状态解析');
|
|
assert(controllerContent.includes('income_total_cash'), 'User.php detail 包含累计现金收益统计');
|
|
assert(controllerContent.includes('function rewards($id)'), 'User.php 包含 rewards 收益流水查询接口');
|
|
assert(controllerContent.includes('function voucherPlans($id)'), 'User.php 包含 voucherPlans 兑换券释放计划查询接口');
|
|
assert(controllerContent.includes('function team($id)'), 'User.php 包含 team 团队成员查询接口');
|
|
|
|
// 3. 验证 sa-user-profile.js
|
|
const profileJsPath = path.resolve(__dirname, '../public/assets/addons/shopro/components/sa-user-profile.js');
|
|
assert(fs.existsSync(profileJsPath), 'sa-user-profile.js 组件文件存在');
|
|
const profileJsContent = fs.readFileSync(profileJsPath, 'utf-8');
|
|
|
|
assert(profileJsContent.includes('Backend.api.addtabs(url, title)'), 'sa-user-profile.js 点击会员头像/ID 使用 addtabs 打开选项卡');
|
|
assert(profileJsContent.includes('top.Backend.api.addtabs(url, title)'), 'sa-user-profile.js 支持 top.Backend.api.addtabs 顶层打开');
|
|
|
|
// 4. 验证 user.js
|
|
const userJsPath = path.resolve(__dirname, '../public/assets/js/backend/shopro/user/user.js');
|
|
assert(fs.existsSync(userJsPath), 'user.js 文件存在');
|
|
const userJsContent = fs.readFileSync(userJsPath, 'utf-8');
|
|
|
|
assert(userJsContent.includes('Backend.api.addtabs(url, title)'), 'user.js onDetail 使用 Backend.api.addtabs 选项卡打开');
|
|
assert(userJsContent.includes('top.Backend.api.addtabs(url, title)'), 'user.js onDetail 兼容 top.Backend.api.addtabs');
|
|
assert(userJsContent.includes('function onOpenAgentDetail(id)'), 'user.js 包含 onOpenAgentDetail 打开收益档案');
|
|
assert(userJsContent.includes('function onRecharge('), 'user.js 包含 onRecharge 快速充值方法');
|
|
assert(userJsContent.includes('queryUserId'), 'user.js detail 支持 queryUserId 灵活参数解析');
|
|
assert(userJsContent.includes('function onBack()'), 'user.js detail 包含 onBack 返回/关闭选项卡方法');
|
|
assert(userJsContent.includes('top.Backend.api.closetabs()'), 'user.js detail onBack 支持 closetabs 关闭当前选项卡');
|
|
assert(userJsContent.includes('partner_reward'), 'user.js detail 包含 partner_reward 收益流水 Tab 逻辑');
|
|
assert(userJsContent.includes('voucher_plan'), 'user.js detail 包含 voucher_plan 兑换券释放计划 Tab 逻辑');
|
|
assert(userJsContent.includes('team'), 'user.js detail 包含 team 团队下级 Tab 逻辑');
|
|
assert(userJsContent.includes('onShowFormula'), 'user.js detail 包含 onShowFormula 公式弹窗查看');
|
|
|
|
// 5. 验证 index.html
|
|
const indexPath = path.resolve(__dirname, '../application/admin/view/shopro/user/user/index.html');
|
|
assert(fs.existsSync(indexPath), 'user index.html 视图文件存在');
|
|
const indexContent = fs.readFileSync(indexPath, 'utf-8');
|
|
|
|
assert(indexContent.includes('stats-row'), 'index.html 包含数据概览 KPI 统计栏');
|
|
assert(indexContent.includes('state.stats.total_users'), 'index.html 统计栏展示全平台会员数');
|
|
assert(indexContent.includes('state.stats.maker_count'), 'index.html 统计栏展示创客团队骨干');
|
|
assert(indexContent.includes('state.stats.venue_count'), 'index.html 统计栏展示线下酒道馆');
|
|
assert(indexContent.includes('state.stats.county_count'), 'index.html 统计栏展示区县代理数');
|
|
assert(indexContent.includes('state.stats.partner_count'), 'index.html 统计栏展示合伙股东数');
|
|
assert(indexContent.includes('state.stats.active_count'), 'index.html 统计栏展示30日自购活跃数');
|
|
assert(indexContent.includes('推荐人'), 'index.html 包含推荐人列');
|
|
assert(indexContent.includes('业务身份'), 'index.html 包含业务身份列');
|
|
assert(indexContent.includes('30日自购活跃'), 'index.html 包含30日自购活跃状态列');
|
|
assert(indexContent.includes('active-dot'), 'index.html 包含活跃状态指示灯样式');
|
|
assert(indexContent.includes('收益中心资产'), 'index.html 包含收益中心资产列');
|
|
assert(indexContent.includes('dmepa与补贴券'), 'index.html 包含dmepa与补贴券列');
|
|
assert(indexContent.includes('onDetail(scope.row.id, scope.row)'), 'index.html 详情按钮正确传递参数触发选项卡');
|
|
assert(indexContent.includes('onOpenAgentDetail(scope.row.id)'), 'index.html 包含收益档案快捷入口');
|
|
|
|
// 6. 验证 detail.html
|
|
const detailPath = path.resolve(__dirname, '../application/admin/view/shopro/user/user/detail.html');
|
|
assert(fs.existsSync(detailPath), 'user detail.html 视图文件存在');
|
|
const detailContent = fs.readFileSync(detailPath, 'utf-8');
|
|
|
|
assert(detailContent.includes('height: 100vh'), 'detail.html 样式适配 100vh 全屏选项卡页面');
|
|
assert(detailContent.includes('detail-header-bar'), 'detail.html 包含顶部导航栏 detail-header-bar');
|
|
assert(detailContent.includes('@click="onBack"'), 'detail.html 包含 onBack 返回/关闭选项卡按钮');
|
|
assert(detailContent.includes('业务身份与二开权益体系'), 'detail.html 包含业务身份与二开权益看板');
|
|
assert(detailContent.includes('30天自购活跃窗口'), 'detail.html 包含30天自购活跃窗口看板');
|
|
assert(detailContent.includes('推三返一'), 'detail.html 包含推三返一循环进度展示');
|
|
assert(detailContent.includes('二开核心资产中枢'), 'detail.html 包含四大核心资产中枢看板');
|
|
assert(detailContent.includes('name="partner_reward"'), 'detail.html 包含收益中心流水 Tab');
|
|
assert(detailContent.includes('name="voucher_plan"'), 'detail.html 包含兑换券释放计划 Tab');
|
|
assert(detailContent.includes('name="team"'), 'detail.html 包含直推团队成员 Tab');
|
|
assert(detailContent.includes('formulaDialog'), 'detail.html 包含奖励测算公式与跳过记录详情弹窗');
|
|
|
|
console.log("\n--------------------------------------------------------");
|
|
console.log(`测试执行结果: 通过 ${passed} 项, 失败 ${failed} 项`);
|
|
console.log("========================================================");
|
|
|
|
process.exit(failed === 0 ? 0 : 1);
|