mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix(hooks): retire legacy inline handler config (#120851)
This commit is contained in:
committed by
GitHub
parent
73bdb4b924
commit
4c3bf14466
@@ -1,6 +1,8 @@
|
||||
// Hook command tests cover metadata config keys and missing-hook exit status.
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { resolveConfiguredInternalHookNames } from "../hooks/configured.js";
|
||||
import type { HookStatusEntry, HookStatusReport } from "../hooks/hooks-status.js";
|
||||
import { createEmptyInstallChecks } from "./requirements-test-fixtures.js";
|
||||
import { createCliRuntimeCapture } from "./test-runtime-capture.js";
|
||||
@@ -15,6 +17,11 @@ const mocks = vi.hoisted(() => ({
|
||||
}));
|
||||
|
||||
const capture = createCliRuntimeCapture();
|
||||
const readConfigMachineStateMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../state/config-machine-state.js", () => ({
|
||||
readConfigMachineState: readConfigMachineStateMock,
|
||||
}));
|
||||
|
||||
vi.mock("../agents/agent-scope.js", () => ({
|
||||
resolveAgentWorkspaceDir: () => "/tmp/openclaw-hook-workspace",
|
||||
@@ -128,6 +135,7 @@ describe("hooks CLI metadata config keys", () => {
|
||||
mocks.getRuntimeConfig.mockReturnValue(sourceConfig);
|
||||
mocks.readConfigFileSnapshot.mockResolvedValue({ sourceConfig, hash: "config-hash" });
|
||||
mocks.replaceConfigFile.mockResolvedValue(undefined);
|
||||
readConfigMachineStateMock.mockReturnValue(undefined);
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -156,6 +164,10 @@ describe("hooks CLI metadata config keys", () => {
|
||||
},
|
||||
baseHash: "config-hash",
|
||||
});
|
||||
const writtenConfig = mocks.replaceConfigFile.mock.calls[0]?.[0]?.nextConfig as OpenClawConfig;
|
||||
expect(resolveConfiguredInternalHookNames(writtenConfig)).toEqual(
|
||||
new Set(testCase.enabled ? ["metadata-key"] : []),
|
||||
);
|
||||
expect(capture.runtimeLogs.at(-1)).toContain("display-name");
|
||||
expect(mocks.requestExitAfterOneShotOutput).toHaveBeenCalledWith(capture.defaultRuntime, 0);
|
||||
expect(mocks.callGateway).not.toHaveBeenCalled();
|
||||
|
||||
Reference in New Issue
Block a user