From 193f3777a3ef17e30d50e70592bf3e7f106a8f3a Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Wed, 4 Mar 2026 05:32:01 -0800 Subject: [PATCH] test: Remove duplicate and theatrical tests (#2187) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Consolidate 3 identical-setup "both 404" tests into 1 test checking all assertions at once - Consolidate 2 identical-setup "both 500" tests into 1 test - Consolidate 4 near-identical network-error tests into 2 tests (error message + troubleshooting hints) - Remove duplicate validatePrompt max-length test (10KB+1 bytes) already covered in security.test.ts Removes 6 tests total (1401 → 1395). No behavior coverage lost. Co-authored-by: spawn-qa-bot Co-authored-by: Claude Sonnet 4.6 Co-authored-by: L <6723574+louisgv@users.noreply.github.com> --- .../__tests__/download-and-failure.test.ts | 90 ++----------------- .../src/__tests__/security-edge-cases.test.ts | 5 -- 2 files changed, 5 insertions(+), 90 deletions(-) diff --git a/packages/cli/src/__tests__/download-and-failure.test.ts b/packages/cli/src/__tests__/download-and-failure.test.ts index 638e6e93..14a5f3ef 100644 --- a/packages/cli/src/__tests__/download-and-failure.test.ts +++ b/packages/cli/src/__tests__/download-and-failure.test.ts @@ -187,7 +187,7 @@ describe("Download and Failure Pipeline", () => { // ── downloadScriptWithFallback: both fail ───────────────────────── describe("download - both URLs fail", () => { - it("should show 'script not found' when both return 404", async () => { + it("should show script-not-found error with recovery hints when both return 404", async () => { await setupFetch(async () => { return new Response("Not Found", { status: 404, @@ -202,48 +202,13 @@ describe("Download and Failure Pipeline", () => { expect(processExitSpy).toHaveBeenCalledWith(1); - // reportDownloadFailure should log specific 404 error const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); expect(errorOutput).toContain("doesn't exist"); - }); - - it("should suggest verifying the combination when both return 404", async () => { - await setupFetch( - async () => - new Response("Not Found", { - status: 404, - }), - ); - - try { - await cmdRun("claude", "sprite"); - } catch { - // Expected - } - - const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); expect(errorOutput).toContain("spawn matrix"); - }); - - it("should suggest reporting the issue when both return 404", async () => { - await setupFetch( - async () => - new Response("Not Found", { - status: 404, - }), - ); - - try { - await cmdRun("claude", "sprite"); - } catch { - // Expected - } - - const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); expect(errorOutput).toContain("Report it"); }); - it("should show server error message when both return 500", async () => { + it("should show server error with retry hint when both return 500", async () => { await setupFetch( async () => new Response("Server Error", { @@ -259,23 +224,6 @@ describe("Download and Failure Pipeline", () => { const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); expect(errorOutput).toContain("HTTP 500"); - }); - - it("should mention temporary server issues on 500 errors", async () => { - await setupFetch( - async () => - new Response("Server Error", { - status: 500, - }), - ); - - try { - await cmdRun("claude", "sprite"); - } catch { - // Expected - } - - const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); expect(errorOutput).toContain("temporarily unavailable"); }); @@ -308,7 +256,7 @@ describe("Download and Failure Pipeline", () => { // ── downloadScriptWithFallback: network error (fetch throws) ────── describe("download - network error", () => { - it("should call reportDownloadError when fetch throws", async () => { + it("should exit 1 and include the network error message", async () => { await setupFetch(async () => { throw new Error("DNS resolution failed"); }); @@ -325,7 +273,7 @@ describe("Download and Failure Pipeline", () => { expect(errorOutput).toContain("DNS resolution failed"); }); - it("should show troubleshooting steps on network error", async () => { + it("should show troubleshooting hints including firewall, connection check, and fallback URL", async () => { await setupFetch(async () => { throw new Error("Network timeout"); }); @@ -339,35 +287,7 @@ describe("Download and Failure Pipeline", () => { const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); expect(errorOutput).toContain("Next steps"); expect(errorOutput).toContain("internet connection"); - }); - - it("should suggest spawn list for verification on network error", async () => { - await setupFetch(async () => { - throw new Error("Connection refused"); - }); - - try { - await cmdRun("claude", "sprite"); - } catch { - // Expected - } - - const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); - expect(errorOutput).toContain("Firewall or proxy"); - }); - - it("should show the GitHub raw URL for manual access on network error", async () => { - await setupFetch(async () => { - throw new Error("ETIMEDOUT"); - }); - - try { - await cmdRun("claude", "sprite"); - } catch { - // Expected - } - - const errorOutput = consoleMocks.error.mock.calls.map((c: any[]) => c.join(" ")).join("\n"); + expect(errorOutput).toContain("Firewall"); expect(errorOutput).toContain("raw.githubusercontent.com"); }); }); diff --git a/packages/cli/src/__tests__/security-edge-cases.test.ts b/packages/cli/src/__tests__/security-edge-cases.test.ts index 785ad56e..daca53d4 100644 --- a/packages/cli/src/__tests__/security-edge-cases.test.ts +++ b/packages/cli/src/__tests__/security-edge-cases.test.ts @@ -171,11 +171,6 @@ dd if=/dev/urandom of=/tmp/random.bin bs=1M count=1 expect(() => validatePrompt("Run `cat /etc/shadow`")).toThrow("backtick"); }); - it("should reject prompts one byte over the max length", () => { - const overPrompt = "x".repeat(10 * 1024 + 1); - expect(() => validatePrompt(overPrompt)).toThrow("too long"); - }); - it("should accept multi-line prompts", () => { const multiLine = "Line 1\nLine 2\nLine 3"; expect(() => validatePrompt(multiLine)).not.toThrow();