Files
OmniRoute/tests/unit/system-prompt-runtime-hotreload.test.ts
Syed Raheemuddin da678bd3ff feat(config): add support for runtime system prompt configuration and hot-reloading (#11841)
Boarded with #12003/#11840/#11839 in one combined worktree: typecheck:core, check:file-size, check:changelog-integrity, check:complexity, check:cognitive-complexity, check:cycles all green; 24/24 focused tests pass. Clean, well-contained addition mirroring the existing systemTransforms hot-reload pattern, tested for both set and cleared states. Thanks for the tidy runtime-config feature.
2026-08-30 02:51:34 -03:00

47 lines
1.5 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import {
applyRuntimeSettings,
resetRuntimeSettingsStateForTests,
} from "../../src/lib/config/runtimeSettings";
import { getSystemPromptConfig } from "../../open-sse/services/systemPrompt.ts";
test.afterEach(() => {
resetRuntimeSettingsStateForTests();
});
test("systemPrompt settings hot-reload updates globalThis in-memory config", async () => {
const newSettings = {
systemPrompt: {
enabled: true,
prefixPrompt: "Prefix rules for agent",
suffixPrompt: "Suffix rules for agent",
},
};
const changes = await applyRuntimeSettings(newSettings, { force: true, source: "test" });
assert.ok(
changes.some((c) => c.section === "systemPrompt"),
"systemPrompt section must be reported as reloaded"
);
const cfg = getSystemPromptConfig();
assert.equal(cfg.enabled, true, "systemPrompt enabled flag must be updated");
assert.equal(
cfg.prefixPrompt,
"Prefix rules for agent",
"prefixPrompt must match updated settings"
);
assert.equal(
cfg.suffixPrompt,
"Suffix rules for agent",
"suffixPrompt must match updated settings"
);
// Hot-reload clearing systemPrompt
await applyRuntimeSettings({ systemPrompt: null }, { force: true, source: "test" });
const clearedCfg = getSystemPromptConfig();
assert.equal(clearedCfg.enabled, false, "systemPrompt must be disabled when set to null");
assert.equal(clearedCfg.prefixPrompt, "", "prefixPrompt must be cleared when set to null");
});