Skip to content

Commit 0ef3a6b

Browse files
d-csclaude
andcommitted
test(run-ops split): repair mollifier claim-resolution db.server mock
The write-path split added static `runOpsLegacyPrisma`/`runOpsNewPrisma` imports to idempotencyKeys.server.ts, which this test loads. vitest validates every named import against the `~/db.server` mock, so the mock now errored on the missing run-ops singletons. Add the four run-ops exports (empty stubs, same boundary pattern as the batchTriggerV3 residency test) and pin isSplitEnabled() to false so the dedup routing deterministically returns the injected fake prisma regardless of the ambient RUN_OPS_SPLIT_ENABLED. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 349ac75 commit 0ef3a6b

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

apps/webapp/test/mollifierClaimResolution.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ import { describe, expect, it, vi } from "vitest";
33
// Stub `~/db.server` before importing the concern — the real module
44
// eagerly calls `prisma.$connect()` at singleton construction, which
55
// would fail without a database. The concern under test receives its
6-
// prisma via the constructor, so the stub is never used by the code path.
7-
vi.mock("~/db.server", () => ({ prisma: {}, $replica: {} }));
6+
// prisma via the constructor, so these empty stubs are never used by the
7+
// tested path; the run-ops singletons only satisfy the concern's static
8+
// imports (vitest validates every named import against the mock).
9+
vi.mock("~/db.server", () => ({
10+
prisma: {},
11+
$replica: {},
12+
runOpsNewPrisma: {},
13+
runOpsLegacyPrisma: {},
14+
runOpsNewReplica: {},
15+
runOpsLegacyReplica: {},
16+
}));
817

918
// The IdempotencyKeyConcern resolves the pre-gate claim through the
1019
// global mollifier buffer (`getMollifierBuffer`), shared by both
@@ -22,6 +31,13 @@ vi.mock("~/v3/mollifier/mollifierBuffer.server", () => ({
2231
vi.mock("~/v3/mollifier/mollifierGate.server", () => ({
2332
makeResolveMollifierFlag: () => async () => h.orgFlag,
2433
}));
34+
// Pin the idempotency dedup routing to the injected fake prisma: split OFF
35+
// makes resolveIdempotencyDedupClient return the concern's constructor client,
36+
// so these tests exercise claim resolution deterministically regardless of the
37+
// ambient RUN_OPS_SPLIT_ENABLED (the split path routes to the empty runOps mocks).
38+
vi.mock("~/v3/runOpsMigration/splitMode.server", () => ({
39+
isSplitEnabled: async () => false,
40+
}));
2541

2642
import type { MollifierBuffer } from "@trigger.dev/redis-worker";
2743
import { IdempotencyKeyConcern } from "~/runEngine/concerns/idempotencyKeys.server";

0 commit comments

Comments
 (0)