task-2(壳层/路由): 冻结 /admin-vue/ base 与 History 路由契约为单一事实源

新增 src/config/app.ts(APP_BASE_PATH/ensureAppBasePath/joinAdminPath),
vite.config base、router createWebHistory、AdminLayout logo 路径统一消费常量,
禁止散落字面量;8 用例覆盖归一化/幂等/空段/单段/非法输入与字面量单源。
This commit is contained in:
2026-09-05 12:13:19 +08:00
parent ec7d56d566
commit 6f0357e41c
6 changed files with 338 additions and 0 deletions
@@ -0,0 +1,31 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { existsSync, readFileSync } from 'node:fs'
import { resolve } from 'node:path'
test('admin build uses the standalone /admin-vue base path from single source', () => {
const config = readFileSync(resolve('vite.config.ts'), 'utf8')
const appConfig = readFileSync(resolve('src/config/app.ts'), 'utf8')
assert.match(appConfig, /export const APP_BASE_PATH = '\/admin-vue\/'/)
assert.match(config, /base:\s*APP_BASE_PATH/)
assert.match(config, /outDir:\s*['"]dist['"]/)
})
test('admin entry and first batch pages exist', () => {
for (const file of [
'index.html',
'src/main.ts',
'src/layout/AdminLayout.vue',
'src/pages/account/UsersPage.vue',
'src/pages/account/MenusPage.vue',
'src/pages/account/GroupsPage.vue',
]) {
assert.equal(existsSync(resolve(file)), true, `${file} should exist`)
}
})
test('admin frontend does not depend on the client new_web_source', () => {
const packageJson = readFileSync(resolve('package.json'), 'utf8')
assert.doesNotMatch(packageJson, /new_web_source/)
})