test: remove duplicate tests from cmd-link-cov (#3013)

remove 3 tests that duplicate scenarios already covered in
cmd-link.test.ts:
- "saves record" (same as "saves a spawn record when agent/cloud given")
- "exits with error for invalid IP" (same as in cmd-link)
- "generates default name" (same as "generates a default name")

remaining 7 tests cover unique paths (IMDS detection, which-binary
fallback, spinner behavior, short flags) not in cmd-link.test.ts.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
A 2026-03-26 10:31:20 -07:00 committed by GitHub
parent 988f5bb7a9
commit 6d46a52f6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -163,39 +163,6 @@ describe("cmdLink (additional coverage)", () => {
expect(clack.logError).toHaveBeenCalledWith(expect.stringContaining("Invalid SSH user"));
});
it("saves record in non-interactive mode (skips confirm)", async () => {
const { loadHistory } = await import("../history.js");
await cmdLink(
[
"link",
"1.2.3.4",
"--agent",
"claude",
"--cloud",
"hetzner",
"--user",
"root",
],
{
tcpCheck: TCP_REACHABLE,
sshCommand: SSH_NO_DETECT,
},
);
// Non-interactive mode skips confirm and saves directly
expect(clack.logSuccess).toHaveBeenCalledWith(expect.stringContaining("Deployment linked"));
const records = loadHistory();
const thisRecord = records.find(
(r: {
connection?: {
ip?: string;
};
}) => r.connection?.ip === "1.2.3.4",
);
expect(thisRecord).toBeDefined();
});
it("uses short flags for cloud and agent", async () => {
const { loadHistory } = await import("../history.js");
@ -274,24 +241,6 @@ describe("cmdLink (additional coverage)", () => {
expect(clack.logError).toHaveBeenCalledWith(expect.stringContaining("not reachable"));
});
it("exits with error for invalid IP address", async () => {
const consoleSpy = spyOn(console, "error").mockImplementation(() => {});
await asyncTryCatch(() =>
cmdLink(
[
"link",
"not-an-ip!@#",
],
{
tcpCheck: TCP_REACHABLE,
sshCommand: SSH_NO_DETECT,
},
),
);
expect(processExitSpy).toHaveBeenCalledWith(1);
consoleSpy.mockRestore();
});
it("runs detection spinner when cloud not provided", async () => {
await cmdLink(
[
@ -311,36 +260,4 @@ describe("cmdLink (additional coverage)", () => {
const spinnerCalls = clack.spinnerStart.mock.calls.map((c: unknown[]) => String(c[0]));
expect(spinnerCalls.some((msg: string) => msg.includes("Auto-detecting"))).toBe(true);
});
it("generates default name from agent and IP when no --name flag", async () => {
const { loadHistory } = await import("../history.js");
await cmdLink(
[
"link",
"10.0.0.1",
"--agent",
"claude",
"--cloud",
"hetzner",
"--user",
"root",
],
{
tcpCheck: TCP_REACHABLE,
sshCommand: SSH_NO_DETECT,
},
);
const records = loadHistory();
const rec = records.find(
(r: {
connection?: {
ip?: string;
};
}) => r.connection?.ip === "10.0.0.1",
);
expect(rec).toBeDefined();
expect(rec?.name).toBe("claude-10-0-0-1");
});
});