Luigit
repositories / will

will

owned by admin

src/agent/config.test.ts

Raw
import assert from 'node:assert/strict'
import { test } from 'node:test'
import { loadAgentConfig, resolveSessionMode } from './config.ts'

test('explicit fake wins even with a key', () => {
  assert.equal(resolveSessionMode({ WILL_SESSION_MODE: 'fake', ZAI_API_KEY: 'k' }), 'fake')
})

test('no env at all falls back to fake', () => {
  assert.equal(resolveSessionMode({}), 'fake')
})

test('key alone gives the real session', () => {
  assert.equal(resolveSessionMode({ ZAI_API_KEY: 'k' }), 'real')
})

test('explicit real without a key fails loudly', () => {
  assert.throws(() => resolveSessionMode({ WILL_SESSION_MODE: 'real' }), /ZAI_API_KEY/)
})

test('explicit real with a key is real', () => {
  assert.equal(resolveSessionMode({ WILL_SESSION_MODE: 'real', ZAI_API_KEY: 'k' }), 'real')
})

test('thinking level defaults to medium', () => {
  assert.equal(loadAgentConfig({}).zai.thinkingLevel, 'medium')
})

test('ZAI_THINKING_LEVEL overrides the default', () => {
  assert.equal(loadAgentConfig({ ZAI_THINKING_LEVEL: 'max' }).zai.thinkingLevel, 'max')
})

test('unknown ZAI_THINKING_LEVEL fails loudly', () => {
  assert.throws(() => loadAgentConfig({ ZAI_THINKING_LEVEL: 'ultra' }), /ZAI_THINKING_LEVEL/)
})