mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-20 01:11:18 +00:00
test: remove duplicate and theatrical tests (#2873)
Remove 7 redundant tests that test the same code paths as existing tests: - history.test.ts: consolidate 4 separate "unrecognized JSON value" tests (non-array object, JSON string, null, number) into one data-driven test. All 4 hit the identical parseHistoryData "Unrecognized format" branch. - cmd-link-cov.test.ts: remove "exits with error when no IP provided" — duplicate of the same test in cmd-link.test.ts with identical behavior. - update-check-cov.test.ts: remove "skips in test environment" and "skips when SPAWN_NO_UPDATE_CHECK=1" — both already covered in update-check.test.ts. - orchestrate-cov.test.ts: remove "calls preLaunch when defined" — identical to the same test in orchestrate.test.ts (same mock setup, same assertion). All 1866 remaining tests pass. Lint clean. Co-authored-by: spawn-qa-bot <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c25594cf09
commit
87f49eba48
4 changed files with 10 additions and 69 deletions
|
|
@ -274,23 +274,6 @@ describe("cmdLink (additional coverage)", () => {
|
|||
expect(clack.logError).toHaveBeenCalledWith(expect.stringContaining("not reachable"));
|
||||
});
|
||||
|
||||
it("exits with error when no IP provided", async () => {
|
||||
const consoleSpy = spyOn(console, "error").mockImplementation(() => {});
|
||||
await asyncTryCatch(() =>
|
||||
cmdLink(
|
||||
[
|
||||
"link",
|
||||
],
|
||||
{
|
||||
tcpCheck: TCP_REACHABLE,
|
||||
sshCommand: SSH_NO_DETECT,
|
||||
},
|
||||
),
|
||||
);
|
||||
expect(processExitSpy).toHaveBeenCalledWith(1);
|
||||
consoleSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("exits with error for invalid IP address", async () => {
|
||||
const consoleSpy = spyOn(console, "error").mockImplementation(() => {});
|
||||
await asyncTryCatch(() =>
|
||||
|
|
|
|||
|
|
@ -60,29 +60,19 @@ describe("history", () => {
|
|||
expect(loadHistory()).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns empty array when file contains a non-array JSON value", () => {
|
||||
writeFileSync(
|
||||
join(testDir, "history.json"),
|
||||
it("returns empty array when file contains an unrecognized JSON value", () => {
|
||||
// All non-array, non-v1 JSON values hit the same "Unrecognized format" branch
|
||||
for (const content of [
|
||||
JSON.stringify({
|
||||
not: "array",
|
||||
}),
|
||||
);
|
||||
expect(loadHistory()).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns empty array when file contains a JSON string", () => {
|
||||
writeFileSync(join(testDir, "history.json"), JSON.stringify("just a string"));
|
||||
expect(loadHistory()).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns empty array when file contains JSON null", () => {
|
||||
writeFileSync(join(testDir, "history.json"), "null");
|
||||
expect(loadHistory()).toEqual([]);
|
||||
});
|
||||
|
||||
it("returns empty array when file contains JSON number", () => {
|
||||
writeFileSync(join(testDir, "history.json"), "42");
|
||||
expect(loadHistory()).toEqual([]);
|
||||
JSON.stringify("just a string"),
|
||||
"null",
|
||||
"42",
|
||||
]) {
|
||||
writeFileSync(join(testDir, "history.json"), content);
|
||||
expect(loadHistory()).toEqual([]);
|
||||
}
|
||||
});
|
||||
|
||||
it("loads multiple records preserving order", () => {
|
||||
|
|
|
|||
|
|
@ -517,22 +517,6 @@ describe("orchestrate SPAWN_NAME", () => {
|
|||
});
|
||||
});
|
||||
|
||||
// ── preLaunch hooks ───────────────────────────────────────────────────
|
||||
|
||||
describe("orchestrate preLaunch", () => {
|
||||
it("calls preLaunch when defined", async () => {
|
||||
const preLaunch = mock(() => Promise.resolve());
|
||||
const cloud = createMockCloud();
|
||||
const agent = createMockAgent({
|
||||
preLaunch,
|
||||
});
|
||||
|
||||
await runSafe(cloud, agent, "testagent");
|
||||
|
||||
expect(preLaunch).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
// ── tunnel support ────────────────────────────────────────────────────
|
||||
|
||||
describe("orchestrate tunnel", () => {
|
||||
|
|
|
|||
|
|
@ -68,22 +68,6 @@ describe("update-check.ts coverage", () => {
|
|||
// ── checkForUpdates skip conditions ────────────────────────────────────
|
||||
|
||||
describe("checkForUpdates skip conditions", () => {
|
||||
it("skips in test environment (NODE_ENV=test)", async () => {
|
||||
process.env.NODE_ENV = "test";
|
||||
global.fetch = mock(async () => new Response("1.0.0"));
|
||||
const { checkForUpdates } = await import("../update-check");
|
||||
await checkForUpdates();
|
||||
expect(global.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("skips when SPAWN_NO_UPDATE_CHECK=1", async () => {
|
||||
process.env.SPAWN_NO_UPDATE_CHECK = "1";
|
||||
global.fetch = mock(async () => new Response("1.0.0"));
|
||||
const { checkForUpdates } = await import("../update-check");
|
||||
await checkForUpdates();
|
||||
expect(global.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("skips when recently backed off", async () => {
|
||||
writeUpdateFailed(Date.now()); // failed just now
|
||||
global.fetch = mock(async () => new Response("1.0.0"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue