Files
triggerdotdev--trigger.dev/apps/webapp/test/engine
Dan Sutton 5c729a4dfc refactor(webapp): move the mollifier-globally-enabled check behind a DI hook
The previous commit added a perf short-circuit at the call site that
read `env.TRIGGER_MOLLIFIER_ENABLED` directly. That broke three
mollifier integration tests in CI: the tests inject a custom
`evaluateGate` via the existing DI seam expecting the buffer-write
branch to be reached, but CI has no `.env` (the `apps/webapp/.env`
symlink target is absent), the Zod default `"0"` wins, the call site
short-circuits to `null` before the injected gate runs, and
`buffer.accepted` stays empty.

Make the global-enabled check itself injectable:

  - New constructor opt `isMollifierGloballyEnabled?: () => boolean`,
    defaulting to `() => env.TRIGGER_MOLLIFIER_ENABLED === "1"`. Each
    DI hook now represents one decision (gate, buffer, global-enabled),
    so a test that wants the buffer-write branch reached can inject
    `isMollifierGloballyEnabled: () => true` alongside its custom gate.
  - Call site now reads `this.isMollifierGloballyEnabled()` instead of
    `env.TRIGGER_MOLLIFIER_ENABLED` directly. In production, with no DI
    override, the default closure resolves `env` exactly once per call
    just as before — same perf win when the flag is off.
  - All six mollifier DI injection sites in triggerTask.test.ts now also
    pass `isMollifierGloballyEnabled: () => true` so the tests' DI
    surface matches the new contract regardless of CI env state.
2026-05-18 09:10:28 +01:00
..