feat(FN-3053): consolidate mock helpers across CLI, dashboard, and engine p

The merge consolidates mock helpers across packages by creating a new shared `mockCoreEngine.ts` in the CLI package and strengthening the core/engine helpers, then migrating both CLI command tests and the dashboard's `AgentsView` tests to use the canonical helpers. It also publishes SSE architecture

Fusion-Task-Id: FN-3053
This commit is contained in:
Fusion
2026-05-01 05:02:16 -07:00
committed by gsxdsm
parent 5eb1d09787
commit fc3864ebd4
10 changed files with 226 additions and 47 deletions

View File

@@ -3,6 +3,12 @@
*
* Add new `app/api.ts` or `app/api/legacy.ts` exports here first before
* introducing ad-hoc per-test `vi.mock("../../api", …)` export lists.
*
* Behavior contract:
* - preserve real exports by default
* - apply canonical/common test mocks
* - allow per-suite overrides
* - auto-synthesize stable fallback fns for missing callable exports
*/
import { vi, type Mock } from "vitest";

View File

@@ -27,6 +27,16 @@ describe("dashboard test mock helpers", () => {
expect(rendered.props.className).toBe("x");
});
it("preserves real non-function exports and respects overrides", async () => {
const module = await createDashboardApiMock(
async () => ({ API_VERSION: "v1", fetchTasks: async () => ["real"] }),
{ fetchTasks: vi.fn().mockResolvedValue(["mocked"]) },
);
expect(module.API_VERSION).toBe("v1");
await expect((module.fetchTasks as () => Promise<string[]>)()).resolves.toEqual(["mocked"]);
});
it("keeps canonical dashboard api mocks resettable", () => {
dashboardApiMocks.fetchSettings.mockResolvedValueOnce({ hello: "world" });
resetDashboardApiMockState();