From 59815fd56377df09a8239783ec178baf0521e789 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Fri, 17 Jul 2026 15:02:25 -0700 Subject: [PATCH] FN-8240: restore dashboard API test coverage Restore quarantined dashboard API coverage and harden PostgreSQL template setup. - Re-enable 18 dashboard API tests by clearing their quarantine ledger and Vitest exclusions. - Preserve remote tunnel providers in route test mocks. - Prevent PostgreSQL template cleanup races and terminate stale template sessions before copies. Files changed: .../core/src/__test-utils__/pg-test-harness.ts | 28 ++++--- .../src/__tests__/routes-remote-access.test.ts | 7 +- packages/dashboard/vitest.config.ts | 25 ++---- scripts/lib/test-quarantine.json | 90 ---------------------- 4 files changed, 30 insertions(+), 120 deletions(-) Fusion-Task-Id: FN-8240 Fusion-Task-Lineage: 19269246-4eb7-418f-ab0d-bf90ba5dfb49 Co-authored-by: Fusion (runfusion.ai) --- .../src/__test-utils__/pg-test-harness.ts | 28 +++--- .../__tests__/routes-remote-access.test.ts | 7 +- packages/dashboard/vitest.config.ts | 25 ++---- scripts/lib/test-quarantine.json | 90 ------------------- 4 files changed, 30 insertions(+), 120 deletions(-) diff --git a/packages/core/src/__test-utils__/pg-test-harness.ts b/packages/core/src/__test-utils__/pg-test-harness.ts index 76cb2bdff5..23d7a5fd6d 100644 --- a/packages/core/src/__test-utils__/pg-test-harness.ts +++ b/packages/core/src/__test-utils__/pg-test-harness.ts @@ -374,17 +374,12 @@ export const __pgTestTemplateTestHooks = { }; /* - * FNXC:PgTestTemplateDb 2026-07-17-14:34: - * Per-module templates must not accumulate for the lifetime of a successful - * worker. `beforeExit` permits this best-effort async cleanup after the module - * has finished its tests; crashes remain reclaimable through the dead-pid sweep. + * FNXC:PgTestTemplateDb 2026-07-17-22:25: + * Do not register module-local `beforeExit` cleanup. Vitest can reach a transient + * beforeExit state while sibling isolated module registries still copy from their + * templates, so that handler races and drops live sources. The dead-pid sweep in + * ensureSchemaTemplate reclaims templates after the owning worker actually exits. */ -process.once("beforeExit", () => { - const templateName = templateDbName(); - void withMaintenanceSql(async (client) => { - await client.unsafe(`DROP DATABASE IF EXISTS "${templateName}" WITH (FORCE)`); - }).catch(() => {}); -}); /** * FNXC:PgTestTemplateDb 2026-07-16-17:40: @@ -499,6 +494,19 @@ export async function createTaskStoreForTest(options?: { // nonce-bearing template names keep isolated modules on disjoint sources. const template = await ensureSchemaTemplate(); await serializeTemplateCopy(async () => { + /* + * FNXC:PgTestTemplateDb 2026-07-17-22:34: + * PostgreSQL can retain a just-closed baseline connection briefly. Terminate + * stale template sessions immediately before copying; the module-local copy + * mutex ensures this never interrupts a sibling copy using the same source. + */ + await withMaintenanceSql(async (client) => { + await client` + SELECT pg_terminate_backend(pid) + FROM pg_stat_activity + WHERE datname = ${template} AND pid <> pg_backend_pid() + `; + }); try { await adminExecAsync(`DROP DATABASE IF EXISTS "${dbName}"`); } catch { diff --git a/packages/dashboard/src/__tests__/routes-remote-access.test.ts b/packages/dashboard/src/__tests__/routes-remote-access.test.ts index 376bf6b54a..19a83e6f15 100644 --- a/packages/dashboard/src/__tests__/routes-remote-access.test.ts +++ b/packages/dashboard/src/__tests__/routes-remote-access.test.ts @@ -246,9 +246,14 @@ describe("remote access API route contracts", () => { url: "https://remote.example.com", lastError: null, }), + /* + FNXC:RemoteAccessTests 2026-07-17-22:18: + The stop endpoint preserves the provider that owned the completed tunnel so callers + can render the stopped lifecycle state consistently. Keep the mock aligned with that contract. + */ stopRemoteTunnel: vi.fn().mockResolvedValue({ state: "stopped", - provider: null, + provider: "cloudflare", url: null, lastError: null, }), diff --git a/packages/dashboard/vitest.config.ts b/packages/dashboard/vitest.config.ts index 36e6e13925..46fec320b4 100644 --- a/packages/dashboard/vitest.config.ts +++ b/packages/dashboard/vitest.config.ts @@ -341,25 +341,12 @@ const quarantinedDashboardTests: string[] = [ "app/components/__tests__/TaskDetailModal.oversight-mobile.test.tsx", "app/components/__tests__/PlanningModeModal.planning-flow.test.tsx", "app/components/__tests__/QuickEntryBox.test.tsx", - // FNXC:DashboardTests 2026-07-14-22:15: VAL-REMOVAL-005 — API backfill suites still boot sync SQLite Database via TaskStore.init; quarantine until PG harness conversion (ledger lockstep). - "src/__tests__/chat-project-services.test.ts", - "src/__tests__/planning-generation-cancellation.test.ts", - "src/__tests__/process-lifecycle.test.ts", - "src/__tests__/register-signal-routes.test.ts", - "src/__tests__/routes-agent-prompt-sizes-integration.test.ts", - "src/__tests__/routes-remote-access.test.ts", - "src/__tests__/routes-system.test.ts", - "src/routes/__tests__/register-settings-memory-worktrunk.test.ts", - "src/routes/__tests__/tasks-overseer-controls.test.ts", - "src/routes/__tests__/tasks-planner-overseer-state.test.ts", - "src/__tests__/mcp-helper-forwarding.test.ts", - "src/__tests__/gitlab-source-issue-reconciler.test.ts", - "src/__tests__/server-view-preload.test.ts", - "src/__tests__/task-effective-settings-route.test.ts", - "src/routes/__tests__/agent-avatar-routes.test.ts", - "src/routes/__tests__/mission-workflow-triage-route.test.ts", - "src/routes/__tests__/workflow-validate-route.test.ts", - "src/__tests__/mesh-routes.test.ts", + /* + FNXC:DashboardTests 2026-07-17-22:10: + FN-8240 verified the 18 VAL-REMOVAL-005 dashboard API tests on their PG-backed + async-store or applicable mock/non-store contracts. Remove their ledger/exclude + pairs so dashboard-api-quality-backfill collects the restored coverage. + */ // FNXC:DashboardTests 2026-07-17-06:35: inventory + ledger lockstep — build-only dist assert not in quality projects. "src/__tests__/plugin-registry-dist.test.ts", ]; diff --git a/scripts/lib/test-quarantine.json b/scripts/lib/test-quarantine.json index 24d29d9735..44943100fb 100644 --- a/scripts/lib/test-quarantine.json +++ b/scripts/lib/test-quarantine.json @@ -126,100 +126,10 @@ "reason": "Flake under concurrent quality load. Quarantine on sight; mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", "quarantinedAt": "2026-07-17" }, - { - "file": "packages/dashboard/src/__tests__/chat-project-services.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: fails via sync SQLite Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/gitlab-source-issue-reconciler.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/mcp-helper-forwarding.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: createInsightTaskStore still calls TaskStore/Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/mesh-routes.test.ts", - "reason": "VAL-REMOVAL-005 / ungated by quality projects while excluded from vitest. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/planning-generation-cancellation.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: fails via sync SQLite Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, { "file": "packages/dashboard/src/__tests__/plugin-registry-dist.test.ts", "reason": "Ungated by quality projects while excluded from vitest runs. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/process-lifecycle.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: fails via sync SQLite Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/register-signal-routes.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: fails via sync SQLite Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/routes-agent-prompt-sizes-integration.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: fails via sync SQLite Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/routes-remote-access.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: fails via sync SQLite Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/routes-system.test.ts", - "reason": "VAL-REMOVAL-005 / CPU-sample flake under loaded API lane. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/server-view-preload.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/__tests__/task-effective-settings-route.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/routes/__tests__/agent-avatar-routes.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/routes/__tests__/mission-workflow-triage-route.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/routes/__tests__/register-settings-memory-worktrunk.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/routes/__tests__/tasks-overseer-controls.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/routes/__tests__/tasks-planner-overseer-state.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: TaskStore/Database.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" - }, - { - "file": "packages/dashboard/src/routes/__tests__/workflow-validate-route.test.ts", - "reason": "VAL-REMOVAL-005 PG migration: sync SQLite Database/TaskStore.init. Mirrored packages/dashboard/vitest.config.ts. Full-suite inventory guard 2026-07-17.", - "quarantinedAt": "2026-07-17" } ] }