refactor(test): share directive elevated config

This commit is contained in:
Peter Steinberger
2026-02-14 23:39:25 +00:00
parent 61371a712b
commit 165dbc232f
3 changed files with 30 additions and 46 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;