- Drop all desktop/Electron branches, scripts, and UI (title bar, pets, desktop bridge); LAN endpoint kind is now web/custom only - Replace the bundled hermes CLI with user-side installation: add GET /api/hermes/cli-status plus a HermesMissingView onboarding guide - Remove the version-management UI (snapshots handled by git) and prune dead website/mcu/claude scripts and lockfile entries
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const mockHasApiKey = vi.hoisted(() => vi.fn())
|
|
const mockIsStoredSuperAdmin = vi.hoisted(() => vi.fn())
|
|
const mockCheckHermesCliAvailable = vi.hoisted(() => vi.fn())
|
|
|
|
vi.mock('@/api/client', () => ({
|
|
hasApiKey: mockHasApiKey,
|
|
isStoredSuperAdmin: mockIsStoredSuperAdmin,
|
|
}))
|
|
|
|
vi.mock('@/api/hermes/system', () => ({
|
|
checkHermesCliAvailable: mockCheckHermesCliAvailable,
|
|
}))
|
|
|
|
async function loadRouter() {
|
|
vi.resetModules()
|
|
return (await import('@/router')).default
|
|
}
|
|
|
|
describe('router login redirect', () => {
|
|
beforeEach(() => {
|
|
mockHasApiKey.mockReturnValue(false)
|
|
mockIsStoredSuperAdmin.mockReturnValue(true)
|
|
mockCheckHermesCliAvailable.mockResolvedValue(true)
|
|
if (!document.queryCommandSupported) {
|
|
document.queryCommandSupported = vi.fn(() => false)
|
|
}
|
|
window.location.hash = ''
|
|
})
|
|
|
|
it('keeps the web login redirect when a token exists', async () => {
|
|
mockHasApiKey.mockReturnValue(true)
|
|
const router = await loadRouter()
|
|
|
|
await router.push('/')
|
|
await router.isReady()
|
|
|
|
expect(router.currentRoute.value.name).toBe('hermes.chat')
|
|
}, 60_000)
|
|
|
|
it('redirects to the hermes CLI guide when the CLI is missing', async () => {
|
|
mockCheckHermesCliAvailable.mockResolvedValue(false)
|
|
const router = await loadRouter()
|
|
|
|
await router.push('/hermes/chat')
|
|
await router.isReady()
|
|
|
|
expect(router.currentRoute.value.name).toBe('hermes.missing')
|
|
})
|
|
})
|