test(auto-reply): share elevated-off status assertion

This commit is contained in:
Peter Steinberger
2026-02-18 17:00:02 +00:00
parent 50e5413c19
commit 3138dbaf75
3 changed files with 11 additions and 8 deletions

View File

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

View File

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

View File

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