test: tighten config validation log assertion

This commit is contained in:
Shakker
2026-05-08 20:50:32 +01:00
parent d456dd1bd3
commit c5cc6d6ae4

View File

@@ -45,6 +45,15 @@ describe("requireValidConfigSnapshot", () => {
};
}
function requireFirstLog(runtime: ReturnType<typeof createRuntime>): string {
const [message] = runtime.log.mock.calls[0] ?? [];
expect(message).toBeDefined();
if (message === undefined) {
throw new Error("expected runtime log message");
}
return String(message);
}
it("returns config without emitting compatibility advice by default", async () => {
createValidSnapshot();
const runtime = createRuntime();
@@ -69,10 +78,9 @@ describe("requireValidConfigSnapshot", () => {
expect(config).toEqual({ plugins: {} });
expect(runtime.error).not.toHaveBeenCalled();
expect(runtime.exit).not.toHaveBeenCalled();
expect(String(runtime.log.mock.calls[0]?.[0])).toContain("Plugin compatibility: 1 notice.");
expect(String(runtime.log.mock.calls[0]?.[0])).toContain(
"legacy-plugin still uses legacy before_agent_start",
);
const logMessage = requireFirstLog(runtime);
expect(logMessage).toContain("Plugin compatibility: 1 notice.");
expect(logMessage).toContain("legacy-plugin still uses legacy before_agent_start");
});
it("blocks invalid config before emitting compatibility advice", async () => {