Files
openclaw-zero-token/daemon/systemd-hints.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

56 lines
2.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { formatCliCommand } from "../cli/command-format.js";
import { isSystemdUnavailableDetail, renderSystemdUnavailableHints } from "./systemd-hints.js";
describe("isSystemdUnavailableDetail", () => {
it("matches systemd unavailable error details", () => {
expect(
isSystemdUnavailableDetail("systemctl --user unavailable: Failed to connect to bus"),
).toBe(true);
expect(
isSystemdUnavailableDetail(
"systemctl not available; systemd user services are required on Linux.",
),
).toBe(true);
expect(isSystemdUnavailableDetail("permission denied")).toBe(false);
});
});
describe("renderSystemdUnavailableHints", () => {
it("renders WSL2-specific recovery hints", () => {
expect(renderSystemdUnavailableHints({ wsl: true })).toEqual([
"WSL2 needs systemd enabled: edit /etc/wsl.conf with [boot]\\nsystemd=true",
"Then run: wsl --shutdown (from PowerShell) and reopen your distro.",
"Verify: systemctl --user status",
]);
});
it("renders generic Linux recovery hints outside WSL", () => {
expect(renderSystemdUnavailableHints({ kind: "generic_unavailable" })).toEqual([
"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 \`${formatCliCommand("openclaw gateway")}\`.`,
]);
});
it("adds headless recovery hints only for user bus/session failures", () => {
expect(renderSystemdUnavailableHints({ kind: "user_bus_unavailable" })).toEqual([
"systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor.",
"On a headless server (SSH/no desktop session): run `sudo loginctl enable-linger $(whoami)` to persist your systemd user session across logins.",
"Also ensure XDG_RUNTIME_DIR is set: `export XDG_RUNTIME_DIR=/run/user/$(id -u)`, then retry.",
`If you're in a container, run the gateway in the foreground instead of \`${formatCliCommand("openclaw gateway")}\`.`,
]);
});
it("skips headless recovery hints when container context is known", () => {
expect(
renderSystemdUnavailableHints({
kind: "user_bus_unavailable",
container: true,
}),
).toEqual([
"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 \`${formatCliCommand("openclaw gateway")}\`.`,
]);
});
});