From 5dea02bd75934d5505b680d7e462a76ac72551e6 Mon Sep 17 00:00:00 2001 From: AminDhouib Date: Fri, 11 Sep 2026 11:16:23 -0400 Subject: [PATCH] test: add buildPolicySettings to the db mock in application.real.test.ts These five tests have failed on every PR targeting canary since #209 with "Cannot read properties of undefined (reading 'findFirst')". The file mocks @dokploy/server/db with a hand-written query namespace listing only applications, deployHook, domains, patch and member; build-policy reaches db.query.buildPolicySettings on the deploy path, through planApplicationBuild -> resolveBuildPolicy -> previewBuildPolicyDecision -> findBuildPolicySettings (services/build-policy/settings.ts:18). Adds that one namespace. An unstubbed vi.fn() resolves undefined, which findBuildPolicySettings maps to null, which is the policy-off answer, so these tests keep asserting upstream deploy behaviour exactly as they did before #209. Nothing else in build-policy is reachable here: previewBuildPolicyDecision returns before touching exclusions or break-glass when the settings row is absent (resolve.ts:59-72). The four review rounds could not see this. The reviewers compared local failing-test sets against the merge base and they matched, because this same file already failed on their Windows host for an unrelated reason (S/track2/w6-review-2.md:78, "Command failed: mkdir -p C:\"). On Linux CI that problem does not exist and the file fails for the build-policy reason instead. --- apps/dokploy/__test__/deploy/application.real.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/dokploy/__test__/deploy/application.real.test.ts b/apps/dokploy/__test__/deploy/application.real.test.ts index e4f36682a6..e3e8570c6a 100644 --- a/apps/dokploy/__test__/deploy/application.real.test.ts +++ b/apps/dokploy/__test__/deploy/application.real.test.ts @@ -37,6 +37,17 @@ vi.mock("@dokploy/server/db", () => { applications: { findFirst: vi.fn(), }, + // build-policy reads this on the deploy path, through + // planApplicationBuild -> resolveBuildPolicy -> + // previewBuildPolicyDecision -> findBuildPolicySettings + // (services/build-policy/settings.ts:18). Without it the + // namespace is undefined and every test here throws + // "Cannot read properties of undefined (reading 'findFirst')". + // Resolving undefined is the policy-off answer, which is what + // these upstream-behaviour tests want. + buildPolicySettings: { + findFirst: vi.fn(), + }, deployHook: { findFirst: vi.fn(), },