feat(agent): 分销商详情改为在后台独立新页面选项卡中打开
这个提交包含在:
70
tests/verify_agent_detail_tab.js
普通文件
70
tests/verify_agent_detail_tab.js
普通文件
@@ -0,0 +1,70 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const vm = require('vm');
|
||||
|
||||
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. 验证 agent.js
|
||||
const agentJsPath = path.resolve(__dirname, '../public/assets/js/backend/shopro/commission/agent.js');
|
||||
assert(fs.existsSync(agentJsPath), 'agent.js 文件存在');
|
||||
const agentJsContent = fs.readFileSync(agentJsPath, 'utf-8');
|
||||
|
||||
assert(agentJsContent.includes('Backend.api.addtabs(url, title)'), 'agent.js 中 onDetail 包含 Backend.api.addtabs 选项卡打开');
|
||||
assert(agentJsContent.includes('top.Backend.api.addtabs(url, title)'), 'agent.js 中 onDetail 兼容 top.Backend.api.addtabs 顶层打开');
|
||||
assert(agentJsContent.includes('Fast.api.addtabs(url, title)'), 'agent.js 中 onDetail 兼容 Fast.api.addtabs');
|
||||
assert(agentJsContent.includes('queryAgentId'), 'agent.js 中 detail 页面使用 queryAgentId 兼容多种 URL 参数传参');
|
||||
assert(agentJsContent.includes('function onBack()'), 'agent.js 中 detail 页面包含 onBack 方法');
|
||||
assert(agentJsContent.includes('top.Backend.api.closetabs()'), 'agent.js 中 onBack 支持 closetabs 关闭当前选项卡');
|
||||
assert(agentJsContent.includes('onBack,') || agentJsContent.includes('onBack'), 'agent.js detail return 中导出 onBack');
|
||||
|
||||
// 2. 验证 agent/index.html
|
||||
const agentIndexPath = path.resolve(__dirname, '../application/admin/view/shopro/commission/agent/index.html');
|
||||
assert(fs.existsSync(agentIndexPath), 'agent/index.html 文件存在');
|
||||
const agentIndexContent = fs.readFileSync(agentIndexPath, 'utf-8');
|
||||
|
||||
const detailCallCount = (agentIndexContent.match(/onDetail\(scope\.row\.user_id,\s*scope\.row\)/g) || []).length;
|
||||
assert(detailCallCount === 3, `agent/index.html 3处操作列均传递 (user_id, scope.row) [实际匹配: ${detailCallCount}]`);
|
||||
|
||||
// 3. 验证 agent/detail.html
|
||||
const agentDetailPath = path.resolve(__dirname, '../application/admin/view/shopro/commission/agent/detail.html');
|
||||
assert(fs.existsSync(agentDetailPath), 'agent/detail.html 文件存在');
|
||||
const agentDetailContent = fs.readFileSync(agentDetailPath, 'utf-8');
|
||||
|
||||
assert(agentDetailContent.includes('detail-header-bar'), 'agent/detail.html 包含顶部导航栏 detail-header-bar');
|
||||
assert(agentDetailContent.includes('@click="onBack"'), 'agent/detail.html 包含返回按钮');
|
||||
assert(agentDetailContent.includes('height: 100vh'), 'agent/detail.html 设置 100vh 满屏适应选项卡');
|
||||
assert(agentDetailContent.includes('min-height: 450px') && agentDetailContent.includes('height: auto'), 'agent/detail.html 优化 agent-content 高度自适应');
|
||||
|
||||
// 4. 验证 user.js 与 user/detail.html
|
||||
const userJsPath = path.resolve(__dirname, '../public/assets/js/backend/shopro/user/user.js');
|
||||
const userDetailPath = path.resolve(__dirname, '../application/admin/view/shopro/user/user/detail.html');
|
||||
assert(fs.existsSync(userJsPath), 'user.js 文件存在');
|
||||
assert(fs.existsSync(userDetailPath), 'user/detail.html 文件存在');
|
||||
|
||||
const userJsContent = fs.readFileSync(userJsPath, 'utf-8');
|
||||
const userDetailContent = fs.readFileSync(userDetailPath, 'utf-8');
|
||||
|
||||
assert(userJsContent.includes('function onOpenAgentDetail(id)'), 'user.js 包含 onOpenAgentDetail 方法');
|
||||
assert(userJsContent.includes('Backend.api.addtabs(url, title)'), 'user.js onOpenAgentDetail 使用 addtabs 打开选项卡');
|
||||
assert(userDetailContent.includes('@click="onOpenAgentDetail(state.detail.id)"'), 'user/detail.html 调用 onOpenAgentDetail');
|
||||
|
||||
console.log("\n--------------------------------------------------------");
|
||||
console.log(`测试执行结果: 通过 ${passed} 项, 失败 ${failed} 项`);
|
||||
console.log("========================================================");
|
||||
|
||||
process.exit(failed === 0 ? 0 : 1);
|
||||
在新工单中引用
屏蔽一个用户