fix(frontend): 修复前端审计问题并补充回归测试
This commit is contained in:
25
frontend/src/router/__tests__/title.spec.ts
Normal file
25
frontend/src/router/__tests__/title.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { resolveDocumentTitle } from '@/router/title'
|
||||
|
||||
describe('resolveDocumentTitle', () => {
|
||||
it('路由存在标题时,使用“路由标题 - 站点名”格式', () => {
|
||||
expect(resolveDocumentTitle('Usage Records', 'My Site')).toBe('Usage Records - My Site')
|
||||
})
|
||||
|
||||
it('路由无标题时,回退到站点名', () => {
|
||||
expect(resolveDocumentTitle(undefined, 'My Site')).toBe('My Site')
|
||||
})
|
||||
|
||||
it('站点名为空时,回退默认站点名', () => {
|
||||
expect(resolveDocumentTitle('Dashboard', '')).toBe('Dashboard - Sub2API')
|
||||
expect(resolveDocumentTitle(undefined, ' ')).toBe('Sub2API')
|
||||
})
|
||||
|
||||
it('站点名变更时仅影响后续路由标题计算', () => {
|
||||
const before = resolveDocumentTitle('Admin Dashboard', 'Alpha')
|
||||
const after = resolveDocumentTitle('Admin Dashboard', 'Beta')
|
||||
|
||||
expect(before).toBe('Admin Dashboard - Alpha')
|
||||
expect(after).toBe('Admin Dashboard - Beta')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user