Files
openclaw-zero-token/cli/daemon-cli/shared.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

87 lines
3.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { theme } from "../../terminal/theme.js";
import {
filterContainerGenericHints,
renderGatewayServiceStartHints,
resolveDaemonContainerContext,
resolveRuntimeStatusColor,
} from "./shared.js";
describe("resolveRuntimeStatusColor", () => {
it("maps known runtime states to expected theme colors", () => {
expect(resolveRuntimeStatusColor("running")).toBe(theme.success);
expect(resolveRuntimeStatusColor("stopped")).toBe(theme.error);
expect(resolveRuntimeStatusColor("unknown")).toBe(theme.muted);
});
it("falls back to warning color for unexpected states", () => {
expect(resolveRuntimeStatusColor("degraded")).toBe(theme.warn);
expect(resolveRuntimeStatusColor(undefined)).toBe(theme.muted);
});
});
describe("renderGatewayServiceStartHints", () => {
it("resolves daemon container context from either env key", () => {
expect(
resolveDaemonContainerContext({
OPENCLAW_CONTAINER: "openclaw-demo-container",
} as NodeJS.ProcessEnv),
).toBe("openclaw-demo-container");
expect(
resolveDaemonContainerContext({
OPENCLAW_CONTAINER_HINT: "openclaw-demo-container",
} as NodeJS.ProcessEnv),
).toBe("openclaw-demo-container");
});
it("prepends a single container restart hint when OPENCLAW_CONTAINER is set", () => {
expect(
renderGatewayServiceStartHints({
OPENCLAW_CONTAINER: "openclaw-demo-container",
} as NodeJS.ProcessEnv),
).toEqual(
expect.arrayContaining([
"Restart the container or the service that manages it for openclaw-demo-container.",
]),
);
});
it("prepends a single container restart hint when OPENCLAW_CONTAINER_HINT is set", () => {
expect(
renderGatewayServiceStartHints({
OPENCLAW_CONTAINER_HINT: "openclaw-demo-container",
} as NodeJS.ProcessEnv),
).toEqual(
expect.arrayContaining([
"Restart the container or the service that manages it for openclaw-demo-container.",
]),
);
});
});
describe("filterContainerGenericHints", () => {
it("drops the generic container foreground hint when OPENCLAW_CONTAINER is set", () => {
expect(
filterContainerGenericHints(
[
"systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor.",
"If you're in a container, run the gateway in the foreground instead of `openclaw gateway`.",
],
{ OPENCLAW_CONTAINER: "openclaw-demo-container" } as NodeJS.ProcessEnv,
),
).toEqual([]);
});
it("drops the generic container foreground hint when OPENCLAW_CONTAINER_HINT is set", () => {
expect(
filterContainerGenericHints(
[
"systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor.",
"If you're in a container, run the gateway in the foreground instead of `openclaw gateway`.",
],
{ OPENCLAW_CONTAINER_HINT: "openclaw-demo-container" } as NodeJS.ProcessEnv,
),
).toEqual([]);
});
});