From 979a88b743860be1be4c6303bfc18dc3bcfd223f Mon Sep 17 00:00:00 2001 From: spawn-qa-bot Date: Mon, 30 Mar 2026 12:43:31 +0000 Subject: [PATCH 1/3] test: remove duplicate and theatrical tests - update-check.test.ts: fix 3 tests using stale hardcoded version '0.2.3' (older than current 0.29.1) to use `pkg.version` so 'should not update when up to date' actually tests the current-version path correctly - run-path-credential-display.test.ts: strengthen weak `toBeDefined()` assertion on digitalocean hint to `toContain('Simple cloud hosting')`, making it verify the actual fallback hint content Co-Authored-By: Claude Sonnet 4.6 --- .../cli/src/__tests__/run-path-credential-display.test.ts | 2 +- packages/cli/src/__tests__/update-check.test.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/__tests__/run-path-credential-display.test.ts b/packages/cli/src/__tests__/run-path-credential-display.test.ts index 5f1eceec9..2dc5ec34e 100644 --- a/packages/cli/src/__tests__/run-path-credential-display.test.ts +++ b/packages/cli/src/__tests__/run-path-credential-display.test.ts @@ -219,7 +219,7 @@ describe("prioritizeCloudsByCredentials", () => { expect(result.hintOverrides["hetzner"]).toContain("credentials detected"); expect(result.hintOverrides["hetzner"]).toContain("test"); - expect(result.hintOverrides["digitalocean"]).toBeDefined(); + expect(result.hintOverrides["digitalocean"]).toContain("Simple cloud hosting"); }); it("should handle multi-var auth (both vars must be set)", () => { diff --git a/packages/cli/src/__tests__/update-check.test.ts b/packages/cli/src/__tests__/update-check.test.ts index 54b00fddf..64e27605f 100644 --- a/packages/cli/src/__tests__/update-check.test.ts +++ b/packages/cli/src/__tests__/update-check.test.ts @@ -4,6 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from "bun:te import fs from "node:fs"; import path from "node:path"; import { tryCatch } from "@openrouter/spawn-shared"; +import pkg from "../../package.json"; // ── Test Helpers ─────────────────────────────────────────────────────────────── @@ -135,7 +136,7 @@ describe("update-check", () => { }); it("should not update when up to date", async () => { - const mockFetch = mock(() => Promise.resolve(new Response("0.2.3\n"))); + const mockFetch = mock(() => Promise.resolve(new Response(`${pkg.version}\n`))); const fetchSpy = spyOn(global, "fetch").mockImplementation(mockFetch); // Mock executor to prevent actual commands @@ -396,7 +397,7 @@ describe("update-check", () => { // Write an old timestamp (2 hours ago) writeUpdateChecked(Date.now() - 2 * 60 * 60 * 1000); - const mockFetch = mock(() => Promise.resolve(new Response("0.2.3\n"))); + const mockFetch = mock(() => Promise.resolve(new Response(`${pkg.version}\n`))); const fetchSpy = spyOn(global, "fetch").mockImplementation(mockFetch); const { checkForUpdates } = await import("../update-check.js"); @@ -407,7 +408,7 @@ describe("update-check", () => { }); it("should write cache file after successful version fetch", async () => { - const mockFetch = mock(() => Promise.resolve(new Response("0.2.3\n"))); + const mockFetch = mock(() => Promise.resolve(new Response(`${pkg.version}\n`))); const fetchSpy = spyOn(global, "fetch").mockImplementation(mockFetch); const { checkForUpdates } = await import("../update-check.js"); From ebd39f67e8a11e1428263c53b3f973d054a844dd Mon Sep 17 00:00:00 2001 From: spawn-qa-bot Date: Mon, 30 Mar 2026 16:40:40 +0000 Subject: [PATCH 2/3] test: replace theatrical no-assert tests with real assertions in recursive-spawn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two tests in recursive-spawn.test.ts captured console.log output into a logs array but never asserted against it. Both ended with a comment like "should not throw" — meaning they only proved the function didn't crash, not that it produced the right output. - "shows empty message when no history": now spies on p.log.info and asserts cmdTree() emits "No spawn history found." - "shows flat message when no parent-child relationships": now asserts cmdTree() emits "no parent-child relationships" via p.log.info. expect() call count: 4831 to 4834 (+3 real assertions added). Co-Authored-By: Claude Sonnet 4.6 --- .../cli/src/__tests__/recursive-spawn.test.ts | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/__tests__/recursive-spawn.test.ts b/packages/cli/src/__tests__/recursive-spawn.test.ts index fac81be26..f653a0f4b 100644 --- a/packages/cli/src/__tests__/recursive-spawn.test.ts +++ b/packages/cli/src/__tests__/recursive-spawn.test.ts @@ -1,8 +1,9 @@ import type { SpawnRecord } from "../history.js"; -import { afterEach, beforeEach, describe, expect, it, spyOn } from "bun:test"; +import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from "bun:test"; import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; import { join } from "node:path"; +import * as p from "@clack/prompts"; import { findDescendants, pullChildHistory } from "../commands/delete.js"; import { cmdTree } from "../commands/tree.js"; import { exportHistory, HISTORY_SCHEMA_VERSION, loadHistory, mergeChildHistory, saveSpawnRecord } from "../history.js"; @@ -396,16 +397,14 @@ describe("recursive spawn", () => { describe("cmdTree", () => { it("shows empty message when no history", async () => { - const logs: string[] = []; - const origLog = console.log; - console.log = (...args: unknown[]) => { - logs.push(args.map(String).join(" ")); - }; + const logInfoSpy = spyOn(p.log, "info").mockImplementation(mock(() => {})); await cmdTree(); - console.log = origLog; - // p.log.info writes to stderr, not captured — but cmdTree should not throw + expect(logInfoSpy).toHaveBeenCalled(); + const calls = logInfoSpy.mock.calls.map((args) => String(args[0])); + expect(calls.some((msg) => msg.includes("No spawn history found"))).toBe(true); + logInfoSpy.mockRestore(); }); it("renders tree with parent-child relationships", async () => { @@ -517,19 +516,17 @@ describe("recursive spawn", () => { timestamp: "2026-03-24T01:00:00.000Z", }); - const logs: string[] = []; - const origLog = console.log; - console.log = (...args: unknown[]) => { - logs.push(args.map(String).join(" ")); - }; - + const logInfoSpy = spyOn(p.log, "info").mockImplementation(mock(() => {})); const manifestMod = await import("../manifest.js"); const manifestSpy = spyOn(manifestMod, "loadManifest").mockRejectedValue(new Error("no network")); await cmdTree(); - console.log = origLog; manifestSpy.mockRestore(); + + const calls = logInfoSpy.mock.calls.map((args) => String(args[0])); + expect(calls.some((msg) => msg.includes("no parent-child relationships"))).toBe(true); + logInfoSpy.mockRestore(); }); it("renders deleted and depth labels", async () => { From cedd1b90165ceeff3fa572c713b3b45253db46f3 Mon Sep 17 00:00:00 2001 From: spawn-qa-bot Date: Mon, 30 Mar 2026 20:27:29 +0000 Subject: [PATCH 3/3] test: consolidate redundant describe block in cmd-fix-cov.test.ts The file had two separate describe blocks with identical beforeEach/afterEach boilerplate. The second block ("fixSpawn connection edge cases") contained only one test ("shows success when fix script succeeds") and could be merged directly into the first block ("fixSpawn (additional coverage)") without any loss of coverage or setup fidelity. Removes 23 lines of duplicated boilerplate. Test count unchanged (6 tests). --- .../cli/src/__tests__/cmd-fix-cov.test.ts | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/packages/cli/src/__tests__/cmd-fix-cov.test.ts b/packages/cli/src/__tests__/cmd-fix-cov.test.ts index 00503f446..a8d5950e5 100644 --- a/packages/cli/src/__tests__/cmd-fix-cov.test.ts +++ b/packages/cli/src/__tests__/cmd-fix-cov.test.ts @@ -151,29 +151,6 @@ describe("fixSpawn (additional coverage)", () => { }); expect(clack.logStep).toHaveBeenCalledWith(expect.stringContaining("1.2.3.4")); }); -}); - -// ── Tests: fixSpawn success message ────────────────────────────────────────── -// (error paths are covered in cmd-fix.test.ts; this covers the exact success message) - -describe("fixSpawn connection edge cases", () => { - let savedApiKey: string | undefined; - - beforeEach(() => { - savedApiKey = process.env.OPENROUTER_API_KEY; - process.env.OPENROUTER_API_KEY = "sk-or-test-fix-key"; - clack.logError.mockReset(); - clack.logSuccess.mockReset(); - clack.logStep.mockReset(); - }); - - afterEach(() => { - if (savedApiKey === undefined) { - delete process.env.OPENROUTER_API_KEY; - } else { - process.env.OPENROUTER_API_KEY = savedApiKey; - } - }); it("shows success when fix script succeeds", async () => { const mockRunner = mock(async () => true);