迁移892-without-redis分支全量功能

This commit is contained in:
wkc
2026-04-15 14:18:56 +08:00
parent 9fe1bffe0d
commit 79c5317414
97 changed files with 10922 additions and 232 deletions

View File

@@ -0,0 +1,34 @@
const fs = require('fs')
const path = require('path')
const assert = require('assert')
function read(relativePath) {
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8')
}
const personalCreateDialog = read('src/views/loanPricing/workflow/components/PersonalCreateDialog.vue')
const corporateCreateDialog = read('src/views/loanPricing/workflow/components/CorporateCreateDialog.vue')
assert(
!personalCreateDialog.includes('const validateIdNum ='),
'个人新增弹窗仍包含证件号码格式校验函数'
)
assert(
!corporateCreateDialog.includes('const validateIdNum ='),
'企业新增弹窗仍包含证件号码格式校验函数'
)
assert(
personalCreateDialog.includes("idNum: [") &&
personalCreateDialog.includes('{required: true, message: "证件号码不能为空", trigger: "blur"}'),
'个人新增弹窗证件号码规则应仅保留必填'
)
assert(
corporateCreateDialog.includes("idNum: [") &&
corporateCreateDialog.includes('{required: true, message: "证件号码不能为空", trigger: "blur"}'),
'企业新增弹窗证件号码规则应仅保留必填'
)
console.log('id number validation removal assertions passed')

View File

