perf(cli): cut test suite from 32s to 11s wall
Two heavy CLI tests were dominating wall time: - chat.test.ts "--once exits with timeout note" waited the real 30s reply-timeout floor. Added a replyTimeoutMs option to runChatInteractive so the test can use 200ms. - bundled-plugin-install.test.ts "loads the real bundled dependency graph plugin" runs esbuild and a live PluginLoader (~18s). Gated behind FUSION_RUN_SLOW_TESTS=1; the install/upgrade logic is covered by mocked unit tests in the same file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -227,12 +227,13 @@ describe("runChatInteractive", () => {
|
||||
nonInteractive: true,
|
||||
input,
|
||||
output: new PassThrough(),
|
||||
pollIntervalMs: 1000,
|
||||
pollIntervalMs: 10,
|
||||
replyTimeoutMs: 200,
|
||||
});
|
||||
|
||||
expect(code).toBe(0);
|
||||
expect(errorSpy).toHaveBeenCalledWith("No reply within 30s");
|
||||
}, 40_000);
|
||||
expect(errorSpy).toHaveBeenCalledWith("No reply within 1s");
|
||||
});
|
||||
|
||||
it("refuses oversized messages", async () => {
|
||||
const oversized = "x".repeat(8193);
|
||||
|
||||
@@ -11,6 +11,7 @@ const HISTORY_LIMIT = 20;
|
||||
export interface ChatInteractiveOptions {
|
||||
project?: string;
|
||||
pollIntervalMs?: number;
|
||||
replyTimeoutMs?: number;
|
||||
once?: boolean;
|
||||
nonInteractive?: boolean;
|
||||
input?: NodeJS.ReadableStream;
|
||||
@@ -151,7 +152,7 @@ export async function runChatInteractive(agentId: string, options: ChatInteracti
|
||||
});
|
||||
|
||||
output.write(`you → ${agentId}: ${content}\n`);
|
||||
const timeoutMs = Math.max(pollIntervalMs * 10, 30_000);
|
||||
const timeoutMs = options.replyTimeoutMs ?? Math.max(pollIntervalMs * 10, 30_000);
|
||||
const replied = await waitForReply(messageStore, agentId, printedIds, output, pollIntervalMs, timeoutMs);
|
||||
if (!replied) {
|
||||
console.error(`No reply within ${Math.ceil(timeoutMs / 1000)}s`);
|
||||
|
||||
@@ -534,7 +534,11 @@ describe("ensureBundledDependencyGraphPluginInstalled", () => {
|
||||
expect(registerCall.path).toContain(`${HERMES_PLUGIN_ID}/bundled.js`);
|
||||
});
|
||||
|
||||
it("loads the real bundled dependency graph plugin and persists a started state", async () => {
|
||||
// Heavy integration test: runs esbuild to bundle the real dependency-graph
|
||||
// plugin and load it through a live PluginLoader. ~18s wall on a fast laptop.
|
||||
// The other tests in this file cover the install/upgrade logic with mocks;
|
||||
// this one is gated behind FUSION_RUN_SLOW_TESTS=1 so day-to-day runs stay fast.
|
||||
it.skipIf(process.env.FUSION_RUN_SLOW_TESTS !== "1")("loads the real bundled dependency graph plugin and persists a started state", async () => {
|
||||
const { existsSync, mkdtempSync, statSync } = await vi.importActual<typeof import("node:fs")>("node:fs");
|
||||
const { cp, mkdir, readFile, rm, stat, copyFile } = await vi.importActual<typeof import("node:fs/promises")>("node:fs/promises");
|
||||
const { tmpdir } = await import("node:os");
|
||||
|
||||
Reference in New Issue
Block a user