Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
184 lines
5.1 KiB
TypeScript
184 lines
5.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
allowSystemManagerMutations,
|
|
buildSystemManagerTabs,
|
|
shouldCollectServerStats,
|
|
shouldShowGpuTab,
|
|
shouldShowPortsTab,
|
|
shouldShowProcessesTab,
|
|
shouldShowServicesTab,
|
|
} from "./systemTarget.ts";
|
|
import type { SessionCapabilities } from "./types.ts";
|
|
|
|
function caps(partial: Partial<SessionCapabilities> = {}): SessionCapabilities {
|
|
return {
|
|
targetOs: "linux",
|
|
hasTmux: false,
|
|
hasDocker: false,
|
|
hasNvidiaSmi: false,
|
|
hasNpuSmi: false,
|
|
hasSs: false,
|
|
hasNetstat: false,
|
|
hasLsof: false,
|
|
hasSystemctl: false,
|
|
probedAt: 1,
|
|
...partial,
|
|
};
|
|
}
|
|
|
|
test("system manager shows overview before detailed management tabs", () => {
|
|
assert.deepEqual(buildSystemManagerTabs(null, undefined, null), ["overview", "processes"]);
|
|
});
|
|
|
|
test("gpu tab appears only after nvidia-smi or npu-smi is detected", () => {
|
|
assert.equal(shouldShowGpuTab(undefined), false);
|
|
assert.equal(shouldShowGpuTab(caps()), false);
|
|
assert.equal(shouldShowGpuTab(caps({ hasNvidiaSmi: true })), true);
|
|
|
|
const host = {
|
|
id: "host-gpu",
|
|
label: "GPU",
|
|
hostname: "gpu.local",
|
|
username: "root",
|
|
tags: [],
|
|
os: "linux" as const,
|
|
};
|
|
assert.deepEqual(
|
|
buildSystemManagerTabs(host, caps({
|
|
hasTmux: true,
|
|
hasDocker: true,
|
|
hasNpuSmi: true,
|
|
hasSs: true,
|
|
hasSystemctl: true,
|
|
}), null),
|
|
["overview", "processes", "ports", "services", "tmux", "docker", "gpu"],
|
|
);
|
|
});
|
|
|
|
test("ports and services tabs are detect-first like GPU", () => {
|
|
assert.equal(shouldShowPortsTab(undefined), false);
|
|
assert.equal(shouldShowPortsTab(caps({ hasSs: true })), true);
|
|
assert.equal(shouldShowPortsTab(caps({ hasNetstat: true })), true);
|
|
assert.equal(shouldShowPortsTab(caps({ hasLsof: true })), true);
|
|
assert.equal(shouldShowServicesTab(undefined), false);
|
|
assert.equal(shouldShowServicesTab(caps({ hasSystemctl: true })), true);
|
|
});
|
|
|
|
test("network appliances keep Ports/Services read-only", () => {
|
|
const host = {
|
|
id: "host-1",
|
|
label: "Router",
|
|
hostname: "router.local",
|
|
username: "admin",
|
|
tags: [],
|
|
os: "linux" as const,
|
|
deviceType: "network" as const,
|
|
};
|
|
assert.equal(allowSystemManagerMutations(host), false);
|
|
assert.equal(allowSystemManagerMutations({
|
|
id: "host-2",
|
|
label: "Linux",
|
|
hostname: "linux.local",
|
|
username: "root",
|
|
tags: [],
|
|
os: "linux" as const,
|
|
}), true);
|
|
});
|
|
|
|
test("network devices hide processes until OS probe confirms a real target", () => {
|
|
const host = {
|
|
id: "host-1",
|
|
label: "Router",
|
|
hostname: "router.local",
|
|
username: "admin",
|
|
tags: [],
|
|
os: "linux" as const,
|
|
deviceType: "network" as const,
|
|
};
|
|
assert.equal(shouldShowProcessesTab(host, undefined), false);
|
|
assert.deepEqual(buildSystemManagerTabs(host, undefined, null), ["overview"]);
|
|
assert.equal(shouldShowProcessesTab(host, caps({ targetOs: "linux" })), true);
|
|
assert.deepEqual(
|
|
buildSystemManagerTabs(host, caps({ targetOs: "linux", hasSs: true }), null),
|
|
["overview", "processes", "ports"],
|
|
);
|
|
});
|
|
|
|
test("system overview stats skip network devices even when a Linux icon was selected", () => {
|
|
assert.equal(
|
|
shouldCollectServerStats(
|
|
{
|
|
id: "host-1",
|
|
label: "Router",
|
|
hostname: "router.local",
|
|
username: "admin",
|
|
tags: [],
|
|
os: "linux",
|
|
deviceType: "network",
|
|
},
|
|
undefined,
|
|
null,
|
|
),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("system overview stats run for Linux and macOS targets", () => {
|
|
assert.equal(
|
|
shouldCollectServerStats(
|
|
{
|
|
id: "host-1",
|
|
label: "Linux",
|
|
distro: "ubuntu",
|
|
hostname: "linux.local",
|
|
username: "root",
|
|
tags: [],
|
|
os: "linux",
|
|
},
|
|
undefined,
|
|
null,
|
|
),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
shouldCollectServerStats(
|
|
{
|
|
id: "host-2",
|
|
label: "Mac",
|
|
hostname: "mac.local",
|
|
username: "root",
|
|
tags: [],
|
|
os: "macos",
|
|
},
|
|
undefined,
|
|
null,
|
|
),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("FreeBSD icon detection does not enable unsupported system features", () => {
|
|
const host = {
|
|
id: "host-3",
|
|
label: "FreeBSD",
|
|
hostname: "freebsd.local",
|
|
username: "root",
|
|
tags: [],
|
|
os: "linux" as const,
|
|
distro: "freebsd",
|
|
};
|
|
|
|
assert.equal(shouldCollectServerStats(host, undefined, null), false);
|
|
assert.deepEqual(buildSystemManagerTabs(host, undefined, null), ["overview", "processes"]);
|
|
});
|
|
|
|
test('default Linux and cosmetic icons cannot enable Linux commands before detection', () => {
|
|
const host = {id:'unknown', label:'Host', hostname:'host', username:'user', tags:[], os:'linux' as const, manualDistro:'ubuntu', distroMode:'manual' as const};
|
|
assert.equal(shouldCollectServerStats(host, undefined, null), false);
|
|
assert.deepEqual(buildSystemManagerTabs(host, undefined, null), ['overview','processes']);
|
|
assert.equal(shouldCollectServerStats({...host,distro:'ubuntu'},undefined,null),true);
|
|
assert.equal(shouldCollectServerStats({...host,distro:'ubuntu',osOverride:'windows'},undefined,null),true);
|
|
});
|