test: remove duplicate and theatrical tests (#2858)

- aws-cov.test.ts: remove aws/BUNDLES (3 tests) and aws/credential-persistence
  (6 tests) — all scenarios already covered by aws.test.ts with stronger
  assertions (>= 5 tiers vs >= 3, pricing format, naming convention, etc.)

- cmd-run-cov.test.ts: remove "cmdRun dry run" and "cmdRun validation" (3 tests)
  — dry-run is covered more thoroughly in cmdrun-happy-path.test.ts;
  validation tests duplicate commands-error-paths.test.ts exactly

- agent-setup-cov.test.ts: remove "agents return non-empty launch commands"
  (weaker duplicate of "all agents have launchCmd") and "agents have configure
  functions" (no expect() calls — theatrical)

Total: 5 tests removed, 162 lines deleted, 0 regressions (1951 pass)

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-21 05:49:27 -07:00 committed by GitHub
parent 6d2c4746f5
commit 2f329684e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 2 additions and 162 deletions

View file

@ -125,18 +125,6 @@ describe("createCloudAgents", () => {
expect(agent.name).toBe(result.agents[firstKey].name);
});
it("agents return non-empty launch commands", () => {
const result = createCloudAgents({
runServer: mock(() => Promise.resolve()),
uploadFile: mock(() => Promise.resolve()),
downloadFile: mock(() => Promise.resolve()),
});
for (const agent of Object.values(result.agents)) {
const cmd = agent.launchCmd();
expect(cmd.length).toBeGreaterThan(0);
}
});
it("resolveAgent throws for unknown agent", () => {
const result = createCloudAgents({
runServer: mock(() => Promise.resolve()),
@ -159,22 +147,6 @@ describe("createCloudAgents", () => {
await agent.install();
expect(runner.runServer).toHaveBeenCalled();
});
it("agents have configure functions for configurable agents", async () => {
const runner = {
runServer: mock(() => Promise.resolve()),
uploadFile: mock(() => Promise.resolve()),
downloadFile: mock(() => Promise.resolve()),
};
const result = createCloudAgents(runner);
// Find an agent with a configure function
for (const agent of Object.values(result.agents)) {
if (agent.configure) {
await agent.configure("sk-or-v1-test", undefined, new Set());
break;
}
}
});
});
// ── offerGithubAuth with GITHUB_TOKEN ─────────────────────────────────

View file

@ -1,19 +1,10 @@
import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from "bun:test";
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
import { mockBunSpawn, mockClackPrompts } from "./test-helpers";
// Must mock clack before importing aws module
mockClackPrompts();
import {
BUNDLES,
DEFAULT_BUNDLE,
getAwsConfigPath,
getConnectionInfo,
getState,
loadCredsFromConfig,
saveCredsToConfig,
} from "../aws/aws";
import { DEFAULT_BUNDLE, getConnectionInfo, getState } from "../aws/aws";
// ─── Helpers ─────────────────────────────────────────────────────────────────
@ -73,101 +64,6 @@ describe("aws/getConnectionInfo", () => {
});
});
// ─── BUNDLES ─────────────────────────────────────────────────────────────────
describe("aws/BUNDLES", () => {
it("has at least 3 bundles", () => {
expect(BUNDLES.length).toBeGreaterThanOrEqual(3);
});
it("each bundle has id and label", () => {
for (const b of BUNDLES) {
expect(b.id).toBeTruthy();
expect(b.label).toBeTruthy();
}
});
it("DEFAULT_BUNDLE is in BUNDLES list", () => {
expect(BUNDLES).toContainEqual(DEFAULT_BUNDLE);
});
});
// ─── Credential Persistence ──────────────────────────────────────────────────
describe("aws/credential-persistence", () => {
let savedConfig: string | null = null;
beforeEach(() => {
const path = getAwsConfigPath();
if (existsSync(path)) {
savedConfig = readFileSync(path, "utf-8");
} else {
savedConfig = null;
}
});
afterEach(() => {
const path = getAwsConfigPath();
if (savedConfig !== null) {
writeFileSync(path, savedConfig);
} else if (existsSync(path)) {
unlinkSync(path);
}
});
it("saveCredsToConfig creates file and loadCredsFromConfig reads it", async () => {
const testKey = "AKIAIOSFODNN7EXAMPLE";
const testSecret = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
await saveCredsToConfig(testKey, testSecret, "us-west-2");
const loaded = loadCredsFromConfig();
expect(loaded).not.toBeNull();
expect(loaded?.accessKeyId).toBe(testKey);
expect(loaded?.secretAccessKey).toBe(testSecret);
expect(loaded?.region).toBe("us-west-2");
});
it("loadCredsFromConfig returns null for missing file", () => {
const path = getAwsConfigPath();
if (existsSync(path)) {
unlinkSync(path);
}
expect(loadCredsFromConfig()).toBeNull();
});
it("loadCredsFromConfig returns null for bad JSON", () => {
writeFileSync(getAwsConfigPath(), "NOT_JSON", {
mode: 0o600,
});
expect(loadCredsFromConfig()).toBeNull();
});
it("loadCredsFromConfig returns null for invalid accessKeyId format", async () => {
await saveCredsToConfig("bad!!!", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "us-east-1");
expect(loadCredsFromConfig()).toBeNull();
});
it("loadCredsFromConfig returns null for invalid secretAccessKey format", async () => {
await saveCredsToConfig("AKIAIOSFODNN7EXAMPLE", "too-short", "us-east-1");
expect(loadCredsFromConfig()).toBeNull();
});
it("loadCredsFromConfig defaults region to us-east-1 when not set", async () => {
writeFileSync(
getAwsConfigPath(),
JSON.stringify({
accessKeyId: "AKIAIOSFODNN7EXAMPLE",
secretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
}),
{
mode: 0o600,
},
);
const loaded = loadCredsFromConfig();
expect(loaded?.region).toBe("us-east-1");
});
});
// ─── ensureAwsCli ────────────────────────────────────────────────────────────
describe("aws/ensureAwsCli", () => {

View file

@ -14,7 +14,7 @@ import { createConsoleMocks, createMockManifest, mockClackPrompts, restoreMocks
const clack = mockClackPrompts();
const { cmdRun, cmdRunHeadless, isRetryableExitCode } = await import("../commands/index.js");
const { cmdRunHeadless, isRetryableExitCode } = await import("../commands/index.js");
const { showDryRunPreview } = await import("../commands/run.js");
describe("commands/run.ts coverage", () => {
@ -92,34 +92,6 @@ describe("commands/run.ts coverage", () => {
});
});
// ── cmdRun with dry run ────────────────────────────────────────────────
describe("cmdRun dry run", () => {
it("shows dry run preview and returns", async () => {
global.fetch = mock(async () => new Response(JSON.stringify(mockManifest)));
await loadManifest(true);
await cmdRun("claude", "sprite", undefined, true);
expect(clack.logSuccess).toHaveBeenCalled();
});
});
// ── cmdRun additional ─────────────────────────────────────────────
describe("cmdRun validation", () => {
it("validates agent and cloud names exist", async () => {
global.fetch = mock(async () => new Response(JSON.stringify(mockManifest)));
await loadManifest(true);
await expect(cmdRun("nonexistent", "sprite")).rejects.toThrow("process.exit");
});
it("validates implementation status", async () => {
global.fetch = mock(async () => new Response(JSON.stringify(mockManifest)));
await loadManifest(true);
// hetzner/codex is "missing" in mock manifest
await expect(cmdRun("codex", "hetzner")).rejects.toThrow("process.exit");
});
});
// ── cmdRunHeadless ─────────────────────────────────────────────────────
describe("cmdRunHeadless", () => {