import { createPinia, setActivePinia } from 'pinia' import { mount } from '@vue/test-utils' import { createMemoryHistory, createRouter } from 'vue-router' import { describe, expect, it } from 'vitest' import ForbiddenView from './ForbiddenView.vue' describe('ForbiddenView', () => { it('shows server-account guidance and sanitizes the source path', async () => { const pinia = createPinia() setActivePinia(pinia) 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('当前登录账号无法访问此页面') expect(wrapper.text()).toContain('来源页面:/') expect(wrapper.text()).not.toContain('权限预览') }) })