Files
YG_FT/frontend/scripts/regression-back-navigation.mjs

36 lines
977 B
JavaScript
Raw Normal View History

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')