From c5cc6d6ae424980b357bd8ea865936f4837ae4e6 Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 8 May 2026 20:50:32 +0100 Subject: [PATCH] test: tighten config validation log assertion --- src/commands/config-validation.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/config-validation.test.ts b/src/commands/config-validation.test.ts index 8c9f2055207..5f0d3cc1737 100644 --- a/src/commands/config-validation.test.ts +++ b/src/commands/config-validation.test.ts @@ -45,6 +45,15 @@ describe("requireValidConfigSnapshot", () => { }; } + function requireFirstLog(runtime: ReturnType): 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 () => {