import { describe, it, expect } from 'vitest' describe('router guard unauthenticated redirect', () => { it('redirects to /login with redirect query when not authenticated', async () => { const { createAppRouter } = await import('@/router/index') const router = createAppRouter(async () => null) // Replace the lazy .vue login route with an inline component to avoid plugin-vue in tests try { router.removeRoute('login') } catch (_) { /* ignore */ } router.addRoute({ path: '/login', name: 'login', component: { template: '
' } }) // Navigate to a protected route that uses an inline component to avoid lazy .vue imports await router.push('/') const current = router.currentRoute.value expect(current.name).toBe('login') expect(current.query.redirect).toBe('/') }) })