140 行
6.7 KiB
JavaScript
140 行
6.7 KiB
JavaScript
/**
|
|
* uniapp 退款与售后功能关闭专项自动化验证测试
|
|
* 覆盖文件:
|
|
* 1. uniapp/sheep/components/s-order-card/s-order-card.vue (个人中心订单卡片)
|
|
* 2. uniapp/pages/order/list.vue (订单列表)
|
|
* 3. uniapp/pages/order/detail.vue (订单详情)
|
|
* 4. uniapp/sheep/router/index.js (全局路由拦截)
|
|
* 5. uniapp/pages/order/aftersale/apply.vue (售后申请页面兜底防护)
|
|
* 6. uniapp/pages/order/aftersale/list.vue (售后列表页面兜底防护)
|
|
* 7. uniapp/pages/order/aftersale/detail.vue (售后详情页面兜底防护)
|
|
* 8. uniapp/pages/order/aftersale/log.vue (售后日志页面兜底防护)
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
let passCount = 0;
|
|
let failCount = 0;
|
|
|
|
function assert(condition, message) {
|
|
if (condition) {
|
|
console.log(` \x1b[32m[PASS]\x1b[0m ${message}`);
|
|
passCount++;
|
|
} else {
|
|
console.error(` \x1b[31m[FAIL]\x1b[0m ${message}`);
|
|
failCount++;
|
|
}
|
|
}
|
|
|
|
console.log('========================================================');
|
|
console.log(' uniapp 退款与售后功能关闭验证测试');
|
|
console.log('========================================================\n');
|
|
|
|
// 1. 个人中心订单卡片 (s-order-card.vue)
|
|
const orderCardPath = path.resolve(__dirname, '../uniapp/sheep/components/s-order-card/s-order-card.vue');
|
|
assert(fs.existsSync(orderCardPath), 's-order-card.vue 文件存在');
|
|
if (fs.existsSync(orderCardPath)) {
|
|
const content = fs.readFileSync(orderCardPath, 'utf-8');
|
|
assert(!content.includes("title: '售后单'"), 's-order-card 不再包含“售后单”菜单项');
|
|
assert(!content.includes("type: 'aftersale'"), 's-order-card 不再包含 aftersale 类型的角标');
|
|
assert(content.includes("title: '待发货'"), 's-order-card 已平滑切换为“待发货”');
|
|
assert(content.includes("type: 'nosend'"), 's-order-card “待发货”绑定 nosend 待发货角标');
|
|
assert(content.includes("value: '2'"), 's-order-card “待发货”指向 tabMaps 对应索引');
|
|
}
|
|
|
|
// 2. 订单列表 (list.vue)
|
|
const orderListPath = path.resolve(__dirname, '../uniapp/pages/order/list.vue');
|
|
assert(fs.existsSync(orderListPath), 'order/list.vue 文件存在');
|
|
if (fs.existsSync(orderListPath)) {
|
|
const content = fs.readFileSync(orderListPath, 'utf-8');
|
|
assert(!content.includes("btns.includes('aftersale')"), 'order/list.vue 商品条目已移除“申请售后”按钮');
|
|
assert(!content.includes("btns.includes('re_aftersale')"), 'order/list.vue 商品条目已移除“重新售后”按钮');
|
|
assert(!content.includes("btns.includes('aftersale_info')"), 'order/list.vue 商品条目已移除“售后详情”按钮');
|
|
assert(!content.includes("btns.includes('apply_refund')"), 'order/list.vue 订单条目已移除“申请退款”按钮');
|
|
assert(!content.includes("btns.includes('re_apply_refund')"), 'order/list.vue 订单条目已移除“重新退款”按钮');
|
|
}
|
|
|
|
// 3. 订单详情 (detail.vue)
|
|
const orderDetailPath = path.resolve(__dirname, '../uniapp/pages/order/detail.vue');
|
|
assert(fs.existsSync(orderDetailPath), 'order/detail.vue 文件存在');
|
|
if (fs.existsSync(orderDetailPath)) {
|
|
const content = fs.readFileSync(orderDetailPath, 'utf-8');
|
|
assert(!content.includes("btns.includes('aftersale')"), 'order/detail.vue 商品卡片已移除“申请售后”按钮');
|
|
assert(!content.includes("btns.includes('re_aftersale')"), 'order/detail.vue 商品卡片已移除“重新售后”按钮');
|
|
assert(!content.includes("btns.includes('aftersale_info')"), 'order/detail.vue 商品卡片已移除“售后详情”按钮');
|
|
assert(!content.includes("btns?.includes('apply_refund')"), 'order/detail.vue 底部操作栏已移除“申请退款”按钮');
|
|
assert(!content.includes("btns?.includes('re_apply_refund')"), 'order/detail.vue 底部操作栏已移除“重新退款”按钮');
|
|
}
|
|
|
|
// 4. 全局路由拦截 (router/index.js)
|
|
const routerPath = path.resolve(__dirname, '../uniapp/sheep/router/index.js');
|
|
assert(fs.existsSync(routerPath), 'router/index.js 文件存在');
|
|
if (fs.existsSync(routerPath)) {
|
|
const content = fs.readFileSync(routerPath, 'utf-8');
|
|
assert(
|
|
content.includes("startsWith(page, '/pages/order/aftersale')"),
|
|
'router/index.js 已拦截 /pages/order/aftersale 路由'
|
|
);
|
|
assert(
|
|
content.includes('退款与售后功能暂未开放'),
|
|
'router/index.js 具备友好中文拦截提示'
|
|
);
|
|
}
|
|
|
|
// 5. 售后申请页兜底 (aftersale/apply.vue)
|
|
const applyPath = path.resolve(__dirname, '../uniapp/pages/order/aftersale/apply.vue');
|
|
assert(fs.existsSync(applyPath), 'aftersale/apply.vue 文件存在');
|
|
if (fs.existsSync(applyPath)) {
|
|
const content = fs.readFileSync(applyPath, 'utf-8');
|
|
assert(
|
|
content.includes('退款与售后功能暂未开放'),
|
|
'aftersale/apply.vue onLoad 与 submit 具备拦截与防提交处理'
|
|
);
|
|
assert(
|
|
content.includes('sheep.$router.back()'),
|
|
'aftersale/apply.vue 具备自动退回上一页保护'
|
|
);
|
|
}
|
|
|
|
// 6. 售后列表页兜底 (aftersale/list.vue)
|
|
const aftersaleListPath = path.resolve(__dirname, '../uniapp/pages/order/aftersale/list.vue');
|
|
assert(fs.existsSync(aftersaleListPath), 'aftersale/list.vue 文件存在');
|
|
if (fs.existsSync(aftersaleListPath)) {
|
|
const content = fs.readFileSync(aftersaleListPath, 'utf-8');
|
|
assert(
|
|
content.includes('退款与售后功能暂未开放') && content.includes('sheep.$router.back()'),
|
|
'aftersale/list.vue 具备自动退回上一页保护'
|
|
);
|
|
}
|
|
|
|
// 7. 售后详情页兜底 (aftersale/detail.vue)
|
|
const aftersaleDetailPath = path.resolve(__dirname, '../uniapp/pages/order/aftersale/detail.vue');
|
|
assert(fs.existsSync(aftersaleDetailPath), 'aftersale/detail.vue 文件存在');
|
|
if (fs.existsSync(aftersaleDetailPath)) {
|
|
const content = fs.readFileSync(aftersaleDetailPath, 'utf-8');
|
|
assert(
|
|
content.includes('退款与售后功能暂未开放') && content.includes('sheep.$router.back()'),
|
|
'aftersale/detail.vue 具备自动退回上一页保护'
|
|
);
|
|
}
|
|
|
|
// 8. 售后进度日志页兜底 (aftersale/log.vue)
|
|
const aftersaleLogPath = path.resolve(__dirname, '../uniapp/pages/order/aftersale/log.vue');
|
|
assert(fs.existsSync(aftersaleLogPath), 'aftersale/log.vue 文件存在');
|
|
if (fs.existsSync(aftersaleLogPath)) {
|
|
const content = fs.readFileSync(aftersaleLogPath, 'utf-8');
|
|
assert(
|
|
content.includes('退款与售后功能暂未开放') && content.includes('sheep.$router.back()'),
|
|
'aftersale/log.vue 具备自动退回上一页保护'
|
|
);
|
|
}
|
|
|
|
console.log('\n========================================================');
|
|
console.log(` 测试结果: 共 ${passCount + failCount} 项, 通过: ${passCount}, 失败: ${failCount}`);
|
|
console.log('========================================================\n');
|
|
|
|
if (failCount > 0) {
|
|
process.exit(1);
|
|
}
|