test: tighten config assertions

This commit is contained in:
Peter Steinberger
2026-05-11 16:05:34 +01:00
parent c0c8f7c2d4
commit 4bb7acd88b
7 changed files with 46 additions and 50 deletions

View File

@@ -80,9 +80,9 @@ describe("config defaults", () => {
const manifestRegistry = { plugins: [] };
expect(applyContextPruningDefaults(cfg as never, { manifestRegistry })).toBe(nextCfg);
expect(mocks.applyProviderConfigDefaultsForConfig).toHaveBeenCalledTimes(1);
expect(mocks.applyProviderConfigDefaultsForConfig).toHaveBeenCalledWith(
expect.objectContaining({ manifestRegistry }),
);
const [[defaultsParams]] = mocks.applyProviderConfigDefaultsForConfig.mock
.calls as unknown as Array<[{ manifestRegistry?: unknown }]>;
expect(defaultsParams.manifestRegistry).toBe(manifestRegistry);
});
it("defaults ackReactionScope without deriving other message fields", () => {

View File

@@ -36,10 +36,9 @@ describe("config doc baseline", () => {
);
const tupleEntry = new Map(entries.map((entry) => [entry.path, entry])).get("tupleValues.*");
expect(tupleEntry).toMatchObject({
type: ["number", "string"],
});
expect(tupleEntry?.enumValues).toEqual(expect.arrayContaining([42, "alpha"]));
expect(tupleEntry?.type).toEqual(["number", "string"]);
expect(tupleEntry?.enumValues).toContain(42);
expect(tupleEntry?.enumValues).toContain("alpha");
expect(tupleEntry?.enumValues).toHaveLength(2);
});
});

View File

@@ -27,15 +27,12 @@ describe("config io shell env expected keys", () => {
vi.resetModules();
const { resolveShellEnvExpectedKeys } = await import("./shell-env-expected-keys.js");
expect(resolveShellEnvExpectedKeys({} as NodeJS.ProcessEnv)).toEqual(
expect.arrayContaining([
"OPENAI_API_KEY",
"ARCEEAI_API_KEY",
"FIREWORKS_ALT_API_KEY",
"DISCORD_BOT_TOKEN",
"SLACK_BOT_TOKEN",
"OPENCLAW_GATEWAY_TOKEN",
]),
);
const expectedKeys = resolveShellEnvExpectedKeys({} as NodeJS.ProcessEnv);
expect(expectedKeys).toContain("OPENAI_API_KEY");
expect(expectedKeys).toContain("ARCEEAI_API_KEY");
expect(expectedKeys).toContain("FIREWORKS_ALT_API_KEY");
expect(expectedKeys).toContain("DISCORD_BOT_TOKEN");
expect(expectedKeys).toContain("SLACK_BOT_TOKEN");
expect(expectedKeys).toContain("OPENCLAW_GATEWAY_TOKEN");
});
});

View File

@@ -300,29 +300,33 @@ describe("config mutate helpers", () => {
}
expect(ioMocks.writeConfigFile).not.toHaveBeenCalled();
expect(notifications).toMatchObject([
{
configPath,
persistedHash: "hash-include-refreshed",
sourceConfig: {
plugins: {
entries: {
old: { enabled: true },
demo: { enabled: true },
},
},
expect(notifications).toHaveLength(1);
const [notification] = notifications as Array<{
configPath?: string;
persistedHash?: string;
sourceConfig?: unknown;
runtimeConfig?: unknown;
afterWrite?: unknown;
}>;
expect(notification?.configPath).toBe(configPath);
expect(notification?.persistedHash).toBe("hash-include-refreshed");
expect(notification?.sourceConfig).toEqual({
plugins: {
entries: {
old: { enabled: true },
demo: { enabled: true },
},
runtimeConfig: {
plugins: {
entries: {
old: { enabled: true },
demo: { enabled: true },
},
},
},
afterWrite: { mode: "restart", reason: "test include refresh" },
},
]);
});
expect(notification?.runtimeConfig).toEqual({
plugins: {
entries: {
old: { enabled: true },
demo: { enabled: true },
},
},
});
expect(notification?.afterWrite).toEqual({ mode: "restart", reason: "test include refresh" });
await expect(fs.readFile(configPath, "utf-8")).resolves.toContain(
'"$include": "./config/plugins.json5"',
);

View File

@@ -111,12 +111,10 @@ describe("session store strips resolvedSkills from persistence", () => {
const loaded = loadSessionStore(storePath, { skipCache: true });
const persistedSnapshot = loaded["agent:main:test:1"]?.skillsSnapshot;
expect(persistedSnapshot).toMatchObject({
prompt: snapshot.prompt,
skills: snapshot.skills,
skillFilter: ["skill-0"],
version: 1,
});
expect(persistedSnapshot?.prompt).toBe(snapshot.prompt);
expect(persistedSnapshot?.skills).toEqual(snapshot.skills);
expect(persistedSnapshot?.skillFilter).toEqual(["skill-0"]);
expect(persistedSnapshot?.version).toBe(1);
expect(persistedSnapshot?.resolvedSkills).toBeUndefined();
});

View File

@@ -15,12 +15,10 @@ describe("thread binding config keys", () => {
if (result.ok) {
return;
}
expect(result.issues).toContainEqual(
expect.objectContaining({
path: "session.threadBindings",
message: expect.stringContaining("ttlHours"),
}),
const threadBindingIssue = result.issues.find(
(issue) => issue.path === "session.threadBindings",
);
expect(threadBindingIssue?.message).toContain("ttlHours");
});
it("accepts channel-level thread binding ttlHours compatibility", () => {

View File

@@ -25,7 +25,7 @@ describe("ProxyConfigSchema", () => {
proxyUrl: "http://127.0.0.1:3128",
loopbackMode: "gateway-only",
});
expect(result).toMatchObject({
expect(result).toEqual({
enabled: true,
proxyUrl: "http://127.0.0.1:3128",
loopbackMode: "gateway-only",