Skip to content

Commit fcc26d4

Browse files
committed
test(webapp): mock db.server in the new run-store read tests
The new container tests import the service and presenter, which pull the db.server singleton in through their base classes. Mock it so the tests do not try to connect to the env database when none is reachable (the CI unit shards), matching the existing webapp container-test pattern. The tests use the injected testcontainer prisma for all reads.
1 parent ae57f25 commit fcc26d4

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

apps/webapp/test/presenters/ApiBatchResultsPresenter.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { ApiBatchResultsPresenter } from "~/presenters/v3/ApiBatchResultsPresent
66
import type { AuthenticatedEnvironment } from "~/services/apiAuth.server";
77
import { seedTestEnvironment } from "../helpers/seedTestEnvironment";
88

9+
// Neutralize the db.server singleton so importing the presenter (via BasePresenter) does not try
10+
// to connect to the env database; the test uses the injected testcontainer prisma for all reads.
11+
vi.mock("~/db.server", () => ({ prisma: {}, $replica: {} }));
12+
913
vi.setConfig({ testTimeout: 60_000 });
1014

1115
const idGenerator = customAlphabet("123456789abcdefghijkmnopqrstuvwxyz", 21);

apps/webapp/test/services/cancelTaskAttemptDependencies.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { CancelTaskAttemptDependenciesService } from "~/v3/services/cancelTaskAt
66
import { CancelTaskRunService } from "~/v3/services/cancelTaskRun.server";
77
import { seedTestEnvironment } from "../helpers/seedTestEnvironment";
88

9+
// Neutralize the db.server singleton so importing the service (via BaseService) does not try to
10+
// connect to the env database; the test uses the injected testcontainer prisma for all reads.
11+
vi.mock("~/db.server", () => ({ prisma: {}, $replica: {} }));
12+
913
vi.setConfig({ testTimeout: 60_000 });
1014

1115
const idGenerator = customAlphabet("123456789abcdefghijkmnopqrstuvwxyz", 21);

0 commit comments

Comments
 (0)