迁移项目到 RuoYi-Vue springboot2 基线
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
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')
|
||||
@@ -1,21 +0,0 @@
|
||||
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')
|
||||
@@ -1,27 +0,0 @@
|
||||
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')
|
||||
@@ -1,52 +0,0 @@
|
||||
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')
|
||||
Reference in New Issue
Block a user