6f0357e41c
新增 src/config/app.ts(APP_BASE_PATH/ensureAppBasePath/joinAdminPath), vite.config base、router createWebHistory、AdminLayout logo 路径统一消费常量, 禁止散落字面量;8 用例覆盖归一化/幂等/空段/单段/非法输入与字面量单源。
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
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/)
|
|
})
|
|
|