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:
@@ -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";
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user