diff --git a/src/app/layouts/AppLayout.test.ts b/src/app/layouts/AppLayout.test.ts index f7554da9..c740c98e 100644 --- a/src/app/layouts/AppLayout.test.ts +++ b/src/app/layouts/AppLayout.test.ts @@ -7,6 +7,9 @@ import { ElMessageBox } from 'element-plus' import { useAuthStore } from '@/core/auth/auth' import AppLayout from './AppLayout.vue' +const { getUnreadCount } = vi.hoisted(() => ({ getUnreadCount: vi.fn() })) +vi.mock('@/modules/notifications/api/notificationCenter', () => ({ getUnreadCount })) + const CachedPage = defineComponent({ setup() { const count = ref(0) @@ -26,31 +29,35 @@ async function mountLayout(path = '/') { const auth = useAuthStore() auth.token = 'token' auth.user = { id: '1', name: '平台管理员', account: 'admin', roles: ['PLATFORM_ADMIN'] } - auth.permissions = ['platform:warehouse:list'] + auth.permissions = ['platform:warehouse:list', 'platform:notification:view'] const router = createRouter({ history: createMemoryHistory(), routes: [ { path: '/', name: 'home', component: { template: '

page

' }, meta: { requiresAuth: true, workspaceTab: false, keepAlive: false } }, { path: '/customers', name: 'customers', component: CachedPage, meta: { title: '客户管理', showPageHeading: false, requiresAuth: true } }, { path: '/warehouses', name: 'warehouses', component: { template: '

warehouses

' }, meta: { title: '仓库管理', requiresAuth: true } }, + { path: '/notifications/mine', name: 'my-notifications', component: { template: '

messages

' }, meta: { title: '我的消息', requiresAuth: true } }, { path: '/login', component: { template: '

login

' } }, ], }) await router.push(path) await router.isReady() const wrapper = mount(AppLayout, { - global: { plugins: [pinia, router], stubs: { AdminSidebarMenu: { template: '