From 165dbc232f1deffb8a52206903c9291c0348cc94 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Feb 2026 23:39:25 +0000 Subject: [PATCH] refactor(test): share directive elevated config --- ...irective.directive-behavior.e2e-harness.ts | 26 +++++++++++++++++++ ...-alongside-directive-only-acks.e2e.test.ts | 25 ++---------------- ...nt-elevated-level-as-off-after.e2e.test.ts | 25 ++---------------- 3 files changed, 30 insertions(+), 46 deletions(-) diff --git a/src/auto-reply/reply.directive.directive-behavior.e2e-harness.ts b/src/auto-reply/reply.directive.directive-behavior.e2e-harness.ts index d8bae56d81..c7af85c77a 100644 --- a/src/auto-reply/reply.directive.directive-behavior.e2e-harness.ts +++ b/src/auto-reply/reply.directive.directive-behavior.e2e-harness.ts @@ -56,3 +56,29 @@ export function installDirectiveBehaviorE2EHooks() { vi.restoreAllMocks(); }); } + +export function makeRestrictedElevatedDisabledConfig(home: string) { + return { + agents: { + defaults: { + model: "anthropic/claude-opus-4-5", + workspace: path.join(home, "openclaw"), + }, + list: [ + { + id: "restricted", + tools: { + elevated: { enabled: false }, + }, + }, + ], + }, + tools: { + elevated: { + allowFrom: { whatsapp: ["+1222"] }, + }, + }, + channels: { whatsapp: { allowFrom: ["+1222"] } }, + session: { store: path.join(home, "sessions.json") }, + } as const; +} diff --git a/src/auto-reply/reply.directive.directive-behavior.returns-status-alongside-directive-only-acks.e2e.test.ts b/src/auto-reply/reply.directive.directive-behavior.returns-status-alongside-directive-only-acks.e2e.test.ts index d3749f7c36..3ed4d365a0 100644 --- a/src/auto-reply/reply.directive.directive-behavior.returns-status-alongside-directive-only-acks.e2e.test.ts +++ b/src/auto-reply/reply.directive.directive-behavior.returns-status-alongside-directive-only-acks.e2e.test.ts @@ -4,6 +4,7 @@ import { describe, expect, it } from "vitest"; import { loadSessionStore } from "../config/sessions.js"; import { installDirectiveBehaviorE2EHooks, + makeRestrictedElevatedDisabledConfig, runEmbeddedPiAgent, withTempHome, } from "./reply.directive.directive-behavior.e2e-harness.js"; @@ -68,29 +69,7 @@ describe("directive behavior", () => { CommandAuthorized: true, }, {}, - { - agents: { - defaults: { - model: "anthropic/claude-opus-4-5", - workspace: path.join(home, "openclaw"), - }, - list: [ - { - id: "restricted", - tools: { - elevated: { enabled: false }, - }, - }, - ], - }, - tools: { - elevated: { - allowFrom: { whatsapp: ["+1222"] }, - }, - }, - channels: { whatsapp: { allowFrom: ["+1222"] } }, - session: { store: path.join(home, "sessions.json") }, - }, + makeRestrictedElevatedDisabledConfig(home), ); const text = Array.isArray(res) ? res[0]?.text : res?.text; diff --git a/src/auto-reply/reply.directive.directive-behavior.shows-current-elevated-level-as-off-after.e2e.test.ts b/src/auto-reply/reply.directive.directive-behavior.shows-current-elevated-level-as-off-after.e2e.test.ts index 3db5742d37..385bef7699 100644 --- a/src/auto-reply/reply.directive.directive-behavior.shows-current-elevated-level-as-off-after.e2e.test.ts +++ b/src/auto-reply/reply.directive.directive-behavior.shows-current-elevated-level-as-off-after.e2e.test.ts @@ -4,6 +4,7 @@ import { describe, expect, it } from "vitest"; import { loadSessionStore } from "../config/sessions.js"; import { installDirectiveBehaviorE2EHooks, + makeRestrictedElevatedDisabledConfig, runEmbeddedPiAgent, withTempHome, } from "./reply.directive.directive-behavior.e2e-harness.js"; @@ -159,29 +160,7 @@ describe("directive behavior", () => { CommandAuthorized: true, }, {}, - { - agents: { - defaults: { - model: "anthropic/claude-opus-4-5", - workspace: path.join(home, "openclaw"), - }, - list: [ - { - id: "restricted", - tools: { - elevated: { enabled: false }, - }, - }, - ], - }, - tools: { - elevated: { - allowFrom: { whatsapp: ["+1222"] }, - }, - }, - channels: { whatsapp: { allowFrom: ["+1222"] } }, - session: { store: path.join(home, "sessions.json") }, - }, + makeRestrictedElevatedDisabledConfig(home), ); const text = Array.isArray(res) ? res[0]?.text : res?.text;