import { describe, it, expect } from 'vitest' describe('router guard refresh 401 handling', () => { it('redirects to /login with redirect when getCurrentUser throws (e.g., refresh 401)', async () => { const { createAppRouter } = await import('@/router/index') const router = createAppRouter(async () => { throw new Error('401 Unauthorized') }) // Stub login route with inline component to avoid loading .vue files try { router.removeRoute('login') } catch (_) { /* ignore */ } router.addRoute({ path: '/login', name: 'login', component: { template: '
' } }) await router.push('/') const current = router.currentRoute.value expect(current.name).toBe('login') expect(current.query.redirect).toBe('/') }) })