@@ -11,6 +11,9 @@ import type { PrismaClient } from "@trigger.dev/database";
1111import { buildJwtAbility , signUserActorToken , verifyUserActorToken } from "@trigger.dev/rbac" ;
1212import { validateJWT } from "@trigger.dev/core/v3/jwt" ;
1313import { beforeEach , describe , expect , it , vi } from "vitest" ;
14+ import type * as DashboardAgentServer from "~/services/dashboardAgent.server" ;
15+ import type * as PersonalAccessTokenServer from "~/services/personalAccessToken.server" ;
16+ import type * as RbacServer from "~/services/rbac.server" ;
1417
1518const SESSION_SECRET = "test-session-secret-for-user-actor-org-scope" ;
1619
@@ -68,14 +71,14 @@ vi.mock("~/v3/runStore.server", () => ({
6871} ) ) ;
6972// The real resolver talks to the GitHub app. Echo back the project the route resolved instead.
7073vi . mock ( "~/services/dashboardAgent.server" , async ( importOriginal ) => {
71- const actual = await importOriginal < typeof import ( "~/services/dashboardAgent.server" ) > ( ) ;
74+ const actual = await importOriginal < typeof DashboardAgentServer > ( ) ;
7275 return {
7376 ...actual ,
7477 resolveDashboardAgentRepoSnapshot : mocks . resolveDashboardAgentRepoSnapshot ,
7578 } ;
7679} ) ;
7780vi . mock ( "~/services/personalAccessToken.server" , async ( importOriginal ) => {
78- const actual = await importOriginal < typeof import ( "~/services/personalAccessToken.server" ) > ( ) ;
81+ const actual = await importOriginal < typeof PersonalAccessTokenServer > ( ) ;
7982 return {
8083 ...actual ,
8184 assertSourcePatActive : mocks . assertSourcePatActive ,
@@ -95,7 +98,7 @@ let forcedAbilityCan: ((action: string, resource: unknown) => boolean) | undefin
9598// `tr_pat_e2e_token` bearer used below has none of. Only that lookup is stubbed; every UAT check
9699// (`authenticateUserActor`) stays real, aside from the opt-in ability override above.
97100vi . mock ( "~/services/rbac.server" , async ( importOriginal ) => {
98- const actual = await importOriginal < typeof import ( "~/services/rbac.server" ) > ( ) ;
101+ const actual = await importOriginal < typeof RbacServer > ( ) ;
99102 // Patched in place (not spread): the plugin's methods are bound to its own instance.
100103 const realAuthenticateUserActor = actual . rbac . authenticateUserActor . bind ( actual . rbac ) ;
101104 actual . rbac . authenticateUserActor = async (
0 commit comments