Files
admin-web/src/app/pages/ForbiddenView.test.ts
T

20 lines
932 B
TypeScript
Raw Normal View History

2026-07-30 17:59:43 +08:00
import { createPinia, setActivePinia } from 'pinia'
2026-07-31 15:34:35 +08:00
import { mount } from '@vue/test-utils'
2026-07-30 17:59:43 +08:00
import { createMemoryHistory, createRouter } from 'vue-router'
2026-07-31 15:34:35 +08:00
import { describe, expect, it } from 'vitest'
2026-07-30 17:59:43 +08:00
import ForbiddenView from './ForbiddenView.vue'
describe('ForbiddenView', () => {
2026-07-31 15:34:35 +08:00
it('shows server-account guidance and sanitizes the source path', async () => {
const pinia = createPinia()
2026-07-30 17:59:43 +08:00
setActivePinia(pinia)
2026-07-31 15:34:35 +08:00
const router = createRouter({ history: createMemoryHistory(), routes: [{ path: '/403', component: ForbiddenView }] })
await router.push({ path: '/403', query: { from: '//example.com' } })
await router.isReady()
const wrapper = mount(ForbiddenView, { global: { plugins: [pinia, router] } })
expect(wrapper.text()).toContain('当前登录账号无法访问此页面')
2026-07-30 17:59:43 +08:00
expect(wrapper.text()).toContain('来源页面:/')
2026-07-31 15:34:35 +08:00
expect(wrapper.text()).not.toContain('权限预览')
2026-07-30 17:59:43 +08:00
})
})