refactor(agent): dedupe harness and command workflows

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:09 +00:00
parent 04892ee230
commit f717a13039
204 changed files with 7366 additions and 11540 deletions

View File

@@ -1,5 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { RuntimeEnv } from "../runtime.js";
import { discordPlugin } from "../../extensions/discord/src/channel.js";
import { imessagePlugin } from "../../extensions/imessage/src/channel.js";
import { signalPlugin } from "../../extensions/signal/src/channel.js";
@@ -8,6 +7,7 @@ import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js";
import { setActivePluginRegistry } from "../plugins/runtime.js";
import { createTestRegistry } from "../test-utils/channel-plugins.js";
import { baseConfigSnapshot, createTestRuntime } from "./test-runtime-config-helpers.js";
const configMocks = vi.hoisted(() => ({
readConfigFileSnapshot: vi.fn(),
@@ -42,22 +42,7 @@ import {
formatGatewayChannelsStatusLines,
} from "./channels.js";
const runtime: RuntimeEnv = {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn(),
};
const baseSnapshot = {
path: "/tmp/openclaw.json",
exists: true,
raw: "{}",
parsed: {},
valid: true,
config: {},
issues: [],
legacyIssues: [],
};
const runtime = createTestRuntime();
describe("channels command", () => {
beforeEach(() => {
@@ -84,7 +69,7 @@ describe("channels command", () => {
});
it("adds a non-default telegram account", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseSnapshot });
configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseConfigSnapshot });
await channelsAddCommand(
{ channel: "telegram", account: "alerts", token: "123:abc" },
runtime,
@@ -105,7 +90,7 @@ describe("channels command", () => {
});
it("adds a default slack account with tokens", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseSnapshot });
configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseConfigSnapshot });
await channelsAddCommand(
{
channel: "slack",
@@ -130,7 +115,7 @@ describe("channels command", () => {
it("deletes a non-default discord account", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({
...baseSnapshot,
...baseConfigSnapshot,
config: {
channels: {
discord: {
@@ -158,7 +143,7 @@ describe("channels command", () => {
});
it("adds a named WhatsApp account", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseSnapshot });
configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseConfigSnapshot });
await channelsAddCommand(
{ channel: "whatsapp", account: "family", name: "Family Phone" },
runtime,
@@ -175,7 +160,7 @@ describe("channels command", () => {
it("adds a second signal account with a distinct name", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({
...baseSnapshot,
...baseConfigSnapshot,
config: {
channels: {
signal: {
@@ -212,7 +197,7 @@ describe("channels command", () => {
it("disables a default provider account when remove has no delete flag", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({
...baseSnapshot,
...baseConfigSnapshot,
config: {
channels: { discord: { token: "d0", enabled: true } },
},
@@ -237,7 +222,7 @@ describe("channels command", () => {
it("includes external auth profiles in JSON output", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({
...baseSnapshot,
...baseConfigSnapshot,
config: {},
});
authMocks.loadAuthProfileStore.mockReturnValue({
@@ -273,7 +258,7 @@ describe("channels command", () => {
it("stores default account names in accounts when multiple accounts exist", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({
...baseSnapshot,
...baseConfigSnapshot,
config: {
channels: {
telegram: {
@@ -311,7 +296,7 @@ describe("channels command", () => {
it("migrates base names when adding non-default accounts", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({
...baseSnapshot,
...baseConfigSnapshot,
config: {
channels: {
discord: {