( session: ResolvedAuthSession, fn: () => T, )
| 53 | } |
| 54 | |
| 55 | function withMockCurrentSession<T>( |
| 56 | session: ResolvedAuthSession, |
| 57 | fn: () => T, |
| 58 | ): T { |
| 59 | const runtime = getAuthRuntime() |
| 60 | const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime) |
| 61 | ;( |
| 62 | runtime as { |
| 63 | getCurrentSession: typeof runtime.getCurrentSession |
| 64 | } |
| 65 | ).getCurrentSession = () => session |
| 66 | |
| 67 | try { |
| 68 | return fn() |
| 69 | } finally { |
| 70 | ;( |
| 71 | runtime as { |
| 72 | getCurrentSession: typeof runtime.getCurrentSession |
| 73 | } |
| 74 | ).getCurrentSession = originalGetCurrentSession |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | beforeEach(() => { |
| 79 | delete process.env.CLAUDE_CODE_PLAN_V2_AGENT_COUNT |
no test coverage detected