76 行
4.3 KiB
JavaScript
76 行
4.3 KiB
JavaScript
const { execSync } = require('child_process');
|
||
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. 本地视图文件检查
|
||
console.log("一、本地模板与样式规则检查:");
|
||
const addHtmlPath = path.resolve(__dirname, '../../application/admin/view/shopro/goods/goods/add.html');
|
||
const addHtmlContent = fs.readFileSync(addHtmlPath, 'utf-8');
|
||
|
||
assert(addHtmlContent.includes('background-color: #f4f6fa !important;'), '设置了页面整体 #f4f6fa 浅灰底色');
|
||
assert(addHtmlContent.includes('border-radius: 10px;'), '表单面板采用了 10px 现代圆角卡片化容器');
|
||
assert(addHtmlContent.includes('box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);'), '表单面板具备柔和微阴影提升层级立体感');
|
||
assert(addHtmlContent.includes('width: 520px !important;'), '优化了 sa-w-360 输入框宽度为 520px,消除宽屏孤立空白');
|
||
assert(addHtmlContent.includes('<el-form-item label="商品类型">'), '商品类型切换卡片被包裹在 el-form-item 中,与下列表单项目严格对齐');
|
||
assert(addHtmlContent.includes('goods-type-wrap'), '商品类型采用了专门的弹性布局与间距容器');
|
||
assert(addHtmlContent.includes('请选择商品分类'), '商品分类选择框增加了友好的空态占位提示');
|
||
assert(addHtmlContent.includes('.goods-form .warning'), '提示信息警告文本升级为规范统一的 Info Badge 样式');
|
||
assert(!addHtmlContent.includes('</el-input>\n </el-input>'), '排除了原模板中残留的多余关闭标签');
|
||
|
||
assert(addHtmlContent.includes('.editor-wrap .note-editable') && addHtmlContent.includes('620px !important;'), 'add.html 样式中成功将编辑器高度拉高至 620px (min-height: 600px)');
|
||
|
||
const goodsJsPath = path.resolve(__dirname, '../../public/assets/js/backend/shopro/goods/goods.js');
|
||
const goodsJsContent = fs.readFileSync(goodsJsPath, 'utf-8');
|
||
assert(goodsJsContent.includes("'height': '620px'"), 'goods.js 中 initEditor 已配置 620px 高度拉高逻辑');
|
||
|
||
// 2. 线上服务器部署一致性验证
|
||
console.log("\n二、线上服务器部署检查:");
|
||
try {
|
||
const remoteCheckCmd = `sshpass -p 'Bjsslxz1' ssh -o StrictHostKeyChecking=no root@118.184.172.94 "
|
||
grep -c 'background-color: #f4f6fa' /www/wwwroot/henglian.gynhc.com/application/admin/view/shopro/goods/goods/add.html
|
||
grep -c 'label=\\"商品类型\\"' /www/wwwroot/henglian.gynhc.com/application/admin/view/shopro/goods/goods/add.html
|
||
grep -c '620px' /www/wwwroot/henglian.gynhc.com/application/admin/view/shopro/goods/goods/add.html
|
||
grep -c '620px' /www/wwwroot/henglian.gynhc.com/public/assets/js/backend/shopro/goods/goods.js
|
||
"`;
|
||
const remoteOutput = execSync(remoteCheckCmd, { encoding: 'utf-8' });
|
||
const lines = remoteOutput.trim().split('\n');
|
||
const bgMatches = parseInt(lines[lines.length - 4] || '0', 10);
|
||
const labelMatches = parseInt(lines[lines.length - 3] || '0', 10);
|
||
const addHtml620Matches = parseInt(lines[lines.length - 2] || '0', 10);
|
||
const goodsJs620Matches = parseInt(lines[lines.length - 1] || '0', 10);
|
||
|
||
assert(bgMatches >= 1, `线上 add.html 已生效背景色优化 (匹配数: ${bgMatches})`);
|
||
assert(labelMatches >= 1, `线上 add.html 已生效商品类型对齐优化 (匹配数: ${labelMatches})`);
|
||
assert(addHtml620Matches >= 1, `线上 add.html 已生效编辑器拉高至 620px (匹配数: ${addHtml620Matches})`);
|
||
assert(goodsJs620Matches >= 1, `线上 goods.js 已生效编辑器拉高至 620px (匹配数: ${goodsJs620Matches})`);
|
||
} catch (err) {
|
||
console.log(' [INFO] 线上环境尚未同步或需要部署:', err.message);
|
||
}
|
||
|
||
console.log("\n========================================================");
|
||
console.log(` 测试阶段统计:通过 ${passed} 项,失败 ${failed} 项`);
|
||
console.log("========================================================");
|
||
|
||
if (failed > 0) {
|
||
process.exit(1);
|
||
} else {
|
||
process.exit(0);
|
||
}
|