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 03f2466108..9908bad165 100644 --- a/src/auto-reply/reply.directive.directive-behavior.e2e-harness.ts +++ b/src/auto-reply/reply.directive.directive-behavior.e2e-harness.ts @@ -125,6 +125,13 @@ export function assertModelSelection( expect(entry?.providerOverride).toBe(selection.provider); } +export function assertElevatedOffStatusReply(text: string | undefined) { + expect(text).toContain("Elevated mode disabled."); + const optionsLine = text?.split("\n").find((line) => line.trim().startsWith("⚙️")); + expect(optionsLine).toBeTruthy(); + expect(optionsLine).not.toContain("elevated"); +} + export function installDirectiveBehaviorE2EHooks() { beforeEach(() => { vi.mocked(runEmbeddedPiAgent).mockReset(); 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 8ca0eb8c54..8af2f80e3b 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 type { OpenClawConfig } from "../config/config.js"; import { loadSessionStore } from "../config/sessions.js"; import { + assertElevatedOffStatusReply, installDirectiveBehaviorE2EHooks, makeRestrictedElevatedDisabledConfig, runEmbeddedPiAgent, @@ -71,11 +72,8 @@ describe("directive behavior", () => { ); const text = extractReplyText(res); - expect(text).toContain("Elevated mode disabled."); expect(text).toContain("Session: agent:main:main"); - const optionsLine = text?.split("\n").find((line) => line.trim().startsWith("⚙️")); - expect(optionsLine).toBeTruthy(); - expect(optionsLine).not.toContain("elevated"); + assertElevatedOffStatusReply(text); const store = loadSessionStore(storePath); expect(store["agent:main:main"]?.elevatedLevel).toBe("off"); diff --git a/src/auto-reply/reply.directive.directive-behavior.shows-current-verbose-level-verbose-has-no.e2e.test.ts b/src/auto-reply/reply.directive.directive-behavior.shows-current-verbose-level-verbose-has-no.e2e.test.ts index 24fe63c825..02406d22fd 100644 --- a/src/auto-reply/reply.directive.directive-behavior.shows-current-verbose-level-verbose-has-no.e2e.test.ts +++ b/src/auto-reply/reply.directive.directive-behavior.shows-current-verbose-level-verbose-has-no.e2e.test.ts @@ -3,6 +3,7 @@ import { describe, expect, it, vi } from "vitest"; import { loadSessionStore } from "../config/sessions.js"; import { AUTHORIZED_WHATSAPP_COMMAND, + assertElevatedOffStatusReply, installDirectiveBehaviorE2EHooks, makeElevatedDirectiveConfig, makeWhatsAppDirectiveConfig, @@ -103,10 +104,7 @@ describe("directive behavior", () => { const storePath = sessionStorePath(home); const res = await runElevatedCommand(home, "/elevated off\n/status"); const text = replyText(res); - expect(text).toContain("Elevated mode disabled."); - const optionsLine = text?.split("\n").find((line) => line.trim().startsWith("⚙️")); - expect(optionsLine).toBeTruthy(); - expect(optionsLine).not.toContain("elevated"); + assertElevatedOffStatusReply(text); const store = loadSessionStore(storePath); expect(store["agent:main:main"]?.elevatedLevel).toBe("off");