第一次提交
This commit is contained in:
35
frontend/scripts/regression-back-navigation.mjs
Normal file
35
frontend/scripts/regression-back-navigation.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const root = resolve(fileURLToPath(new URL('..', import.meta.url)))
|
||||
|
||||
function read(relativePath) {
|
||||
return readFileSync(resolve(root, relativePath), 'utf8')
|
||||
}
|
||||
|
||||
function assert(condition, message) {
|
||||
if (!condition) {
|
||||
throw new Error(message)
|
||||
}
|
||||
}
|
||||
|
||||
const appHeader = read('src/components/AppHeader.vue')
|
||||
const trainingLog = read('src/views/system/TrainingLogView.vue')
|
||||
|
||||
assert(
|
||||
appHeader.includes('showBackButton'),
|
||||
'AppHeader should gate the global back button behind showBackButton',
|
||||
)
|
||||
|
||||
assert(
|
||||
appHeader.includes('v-if="showBackButton"'),
|
||||
'AppHeader should hide 返回上一页 when the current route is not a detail/sub page',
|
||||
)
|
||||
|
||||
assert(
|
||||
!trainingLog.includes('返回列表'),
|
||||
'TrainingLogView should rely on the global 返回上一页 button instead of rendering 返回列表',
|
||||
)
|
||||
|
||||
console.log('back-navigation regression checks passed')
|
||||
Reference in New Issue
Block a user