test(cli): consolidate schema coverage and assert input refusals

Remove 30 redundant truthy-JSON schema checks. Validate advertised groups and property parity across every primary command, retain required-field checks, and assert structured malformed-input errors. Exercise JEB positional validation rather than an unknown flag.

Validation: 13 public CLI adapter tests, combined checks, and temporary-directory hygiene. Host configuration refusal coverage from main is preserved.
This commit is contained in:
morluto
2026-10-12 05:24:33 +08:00
parent 108b5f9425
commit beb80a07ba
4 changed files with 47 additions and 68 deletions
+4 -33
View File
@@ -5,38 +5,6 @@ import {
serveCli as serve,
} from "./cliServeHarness.js";
it.each([
["inspect-adb-client"],
["list-adb-devices"],
["inspect-adb-device"],
["list-adb-packages"],
["pull-adb-package"],
["read-adb-logcat"],
["inspect-adb-package"],
["pull-adb-file"],
["push-adb-file"],
["capture-adb-screen"],
["list-adb-processes"],
["list-adb-directory"],
["list-adb-features"],
["list-adb-services"],
["inspect-adb-display"],
["inspect-adb-window"],
["read-adb-setting"],
["collect-adb-bugreport"],
["resolve-adb-packages"],
["install-adb-package"],
["uninstall-adb-package"],
["start-adb-app"],
["start-adb-activity"],
["stop-adb-app"],
])("%s advertises a schema through the public CLI", async (command) => {
const result = await serve([command, "--schema", "--json"]);
expect(result.exitCode, command).toBe(0);
const schema = JSON.parse(result.stdout) as { args?: unknown };
expect(schema).toBeTruthy();
});
it.each([
[
["inspect-adb-client", "--json"],
@@ -63,7 +31,10 @@ it.each([
it("validates device serials before contacting any device", async () => {
const result = await serve(["inspect-adb-device", "bad serial", "--json"]);
expect(result.stdout).toContain("invalid_input");
expect(JSON.parse(result.stdout)).toMatchObject({
code: "invalid_request",
category: "invalid_input",
});
});
it("requires the output directory option on pull", async () => {