@@ -38,7 +38,6 @@ vi.mock('@/lib/logs/console/logger', () => ({
3838} ) )
3939
4040import { db } from '@sim/db'
41- import { createLogger } from '@/lib/logs/console/logger'
4241import { refreshOAuthToken } from '@/lib/oauth/oauth'
4342import {
4443 getCredential ,
@@ -49,7 +48,6 @@ import {
4948
5049const mockDb = db as any
5150const mockRefreshOAuthToken = refreshOAuthToken as any
52- const mockLogger = ( createLogger as any ) ( )
5351
5452describe ( 'OAuth Utils' , ( ) => {
5553 beforeEach ( ( ) => {
@@ -87,7 +85,6 @@ describe('OAuth Utils', () => {
8785 const userId = await getUserId ( 'request-id' )
8886
8987 expect ( userId ) . toBeUndefined ( )
90- expect ( mockLogger . warn ) . toHaveBeenCalled ( )
9188 } )
9289
9390 it ( 'should return undefined if workflow is not found' , async ( ) => {
@@ -96,7 +93,6 @@ describe('OAuth Utils', () => {
9693 const userId = await getUserId ( 'request-id' , 'nonexistent-workflow-id' )
9794
9895 expect ( userId ) . toBeUndefined ( )
99- expect ( mockLogger . warn ) . toHaveBeenCalled ( )
10096 } )
10197 } )
10298
@@ -121,7 +117,6 @@ describe('OAuth Utils', () => {
121117 const credential = await getCredential ( 'request-id' , 'nonexistent-id' , 'test-user-id' )
122118
123119 expect ( credential ) . toBeUndefined ( )
124- expect ( mockLogger . warn ) . toHaveBeenCalled ( )
125120 } )
126121 } )
127122
@@ -139,7 +134,6 @@ describe('OAuth Utils', () => {
139134
140135 expect ( mockRefreshOAuthToken ) . not . toHaveBeenCalled ( )
141136 expect ( result ) . toEqual ( { accessToken : 'valid-token' , refreshed : false } )
142- expect ( mockLogger . info ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Access token is valid' ) )
143137 } )
144138
145139 it ( 'should refresh token when expired' , async ( ) => {
@@ -159,13 +153,10 @@ describe('OAuth Utils', () => {
159153
160154 const result = await refreshTokenIfNeeded ( 'request-id' , mockCredential , 'credential-id' )
161155
162- expect ( mockRefreshOAuthToken ) . toHaveBeenCalledWith ( 'google' , 'refresh-token' , undefined )
156+ expect ( mockRefreshOAuthToken ) . toHaveBeenCalledWith ( 'google' , 'refresh-token' )
163157 expect ( mockDb . update ) . toHaveBeenCalled ( )
164158 expect ( mockDb . set ) . toHaveBeenCalled ( )
165159 expect ( result ) . toEqual ( { accessToken : 'new-token' , refreshed : true } )
166- expect ( mockLogger . info ) . toHaveBeenCalledWith (
167- expect . stringContaining ( 'Successfully refreshed' )
168- )
169160 } )
170161
171162 it ( 'should handle refresh token error' , async ( ) => {
@@ -182,8 +173,6 @@ describe('OAuth Utils', () => {
182173 await expect (
183174 refreshTokenIfNeeded ( 'request-id' , mockCredential , 'credential-id' )
184175 ) . rejects . toThrow ( 'Failed to refresh token' )
185-
186- expect ( mockLogger . error ) . toHaveBeenCalled ( )
187176 } )
188177
189178 it ( 'should not attempt refresh if no refresh token' , async ( ) => {
@@ -239,7 +228,7 @@ describe('OAuth Utils', () => {
239228
240229 const token = await refreshAccessTokenIfNeeded ( 'credential-id' , 'test-user-id' , 'request-id' )
241230
242- expect ( mockRefreshOAuthToken ) . toHaveBeenCalledWith ( 'google' , 'refresh-token' , undefined )
231+ expect ( mockRefreshOAuthToken ) . toHaveBeenCalledWith ( 'google' , 'refresh-token' )
243232 expect ( mockDb . update ) . toHaveBeenCalled ( )
244233 expect ( mockDb . set ) . toHaveBeenCalled ( )
245234 expect ( token ) . toBe ( 'new-token' )
@@ -251,7 +240,6 @@ describe('OAuth Utils', () => {
251240 const token = await refreshAccessTokenIfNeeded ( 'nonexistent-id' , 'test-user-id' , 'request-id' )
252241
253242 expect ( token ) . toBeNull ( )
254- expect ( mockLogger . warn ) . toHaveBeenCalled ( )
255243 } )
256244
257245 it ( 'should return null if refresh fails' , async ( ) => {
@@ -270,7 +258,6 @@ describe('OAuth Utils', () => {
270258 const token = await refreshAccessTokenIfNeeded ( 'credential-id' , 'test-user-id' , 'request-id' )
271259
272260 expect ( token ) . toBeNull ( )
273- expect ( mockLogger . error ) . toHaveBeenCalled ( )
274261 } )
275262 } )
276263} )
0 commit comments