Skip to content

OUT-4025: L1.0 — test-only Trigger SDK double (inline task graph) - #124

Open
SandipBajracharya wants to merge 2 commits into
mainfrom
OUT-4025
Open

OUT-4025: L1.0 — test-only Trigger SDK double (inline task graph)#124
SandipBajracharya wants to merge 2 commits into
mainfrom
OUT-4025

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

What & why

L1.0 — the prerequisite for the L1 flow tests. A test-only double of @trigger.dev/sdk so that in integration tests, every trigger / triggerAndWait / batchTrigger / batchTriggerAndWait invokes each task's own run() inline, in-process. This lets the upcoming L1 tests drive the real task graph (no Trigger dev server) with zero production change.

This PR is harness only — it does not test real sync behavior (that's L1.1–L1.4).

Changes (all under test/**)

  • test/trigger/inlineSdk.ts — the double: task, schedules, logger, ApiError
  • test/trigger/index.ts — barrel
  • test/trigger/inlineSdk.test.ts — 13 unit mechanics tests
  • test/trigger/inlineSdk.integration.test.ts — 2 integration smoke tests (drives a real task inline)
  • test/integration/setup.tsvi.mock both SDK specifiers (@trigger.dev/sdk/v3 for tasks, base @trigger.dev/sdk for withErrorLogger)

Behavior notes

  • Matches the real SDK error contract: *AndWait resolve a TaskRunResult ({ok:true/false}) on a run failure — never reject; trigger / batchTrigger are fire-and-forget; batches run every item.
  • Concurrency / retries / queues are deliberately not modelled (that's L2) — the double models the graph, not the scheduler.

Testing

  • pnpm typecheck
  • pnpm lint
  • pnpm test — 177/177 ✅
  • pnpm test:integration — 40/40 ✅

🤖 Generated with Claude Code

SandipBajracharya and others added 2 commits August 7, 2026 16:52
Test-only double of @trigger.dev/sdk: trigger/triggerAndWait/batchTrigger/
batchTriggerAndWait invoke each task's own run() inline, in-process. Matches
the real error contract - *AndWait resolve a TaskRunResult (never reject),
trigger/batchTrigger are fire-and-forget, batches run every item. No-op
logger and stub ApiError. 13 unit cases cover the mechanics.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vi.mock both SDK specifiers (@trigger.dev/sdk/v3 for tasks, base
@trigger.dev/sdk for withErrorLogger) so integration tests run the real
task graph in-process. Smoke test drives a real exported task
(processDropboxChanges) inline against Postgres.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

OUT-4025

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dropbox-integration Ready Ready Preview Aug 7, 2026 11:09am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds a test-only Trigger SDK double that executes the repository’s task graph inline during integration tests without requiring a Trigger development server.

  • Globally mocks both Trigger SDK module specifiers in integration-test setup.
  • Implements task, scheduled-task, logger, and API-error substitutes covering all currently reachable SDK imports.
  • Adds unit coverage for result, failure, batching, and ordering semantics, plus integration smoke coverage against a real exported task.

Confidence Score: 5/5

The PR appears safe to merge with no concrete blocking or independently actionable non-blocking issue identified.

The global mock covers every Trigger SDK export currently loaded by integration tests, and the observed timing and error-handling differences are deliberate parts of the documented test-harness contract.

Important Files Changed

Filename Overview
test/integration/setup.ts Installs integration-wide mocks for both Trigger SDK import specifiers; all SDK exports currently reachable from integration tests are covered.
test/trigger/inlineSdk.ts Implements the inline task handles and documented result, failure, and serial-batch behavior without an identified actionable defect.
test/trigger/inlineSdk.test.ts Exercises the double’s success, failure, batching, ordering, logger, scheduled-task, and ApiError mechanics.
test/trigger/inlineSdk.integration.test.ts Verifies setup-level mocking and confirms that a real exported task can execute inline against the integration database.

Sequence Diagram

sequenceDiagram
    participant Test as Integration test
    participant Mock as Inline SDK double
    participant Task as Real task run()
    participant Child as Child task run()
    Test->>Mock: triggerAndWait(payload)
    Mock->>Task: run(payload)
    Task->>Mock: child triggerAndWait(payload)
    Mock->>Child: run(payload)
    Child-->>Mock: output or error
    Mock-->>Task: TaskRunResult
    Task-->>Mock: output or error
    Mock-->>Test: TaskRunResult
Loading

Reviews (1): Last reviewed commit: "test(OUT-4025): wire inline Trigger SDK ..." | Re-trigger Greptile

@priosshrsth priosshrsth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants