mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
test: fix post-merge config and tui command-handler tests
This commit is contained in:
@@ -85,7 +85,17 @@ describe("browser state option collisions", () => {
|
||||
it("resolves --url via parent when addGatewayClientOptions captures it", async () => {
|
||||
const program = createBrowserProgram({ withGatewayUrl: true });
|
||||
await program.parseAsync(
|
||||
["browser", "--url", "ws://gw", "cookies", "set", "session", "abc", "--url", "https://example.com"],
|
||||
[
|
||||
"browser",
|
||||
"--url",
|
||||
"ws://gw",
|
||||
"cookies",
|
||||
"set",
|
||||
"session",
|
||||
"abc",
|
||||
"--url",
|
||||
"https://example.com",
|
||||
],
|
||||
{ from: "user" },
|
||||
);
|
||||
const call = mocks.callBrowserRequest.mock.calls.at(-1);
|
||||
|
||||
@@ -3,6 +3,7 @@ import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { withTempHome } from "./home-env.test-harness.js";
|
||||
import { createConfigIO } from "./io.js";
|
||||
import type { OpenClawConfig } from "./types.js";
|
||||
|
||||
describe("config io write", () => {
|
||||
const silentLogger = {
|
||||
@@ -140,7 +141,7 @@ describe("config io write", () => {
|
||||
allowFrom: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
} satisfies OpenClawConfig;
|
||||
|
||||
await expect(io.writeConfigFile(invalidConfig)).rejects.toThrow(
|
||||
"openclaw config set channels.telegram.allowFrom '[\"*\"]'",
|
||||
|
||||
@@ -9,6 +9,7 @@ function createHarness(params?: {
|
||||
resetSession?: ReturnType<typeof vi.fn>;
|
||||
loadHistory?: LoadHistoryMock;
|
||||
setActivityStatus?: SetActivityStatusMock;
|
||||
isConnected?: boolean;
|
||||
}) {
|
||||
const sendChat = params?.sendChat ?? vi.fn().mockResolvedValue({ runId: "r1" });
|
||||
const resetSession = params?.resetSession ?? vi.fn().mockResolvedValue({ ok: true });
|
||||
@@ -27,6 +28,7 @@ function createHarness(params?: {
|
||||
state: {
|
||||
currentSessionKey: "agent:main:main",
|
||||
activeChatRunId: null,
|
||||
isConnected: params?.isConnected ?? true,
|
||||
sessionInfo: {},
|
||||
} as never,
|
||||
deliverDefault: false,
|
||||
@@ -126,4 +128,17 @@ describe("tui command handlers", () => {
|
||||
expect(addSystem).toHaveBeenCalledWith("send failed: Error: gateway down");
|
||||
expect(setActivityStatus).toHaveBeenLastCalledWith("error");
|
||||
});
|
||||
|
||||
it("reports disconnected status and skips gateway send when offline", async () => {
|
||||
const { handleCommand, sendChat, addUser, addSystem, setActivityStatus } = createHarness({
|
||||
isConnected: false,
|
||||
});
|
||||
|
||||
await handleCommand("/context");
|
||||
|
||||
expect(sendChat).not.toHaveBeenCalled();
|
||||
expect(addUser).not.toHaveBeenCalled();
|
||||
expect(addSystem).toHaveBeenCalledWith("not connected to gateway — message not sent");
|
||||
expect(setActivityStatus).toHaveBeenLastCalledWith("disconnected");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user