mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-05-25 21:40:13 +00:00
9a9416c99c
* feat: support profile-aware group chat bridge flows * feat: route cron jobs through hermes cli * Fix group chat routing and isolate bridge tests * Add Grok image-to-video media skill * Default Grok videos to media directory * Fix bridge profile fallback and cron repeat clearing * Refine bridge chat and gateway platform handling * Filter bridge tool-call text deltas * Preserve structured bridge chat history * Prepare beta release build artifacts * Fix Windows run profile resolution * Fix Windows path compatibility checks * Fix profile-scoped model page display * Hide Windows subprocess windows for jobs and updates * Hide Windows file backend subprocess windows * Avoid Windows gateway restart lock conflicts * Treat Windows gateway lock as running on startup * Force release Windows gateway lock on restart * Tighten Windows gateway lock cleanup * Update chat e2e source expectation * Bump package version to 0.5.30 --------- Co-authored-by: Codex <codex@openai.com>
104 lines
3.1 KiB
TypeScript
104 lines
3.1 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import { readFileSync } from 'fs'
|
|
import { resolve } from 'path'
|
|
|
|
function readRootPackage() {
|
|
return JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf-8')) as {
|
|
name: string
|
|
version: string
|
|
}
|
|
}
|
|
|
|
async function loadHealthControllerWithoutInjectedVersion() {
|
|
vi.resetModules()
|
|
delete (globalThis as any).__APP_VERSION__
|
|
|
|
vi.doMock('../../packages/server/src/services/hermes/hermes-cli', () => ({
|
|
getVersion: vi.fn().mockResolvedValue('Hermes Agent v0.11.0\n'),
|
|
}))
|
|
|
|
return import('../../packages/server/src/controllers/health')
|
|
}
|
|
|
|
async function loadHealthControllerWithInjectedVersion(version: string) {
|
|
vi.resetModules()
|
|
;(globalThis as any).__APP_VERSION__ = version
|
|
|
|
vi.doMock('../../packages/server/src/services/hermes/hermes-cli', () => ({
|
|
getVersion: vi.fn().mockResolvedValue('Hermes Agent v0.11.0\n'),
|
|
}))
|
|
|
|
return import('../../packages/server/src/controllers/health')
|
|
}
|
|
|
|
function createMockCtx() {
|
|
return {
|
|
body: null as any,
|
|
}
|
|
}
|
|
|
|
describe('health controller version metadata', () => {
|
|
afterEach(() => {
|
|
vi.restoreAllMocks()
|
|
vi.resetModules()
|
|
;(globalThis as any).__APP_VERSION__ = 'test'
|
|
})
|
|
|
|
it('reads the root package version in ts-node/dev mode instead of falling back to 0.0.0', async () => {
|
|
const pkg = readRootPackage()
|
|
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true }))
|
|
|
|
const { healthCheck } = await loadHealthControllerWithoutInjectedVersion()
|
|
const ctx = createMockCtx()
|
|
|
|
await healthCheck(ctx)
|
|
|
|
expect(ctx.body.webui_version).toBe(pkg.version)
|
|
expect(ctx.body.webui_version).not.toBe('0.0.0')
|
|
})
|
|
|
|
it('uses the injected build version when available', async () => {
|
|
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true }))
|
|
|
|
const { healthCheck } = await loadHealthControllerWithInjectedVersion('9.9.9-test')
|
|
const ctx = createMockCtx()
|
|
|
|
await healthCheck(ctx)
|
|
|
|
expect(ctx.body.webui_version).toBe('9.9.9-test')
|
|
})
|
|
|
|
it('checks npm latest using the root package name', async () => {
|
|
vi.spyOn(console, 'log').mockImplementation(() => {})
|
|
const pkg = readRootPackage()
|
|
const fetchMock = vi.fn().mockResolvedValue({
|
|
ok: true,
|
|
json: vi.fn().mockResolvedValue({ version: '99.99.99' }),
|
|
})
|
|
vi.stubGlobal('fetch', fetchMock)
|
|
|
|
const { checkLatestVersion, healthCheck } = await loadHealthControllerWithoutInjectedVersion()
|
|
|
|
await checkLatestVersion()
|
|
|
|
expect(fetchMock).toHaveBeenCalledWith(
|
|
`https://registry.npmjs.org/${pkg.name}/latest`,
|
|
expect.objectContaining({ signal: expect.any(AbortSignal) }),
|
|
)
|
|
|
|
const ctx = createMockCtx()
|
|
await healthCheck(ctx)
|
|
|
|
expect(ctx.body.webui_latest).toBe('99.99.99')
|
|
expect(ctx.body.webui_update_available).toBe(true)
|
|
})
|
|
|
|
it('does not throw when latest-version lookup fails', async () => {
|
|
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('network down')))
|
|
|
|
const { checkLatestVersion } = await loadHealthControllerWithoutInjectedVersion()
|
|
|
|
await expect(checkLatestVersion()).resolves.toBeUndefined()
|
|
})
|
|
})
|