From 6d46a52f6fc5ca3c4900aec33de1bba063750e69 Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Thu, 26 Mar 2026 10:31:20 -0700 Subject: [PATCH] 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 Co-authored-by: Claude Sonnet 4.6 --- .../cli/src/__tests__/cmd-link-cov.test.ts | 83 ------------------- 1 file changed, 83 deletions(-) diff --git a/packages/cli/src/__tests__/cmd-link-cov.test.ts b/packages/cli/src/__tests__/cmd-link-cov.test.ts index c0faaa1e..8f940195 100644 --- a/packages/cli/src/__tests__/cmd-link-cov.test.ts +++ b/packages/cli/src/__tests__/cmd-link-cov.test.ts @@ -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"); - }); });