Files
hermes-ui/tests/server/config.test.ts
T
toor 1e9ea89d86
Build / build (push) Canceled after 0s
NPM Lockfile Check / npm ci --ignore-scripts (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
chore: bootstrap hermes-ui skeleton from 0.6.29 snapshot
Import the client, server, skills, tests, and build scripts as the starting
point for the rebuild, then trim the surfaces this project does not ship:
Electron desktop packaging, the marketing website, and the ESP32 firmware
tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows.

Rename the package and CLI entry points to hermes-ui, drop the prepare hook so
npm ci no longer triggers a build, and drop the removed tsconfig and nodemon
references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs
so the documented package map and hard rules match this repository.

reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
2026-10-16 10:34:35 +08:00

44 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { homedir } from 'os'
import { join, resolve } from 'path'
import { getCorsOrigins, getListenHost, getWebUiHome, shouldCreateWebUiDataDir } from '../../packages/server/src/config'
describe('server config', () => {
it('defaults to an IPv4 bind host', () => {
expect(getListenHost({})).toBe('0.0.0.0')
})
it('uses BIND_HOST when provided', () => {
expect(getListenHost({ BIND_HOST: ' :: ' })).toBe('::')
})
it('ignores blank BIND_HOST values', () => {
expect(getListenHost({ BIND_HOST: ' ' })).toBe('0.0.0.0')
})
it('defaults web-ui home to ~/.hermes-web-ui', () => {
expect(getWebUiHome({})).toBe(join(homedir(), '.hermes-web-ui'))
})
it('uses HERMES_WEB_UI_HOME when provided', () => {
expect(getWebUiHome({ HERMES_WEB_UI_HOME: ' ./tmp/hermes-ui ' })).toBe(resolve('./tmp/hermes-ui'))
})
it('uses HERMES_WEBUI_STATE_DIR as a compatibility alias', () => {
expect(getWebUiHome({ HERMES_WEBUI_STATE_DIR: ' ./tmp/hermes-state ' })).toBe(resolve('./tmp/hermes-state'))
})
it('only creates the development data directory outside production', () => {
expect(shouldCreateWebUiDataDir({ NODE_ENV: 'development' })).toBe(true)
expect(shouldCreateWebUiDataDir({ NODE_ENV: 'production' })).toBe(false)
})
it('does not enable cross-origin requests by default', () => {
expect(getCorsOrigins({})).toBe('')
})
it('uses CORS_ORIGINS when provided', () => {
expect(getCorsOrigins({ CORS_ORIGINS: ' https://app.example, http://localhost:3000 ' })).toBe('https://app.example, http://localhost:3000')
})
})