test(FN-5102): expand agent-surface github tracking regressions

Fusion-Task-Id: FN-5102
Fusion-Task-Lineage: 13be2941-176e-4a6e-b6fc-2bb644f7444a
This commit is contained in:
Fusion (runfusion.ai)
2026-05-18 23:34:46 -07:00
committed by gsxdsm
parent 000fa3d6bb
commit a43c0cfb18
3 changed files with 43 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { mkdtemp, mkdir, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { setTaskCreatedHook } from "@fusion/core";
import { TaskStore, setTaskCreatedHook } from "@fusion/core";
const hookSpy = vi.hoisted(() => vi.fn(async () => {}));
const registerGithubTrackingHookMock = vi.hoisted(() => vi.fn(() => {
@@ -68,6 +68,13 @@ describe("extension github tracking hook wiring", () => {
expect(registerGithubTrackingHookMock).toHaveBeenCalledTimes(2);
const tool = tools.get("fn_task_create");
const taskStore = new TaskStore(repoRoot, undefined, { inMemoryDb: false });
await taskStore.init();
await taskStore.updateSettings({
githubTrackingEnabledByDefault: true,
githubTrackingDefaultRepo: "owner/repo",
});
const result = await tool.execute(
"call-1",
{ description: "extension-created task" },
@@ -81,6 +88,11 @@ describe("extension github tracking hook wiring", () => {
expect(hookSpy.mock.calls[0]?.[0]).toEqual(
expect.objectContaining({ id: result.details.taskId }),
);
const persisted = await taskStore.getTask(result.details.taskId);
expect(persisted).toBeTruthy();
expect(persisted?.githubTracking?.enabled).toBe(true);
taskStore.close();
} finally {
await rm(repoRoot, { recursive: true, force: true });
}

View File

@@ -24,6 +24,7 @@ import {
TASK_PRIORITIES,
resolveSecretAccessPolicy,
getProjectRootFromWorktree,
resolveTaskGithubTracking,
type SecretScope,
} from "@fusion/core";
import {
@@ -508,12 +509,28 @@ export default function kbExtension(pi: ExtensionAPI) {
}
try {
const projectSettings = await store.getSettings();
const globalSettings = await store.getGlobalSettingsStore().getSettings();
const resolvedTracking = resolveTaskGithubTracking(
{ githubTracking: undefined },
projectSettings,
globalSettings,
);
const task = await store.createTask({
description: params.description.trim(),
dependencies: params.depends,
assignedAgentId: normalizedAgentId === null ? undefined : normalizedAgentId,
priority: params.priority as TaskPriority | undefined,
source: { sourceType: "api" },
githubTracking: resolvedTracking.enabled
? {
enabled: true,
...(resolvedTracking.repo
? { repoOverride: `${resolvedTracking.repo.owner}/${resolvedTracking.repo.repo}` }
: {}),
}
: undefined,
});
const label =

View File

@@ -4,6 +4,7 @@ import { rm } from "node:fs/promises";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { TaskStore, setTaskCreatedHook } from "@fusion/core";
import { HeartbeatMonitor } from "../agent-heartbeat.js";
import { createDelegateTaskTool, createTaskCreateTool } from "../agent-tools.js";
const githubTrackingHookModulePromise: Promise<any> = import("../../../dashboard/src/github-tracking-hook.js");
@@ -61,6 +62,18 @@ describe("agent task creation githubTracking.enabled persistence", () => {
{} as never,
),
},
{
name: "heartbeat trackedCreateTool",
run: async () => {
const monitor = new HeartbeatMonitor({
store: { listAgents: vi.fn().mockResolvedValue([]), getAgent: vi.fn().mockResolvedValue(null), getRatingSummary: vi.fn().mockResolvedValue({ averageScore: null, trend: "stable", totalRatings: 0, categoryAverages: {} }), getRatings: vi.fn().mockResolvedValue([]), updateAgent: vi.fn().mockResolvedValue(undefined) } as never,
taskStore: store,
rootDir,
});
const tool = monitor.createHeartbeatTools("agent-1", store, "FN-000").find((entry) => entry.name === "fn_task_create");
return tool!.execute("call-1", { description: "heartbeat tracked task" } as never, undefined, undefined, {} as never);
},
},
])("persists githubTracking.enabled and invokes tracking hook for $name", async ({ run }) => {
const githubTrackingHookModule = await githubTrackingHookModulePromise;
const githubTrackingModule = await githubTrackingModulePromise;