From fd6059bb28f35d046673e5e4336318d83166ee12 Mon Sep 17 00:00:00 2001 From: Shakker Date: Mon, 11 May 2026 21:36:49 +0100 Subject: [PATCH] test: list onboarding hook notes --- src/commands/onboard-hooks.test.ts | 37 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/commands/onboard-hooks.test.ts b/src/commands/onboard-hooks.test.ts index 4dddce29b9e..9410a13dd3c 100644 --- a/src/commands/onboard-hooks.test.ts +++ b/src/commands/onboard-hooks.test.ts @@ -134,6 +134,10 @@ describe("onboard-hooks", () => { } describe("setupInternalHooks", () => { + beforeEach(() => { + vi.unstubAllEnvs(); + }); + it("should enable hooks when user selects them", async () => { const { result, prompter } = await runSetupInternalHooks({ selected: ["session-memory"], @@ -221,20 +225,35 @@ describe("onboard-hooks", () => { }); it("should show informative notes to user", async () => { + vi.stubEnv("OPENCLAW_CONTAINER_HINT", ""); + vi.stubEnv("OPENCLAW_PROFILE", ""); const { prompter } = await runSetupInternalHooks({ selected: ["session-memory"], }); const noteCalls = (prompter.note as ReturnType).mock.calls; - expect(noteCalls).toHaveLength(2); - - // First note should explain what hooks are - expect(noteCalls[0][0]).toContain("Hooks let you automate actions"); - expect(noteCalls[0][0]).toContain("automate actions"); - - // Second note should confirm configuration - expect(noteCalls[1][0]).toContain("Enabled 1 hook: session-memory"); - expect(noteCalls[1][0]).toMatch(/(?:openclaw|openclaw)( --profile isolated)? hooks list/); + expect(noteCalls).toEqual([ + [ + [ + "Hooks let you automate actions when agent commands are issued.", + "Example: Save session context to memory when you issue /new or /reset.", + "", + "Learn more: https://docs.openclaw.ai/automation/hooks", + ].join("\n"), + "Hooks", + ], + [ + [ + "Enabled 1 hook: session-memory", + "", + "You can manage hooks later with:", + " openclaw hooks list", + " openclaw hooks enable ", + " openclaw hooks disable ", + ].join("\n"), + "Hooks Configured", + ], + ]); }); }); });