|  |  |  | @ -524,24 +524,24 @@ describe('WebhookServer', () => { | 
		
	
		
			
				|  |  |  |  |     let mockEnsureUserExists: any; | 
		
	
		
			
				|  |  |  |  |     let consoleSpy: any; | 
		
	
		
			
				|  |  |  |  |     let originalConsoleLog: any; | 
		
	
		
			
				|  |  |  |  |     let originalEnsureUserExists: any; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     beforeEach(async () => { | 
		
	
		
			
				|  |  |  |  |       // Import the db module dynamically to mock ensureUserExists locally
 | 
		
	
		
			
				|  |  |  |  |       const dbModule = await import('../../src/db'); | 
		
	
		
			
				|  |  |  |  |       originalEnsureUserExists = dbModule.ensureUserExists; | 
		
	
		
			
				|  |  |  |  |       mockEnsureUserExists = mock(() => '1234567890'); | 
		
	
		
			
				|  |  |  |  |        | 
		
	
		
			
				|  |  |  |  |       // Mock the db module to replace ensureUserExists
 | 
		
	
		
			
				|  |  |  |  |       mock.module('../../src/db', () => ({ | 
		
	
		
			
				|  |  |  |  |         db: {}, | 
		
	
		
			
				|  |  |  |  |         getDb: () => ({}), | 
		
	
		
			
				|  |  |  |  |         initializeDatabase: () => {}, | 
		
	
		
			
				|  |  |  |  |         ensureUserExists: mockEnsureUserExists | 
		
	
		
			
				|  |  |  |  |       })); | 
		
	
		
			
				|  |  |  |  |       dbModule.ensureUserExists = mockEnsureUserExists; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       originalConsoleLog = console.log; | 
		
	
		
			
				|  |  |  |  |       consoleSpy = mock(() => {}); | 
		
	
		
			
				|  |  |  |  |       console.log = consoleSpy; | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     afterEach(() => { | 
		
	
		
			
				|  |  |  |  |     afterEach(async () => { | 
		
	
		
			
				|  |  |  |  |       // Restore the original functions manually
 | 
		
	
		
			
				|  |  |  |  |       const dbModule = await import('../../src/db'); | 
		
	
		
			
				|  |  |  |  |       dbModule.ensureUserExists = originalEnsureUserExists; | 
		
	
		
			
				|  |  |  |  |       console.log = originalConsoleLog; | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | 
 |