40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
|
|
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 router = read('src/router/index.ts')
|
||
|
|
const login = read('src/views/login/LoginView.vue')
|
||
|
|
const sidebar = read('src/components/AppSidebar.vue')
|
||
|
|
|
||
|
|
assert(
|
||
|
|
router.includes("redirect: '/dashboard'"),
|
||
|
|
'The authenticated root and fallback routes should default to 服务看板',
|
||
|
|
)
|
||
|
|
|
||
|
|
assert(
|
||
|
|
router.includes("next('/dashboard')"),
|
||
|
|
'An authenticated user visiting the login page should enter 服务看板',
|
||
|
|
)
|
||
|
|
|
||
|
|
assert(
|
||
|
|
login.includes("router.push('/dashboard')"),
|
||
|
|
'A successful login should navigate to 服务看板',
|
||
|
|
)
|
||
|
|
|
||
|
|
assert(
|
||
|
|
sidebar.includes("route.path.split('/')[1] || 'dashboard'"),
|
||
|
|
'The sidebar fallback active item should be 服务看板',
|
||
|
|
)
|
||
|
|
|
||
|
|
console.log('default-dashboard regression checks passed')
|