test: tighten system run command coverage

This commit is contained in:
Peter Steinberger 2026-03-14 00:30:10 +00:00
parent f806b07208
commit 767609532f
1 changed files with 24 additions and 0 deletions

View File

@ -182,6 +182,30 @@ describe("system run command helpers", () => {
expect(res.details?.code).toBe("MISSING_COMMAND"); expect(res.details?.code).toBe("MISSING_COMMAND");
}); });
test("resolveSystemRunCommand returns an empty success payload when no command is provided", () => {
const res = resolveSystemRunCommand({});
expect(res.ok).toBe(true);
if (!res.ok) {
throw new Error("unreachable");
}
expect(res.argv).toEqual([]);
expect(res.commandText).toBe("");
expect(res.shellPayload).toBeNull();
expect(res.previewText).toBeNull();
});
test("resolveSystemRunCommand stringifies non-string argv tokens", () => {
const res = resolveSystemRunCommand({
command: ["echo", 123, false, null],
});
expect(res.ok).toBe(true);
if (!res.ok) {
throw new Error("unreachable");
}
expect(res.argv).toEqual(["echo", "123", "false", "null"]);
expect(res.commandText).toBe("echo 123 false null");
});
test("resolveSystemRunCommandRequest accepts legacy shell payloads but returns canonical command text", () => { test("resolveSystemRunCommandRequest accepts legacy shell payloads but returns canonical command text", () => {
const res = resolveSystemRunCommandRequest({ const res = resolveSystemRunCommandRequest({
command: ["cmd.exe", "/d", "/s", "/c", "echo", "SAFE&&whoami"], command: ["cmd.exe", "/d", "/s", "/c", "echo", "SAFE&&whoami"],