Files
fusion/plugins/fusion-plugin-agent-browser/src/__tests__/index.test.ts
Fusion 43261694fe feat(FN-3573): broaden runtime ignore list for live fusion app paths (+2 more)
Commits merged:
- chore(test-isolation): broaden runtime ignore list for live fusion app paths
- feat(FN-3573): complete Step 2 — add plugin setup API client helpers
- feat(FN-3573): complete Step 1 — backfill plugin setup routes

Files changed:
plugins/fusion-plugin-agent-browser/README.md      | 26 ++++++
 plugins/fusion-plugin-agent-browser/manifest.json  | 15 ++++
 plugins/fusion-plugin-agent-browser/package.json   | 25 ++++++
 .../src/__tests__/index.test.ts                    | 66 +++++++++++++++
 .../src/__tests__/prompts.test.ts                  | 21 +++++
 .../src/__tests__/setup.test.ts                    | 39 +++++++++
 .../src/__tests__/skills.test.ts                   |  9 ++
 .../src/__tests__/tools.test.ts                    | 55 ++++++++++++
 .../src/__tests__/types.test.ts                    | 16 ++++
 .../src/__tests__/workflow-steps.test.ts           | 10 +++
 plugins/fusion-plugin-agent-browser/src/index.ts   | 67 +++++++++++++++
 plugins/fusion-plugin-agent-browser/src/probe.ts   | 98 ++++++++++++++++++++++
 plugins/fusion-plugin-agent-browser/src/prompts.ts | 23 +++++
 plugins/fusion-plugin-agent-browser/src/setup.ts   | 31 +++++++
 plugins/fusion-plugin-agent-browser/src/skills.ts  | 12 +++
 plugins/fusion-plugin-agent-browser/src/tools.ts   | 34 ++++++++
 plugins/fusion-plugin-agent-browser/src/types.ts   | 56 +++++++++++++
 .../src/workflow-steps.ts                          | 15 ++++
 plugins/fusion-plugin-agent-browser/tsconfig.json  |  9 ++
 .../fusion-plugin-agent-browser/vitest.config.ts   | 22 +++++
 pnpm-lock.yaml                                     | 16 ++++
 pnpm-workspace.yaml                                |  1 +
 22 files changed, 666 insertions(+)

Fusion-Task-Id: FN-3573
2026-05-06 15:06:24 -07:00

67 lines
2.5 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import plugin, { AGENT_BROWSER_SETTINGS_SCHEMA } from "../index.js";
import manifestJson from "../../manifest.json";
const { probeMock } = vi.hoisted(() => ({
probeMock: vi.fn(async () => ({ available: false, reason: "`agent-browser` not found on PATH" } as { available: boolean; reason?: string; version?: string })),
}));
vi.mock("../probe.js", () => ({
probeAgentBrowserBinary: probeMock,
}));
describe("agent-browser plugin index", () => {
it("exports canonical plugin id and manifest metadata", () => {
expect(plugin.manifest.id).toBe("fusion-plugin-agent-browser");
expect(manifestJson.id).toBe("fusion-plugin-agent-browser");
expect(plugin.manifest.setup?.binaryName).toBe("agent-browser");
});
it("emits load event on successful probe", async () => {
probeMock.mockResolvedValueOnce({ available: true, version: "1.0.0" });
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() };
const emitEvent = vi.fn();
await plugin.hooks.onLoad?.({
pluginId: plugin.manifest.id,
taskStore: {} as never,
settings: { promptExecutorSystem: "Use browser evidence" },
logger,
emitEvent,
});
expect(emitEvent).toHaveBeenCalledWith("agent-browser:loaded", expect.objectContaining({ available: true, version: "1.0.0" }));
expect(plugin.promptContributions?.contributions.some((p) => p.content.includes("Use browser evidence"))).toBe(true);
});
it("emits unavailable payload when probe throws", async () => {
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() };
const emitEvent = vi.fn();
probeMock.mockRejectedValueOnce(new Error("boom"));
await plugin.hooks.onLoad?.({
pluginId: plugin.manifest.id,
taskStore: {} as never,
settings: {},
logger,
emitEvent,
});
expect(logger.error).toHaveBeenCalled();
expect(emitEvent).toHaveBeenCalledWith("agent-browser:loaded", expect.objectContaining({ available: false, error: "boom" }));
});
it("has canonical settings keys", () => {
expect(Object.keys(AGENT_BROWSER_SETTINGS_SCHEMA)).toEqual([
"enabled",
"installChannel",
"commandTimeoutMs",
"headlessMode",
"allowedDomains",
"promptExecutorSystem",
"promptExecutorTask",
"promptTriage",
"promptReviewer",
"promptHeartbeat",
"skillExposure",
]);
expect(AGENT_BROWSER_SETTINGS_SCHEMA.installChannel?.defaultValue).toBe("stable");
});
});