test: list onboarding hook notes

This commit is contained in:
Shakker
2026-05-11 21:36:49 +01:00
parent d865d3a6de
commit fd6059bb28

View File

@@ -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<typeof vi.fn>).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 <name>",
" openclaw hooks disable <name>",
].join("\n"),
"Hooks Configured",
],
]);
});
});
});