@@ -0,0 +1,30 @@
const fs = require('fs')
const path = require('path')
const assert = require('assert')
const loginViewSource = fs.readFileSync(
path.join(__dirname, '../src/views/login.vue'),
'utf8'
)
assert(
/loginForm:\s*\{[\s\S]*username:\s*""/.test(loginViewSource),
'登录页默认用户名应为空字符串'
)
assert(
/loginForm:\s*\{[\s\S]*password:\s*""/.test(loginViewSource),
'登录页默认密码应为空字符串'
)
assert(
/username:\s*username === undefined \? this\.loginForm\.username : username/.test(loginViewSource),
'登录页应继续支持从 cookie 回填用户名'
)
assert(
/password:\s*password === undefined \? this\.loginForm\.password : decrypt\(password\)/.test(loginViewSource),
'登录页应继续支持从 cookie 回填密码'
)
console.log('login default credentials assertions passed')

View File

@@ -0,0 +1,88 @@
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const vm = require('vm')
function loadModule(filePath, stubs = {}) {
const source = fs.readFileSync(filePath, 'utf8')
const exportedNames = []
const transformed = source
.replace(/^import .*$/gm, '')
.replace(/export function\s+([A-Za-z0-9_]+)\s*\(/g, (_, name) => {
exportedNames.push(name)
return `function ${name}(`
})
.replace(/export default\s+/g, 'module.exports = ')
const sandbox = {
module: { exports: {} },
exports: {},
require,
console,
process: {
env: {
VUE_APP_PASSWORD_TRANSFER_KEY: '1234567890abcdef'
}
},
...stubs
}
vm.runInNewContext(
`${transformed}\nmodule.exports = { ${exportedNames.join(', ')} };`,
sandbox,
{ filename: filePath }
)
return sandbox.module.exports
}
const passwordTransferModule = loadModule(
path.resolve(__dirname, '../src/utils/passwordTransfer.js'),
{ CryptoJS: require('crypto-js') }
)
const { encryptPasswordFields } = passwordTransferModule
const encrypted = encryptPasswordFields(
{ password: 'admin123', code: '8888' },
['password'],
'1234567890abcdef'
)
assert.notStrictEqual(encrypted.password, 'admin123')
assert.strictEqual(encrypted.code, '8888')
const request = config => config
const loginModule = loadModule(
path.resolve(__dirname, '../src/api/login.js'),
{ request, encryptPasswordFields }
)
const loginConfig = loginModule.login('admin', 'admin123', '8888', 'uuid-1')
assert.notStrictEqual(loginConfig.data.password, 'admin123')
assert.strictEqual(loginConfig.data.username, 'admin')
const registerConfig = loginModule.register({ username: 'u1', password: 'p1', confirmPassword: 'p1', code: '8888' })
assert.notStrictEqual(registerConfig.data.password, 'p1')
assert.strictEqual(registerConfig.data.confirmPassword, 'p1')
const userModule = loadModule(
path.resolve(__dirname, '../src/api/system/user.js'),
{
request,
encryptPasswordFields,
parseStrEmpty: value => value
}
)
const updatePwdConfig = userModule.updateUserPwd('oldPwd', 'newPwd')
assert.notStrictEqual(updatePwdConfig.data.oldPassword, 'oldPwd')
assert.notStrictEqual(updatePwdConfig.data.newPassword, 'newPwd')
const addUserConfig = userModule.addUser({ userName: 'u1', password: 'initPwd', nickName: 'n1' })
assert.notStrictEqual(addUserConfig.data.password, 'initPwd')
const resetUserPwdConfig = userModule.resetUserPwd(2, 'resetPwd')
assert.notStrictEqual(resetUserPwdConfig.data.password, 'resetPwd')
console.log('password-transfer-api test passed')

View File

@@ -0,0 +1,65 @@
const fs = require('fs')
const path = require('path')
const assert = require('assert')
function read(relativePath) {
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8')
}
const personalCreateDialog = read('src/views/loanPricing/workflow/components/PersonalCreateDialog.vue')
const personalDetail = read('src/views/loanPricing/workflow/components/PersonalWorkflowDetail.vue')
assert(
personalCreateDialog.includes('label="贷款用途"') && personalCreateDialog.includes('prop="loanPurpose"'),
'个人新增弹窗缺少贷款用途字段'
)
assert(
personalCreateDialog.includes('label="借款期限(年)"') && personalCreateDialog.includes('prop="loanTerm"'),
'个人新增弹窗缺少借款期限字段'
)
assert(
personalCreateDialog.includes("value=\"consumer\"") && personalCreateDialog.includes("value=\"business\""),
'个人新增弹窗缺少贷款用途选项'
)
assert(
personalCreateDialog.includes('loanTermOptions') &&
personalCreateDialog.includes("'1'") &&
personalCreateDialog.includes("'6'") &&
!personalCreateDialog.includes("'7'"),
'个人新增弹窗借款期限选项应限制为 1-6 年'
)
assert(
personalCreateDialog.includes('label="一类"') &&
personalCreateDialog.includes('label="二类"') &&
personalCreateDialog.includes('label="三类"') &&
!personalCreateDialog.includes('label="一线"'),
'个人新增弹窗抵质押类型选项未按 Excel 对齐'
)
assert(
!personalCreateDialog.includes('{required: true, message: "请选择抵质押类型", trigger: "change"}'),
'个人新增弹窗仍将抵质押类型设为必填'
)
assert(
personalCreateDialog.includes("bizProof: this.form.bizProof ? '1' : '0'") &&
personalCreateDialog.includes("loanLoop: this.form.loanLoop ? '1' : '0'") &&
personalCreateDialog.includes("collThirdParty: this.form.collThirdParty ? '1' : '0'"),
'个人新增弹窗开关字段未按 1/0 提交'
)
assert(
personalDetail.includes('label="贷款用途"') && personalDetail.includes('detailData.loanPurpose'),
'个人详情页缺少贷款用途展示'
)
assert(
personalDetail.includes("value === '1'") && personalDetail.includes("value === '0'"),
'个人详情页布尔格式化未兼容 1/0'
)
console.log('personal create input params assertions passed')

View File

@@ -0,0 +1,21 @@
const fs = require('fs')
const path = require('path')
const assert = require('assert')
function read(relativePath) {
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8')
}
const personalDetail = read('src/views/loanPricing/workflow/components/PersonalWorkflowDetail.vue')
assert(
/label="最终测算利率"/.test(personalDetail),
'个人流程详情左侧缺少“最终测算利率”标签'
)
assert(
/return this\.retailOutput\?\.finalCalculateRate \|\| '-'/.test(personalDetail),
'个人流程详情没有使用 finalCalculateRate 展示最终测算利率'
)
console.log('personal final calculate rate display assertions passed')

View File

@@ -0,0 +1,29 @@
const fs = require('fs')
const path = require('path')
const assert = require('assert')
function read(relativePath) {
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8')
}
const personalDetail = read('src/views/loanPricing/workflow/components/PersonalWorkflowDetail.vue')
const modelOutput = read('src/views/loanPricing/workflow/components/ModelOutputDisplay.vue')
assert(
personalDetail.includes('label="借款期限"') && personalDetail.includes('detailData.loanTerm'),
'个人详情页缺少借款期限展示'
)
const requiredRetailFields = [
'retailOutput.loanRateHistory',
'retailOutput.minRateProduct',
'retailOutput.smoothRange',
'retailOutput.finalCalculateRate',
'retailOutput.referenceRate'
]
requiredRetailFields.forEach((field) => {
assert(modelOutput.includes(field), `模型输出缺少字段展示: ${field}`)
})
console.log('retail display fields assertions passed')

View File

@@ -0,0 +1,27 @@
const fs = require('fs')
const path = require('path')
const assert = require('assert')
function read(relativePath) {
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8')
}
function assertModelOutputBeforeDetailCard(source, label) {
const modelOutputIndex = source.indexOf('<ModelOutputDisplay')
const detailCardIndex = source.indexOf('<el-card class="detail-card">')
assert(modelOutputIndex !== -1, `${label} 缺少模型输出卡片`)
assert(detailCardIndex !== -1, `${label} 缺少流程详情卡片`)
assert(
modelOutputIndex < detailCardIndex,
`${label} 的模型输出卡片应位于流程详情卡片上方`
)
}
const personalDetail = read('src/views/loanPricing/workflow/components/PersonalWorkflowDetail.vue')
const corporateDetail = read('src/views/loanPricing/workflow/components/CorporateWorkflowDetail.vue')
assertModelOutputBeforeDetailCard(personalDetail, '个人流程详情')
assertModelOutputBeforeDetailCard(corporateDetail, '企业流程详情')
console.log('workflow detail card order assertions passed')

View File

@@ -0,0 +1,52 @@
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const vm = require('vm')
function loadComponentOptions(filePath) {
const source = fs.readFileSync(filePath, 'utf8')
const scriptMatch = source.match(/<script>([\s\S]*?)<\/script>/)
if (!scriptMatch) {
throw new Error('未找到组件脚本内容')
}
const importNames = []
const importPattern = /^import\s+([A-Za-z0-9_]+)\s+from\s+.*$/gm
let importMatch = importPattern.exec(scriptMatch[1])
while (importMatch) {
importNames.push(importMatch[1])
importMatch = importPattern.exec(scriptMatch[1])
}
const stubImports = importNames.map(name => `const ${name} = {};`).join('\n')
const transformed = `${stubImports}\n${scriptMatch[1]}`
.replace(/^import .*$/gm, '')
.replace(/export default/, 'module.exports =')
const sandbox = {
module: { exports: {} },
exports: {},
require,
console
}
vm.runInNewContext(transformed, sandbox, { filename: filePath })
return sandbox.module.exports
}
const filePath = path.resolve(__dirname, '../src/views/loanPricing/workflow/index.vue')
const component = loadComponentOptions(filePath)
assert.strictEqual(typeof component.activated, 'function', '流程列表页应在激活时刷新数据')
let refreshCount = 0
component.activated.call({
getList() {
refreshCount += 1
}
})
assert.strictEqual(refreshCount, 1, '流程列表页激活时应调用一次 getList')
console.log('workflow-index-refresh test passed')