test: cover auto-reply command gating

This commit is contained in:
Peter Steinberger
2026-01-11 02:27:07 +01:00
parent e0bf86f06c
commit 2d74119a08
10 changed files with 104 additions and 32 deletions

View File

@@ -1,9 +1,9 @@
import { describe, expect, it } from "vitest";
import {
formatGatewayServiceDescription,
GATEWAY_LAUNCH_AGENT_LABEL,
GATEWAY_SYSTEMD_SERVICE_NAME,
GATEWAY_WINDOWS_TASK_NAME,
formatGatewayServiceDescription,
resolveGatewayLaunchAgentLabel,
resolveGatewaySystemdServiceName,
resolveGatewayWindowsTaskName,
@@ -149,15 +149,15 @@ describe("formatGatewayServiceDescription", () => {
});
it("includes profile when set", () => {
expect(
formatGatewayServiceDescription({ profile: "work" }),
).toBe("Clawdbot Gateway (profile: work)");
expect(formatGatewayServiceDescription({ profile: "work" })).toBe(
"Clawdbot Gateway (profile: work)",
);
});
it("includes version when set", () => {
expect(
formatGatewayServiceDescription({ version: "2026.1.10" }),
).toBe("Clawdbot Gateway (v2026.1.10)");
expect(formatGatewayServiceDescription({ version: "2026.1.10" })).toBe(
"Clawdbot Gateway (v2026.1.10)",
);
});
it("includes profile and version when set", () => {

View File

@@ -103,7 +103,9 @@ function isClawdbotGatewayTaskName(name: string): boolean {
const normalized = name.trim().toLowerCase();
if (!normalized) return false;
const defaultName = resolveGatewayWindowsTaskName().toLowerCase();
return normalized === defaultName || normalized.startsWith("clawdbot gateway");
return (
normalized === defaultName || normalized.startsWith("clawdbot gateway")
);
}
function tryExtractPlistLabel(contents: string): string | null {

View File

@@ -5,9 +5,9 @@ import { promisify } from "node:util";
import { colorize, isRich, theme } from "../terminal/theme.js";
import {
formatGatewayServiceDescription,
GATEWAY_LAUNCH_AGENT_LABEL,
LEGACY_GATEWAY_LAUNCH_AGENT_LABELS,
formatGatewayServiceDescription,
resolveGatewayLaunchAgentLabel,
} from "./constants.js";
import { parseKeyValueOutput } from "./runtime-parse.js";
@@ -190,12 +190,11 @@ export function buildLaunchAgentPlist({
<key>WorkingDirectory</key>
<string>${plistEscape(workingDirectory)}</string>`
: "";
const commentXml =
comment && comment.trim()
? `
const commentXml = comment?.trim()
? `
<key>Comment</key>
<string>${plistEscape(comment.trim())}</string>`
: "";
: "";
const envXml = renderEnvDict(environment);
return `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

View File

@@ -5,8 +5,8 @@ import { promisify } from "node:util";
import { colorize, isRich, theme } from "../terminal/theme.js";
import {
LEGACY_GATEWAY_WINDOWS_TASK_NAMES,
formatGatewayServiceDescription,
LEGACY_GATEWAY_WINDOWS_TASK_NAMES,
resolveGatewayWindowsTaskName,
} from "./constants.js";
import { parseKeyValueOutput } from "./runtime-parse.js";

View File

@@ -103,7 +103,10 @@ export function resolveGatewayService(): GatewayService {
await uninstallSystemdService(args);
},
stop: async (args) => {
await stopSystemdService({ stdout: args.stdout, profile: args.profile });
await stopSystemdService({
stdout: args.stdout,
profile: args.profile,
});
},
restart: async (args) => {
await restartSystemdService({

View File

@@ -6,8 +6,8 @@ import { promisify } from "node:util";
import { runCommandWithTimeout, runExec } from "../process/exec.js";
import { colorize, isRich, theme } from "../terminal/theme.js";
import {
LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES,
formatGatewayServiceDescription,
LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES,
resolveGatewaySystemdServiceName,
} from "./constants.js";
import { parseKeyValueOutput } from "./runtime-parse.js";