mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test(auto-reply): share elevated-off status assertion
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user