@@ -51,6 +51,8 @@ const ctx = vi.hoisted(() => ({
5151 agentDb : undefined as unknown as DashboardAgentDb ,
5252 canAccess : true ,
5353 actor : undefined as undefined | { userId : string ; client ?: string ; environmentId ?: string } ,
54+ /** Every task id the suite would have triggered for real. */
55+ triggered : [ ] as string [ ] ,
5456} ) ) ;
5557
5658vi . mock ( "~/services/uatRoutePreamble.server" , ( ) => ( {
@@ -84,6 +86,23 @@ vi.mock("~/v3/canAccessDashboardAgent.server", () => ({
8486 canAccessDashboardAgent : async ( ) => ctx . canAccess ,
8587} ) ) ;
8688
89+ // The routes drive the real service, which builds a TriggerClient from .env — so an unmocked
90+ // suite triggers actual runs against whatever origin .env names.
91+ vi . mock ( "@trigger.dev/sdk" , async ( importOriginal ) => {
92+ const actual = await importOriginal < typeof import ( "@trigger.dev/sdk" ) > ( ) ;
93+ return {
94+ ...actual ,
95+ TriggerClient : class {
96+ tasks = {
97+ trigger : async ( taskId : string ) => {
98+ ctx . triggered . push ( taskId ) ;
99+ return { id : "run_test" } ;
100+ } ,
101+ } ;
102+ } ,
103+ } ;
104+ } ) ;
105+
87106const SESSION_SECRET = "test-session-secret-for-watch-tokens" ;
88107process . env . SESSION_SECRET = SESSION_SECRET ;
89108// The agent's subscribe endpoint refuses without an email transport configured.
@@ -1594,6 +1613,9 @@ describe("the check endpoint", () => {
15941613 const body = await response . json ( ) ;
15951614 expect ( body . result ) . toBe ( "terminal_unsatisfied" ) ;
15961615
1616+ // Arming the chain goes through the stubbed client, never a real trigger.
1617+ expect ( ctx . triggered ) . toContain ( "dashboard-agent-watch-batch" ) ;
1618+
15971619 const row = await getWatch ( ctx . agentDb , { id : watch . watchId } ) ;
15981620 expect ( row ?. lastCheckedAt ) . not . toBeNull ( ) ;
15991621 expect ( row ?. tickCount ) . toBe ( 0 ) ;
0 commit comments