|
|
|
@ -523,20 +523,26 @@ describe('WebhookServer', () => {
|
|
|
|
describe('User validation in handleMessageUpsert', () => {
|
|
|
|
describe('User validation in handleMessageUpsert', () => {
|
|
|
|
let mockEnsureUserExists: any;
|
|
|
|
let mockEnsureUserExists: any;
|
|
|
|
let consoleSpy: any;
|
|
|
|
let consoleSpy: any;
|
|
|
|
|
|
|
|
let originalConsoleLog: any;
|
|
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
mockEnsureUserExists = mock(() => '1234567890');
|
|
|
|
mockEnsureUserExists = mock(() => '1234567890');
|
|
|
|
// Mock the function in the module
|
|
|
|
|
|
|
|
const dbModule = await import('../../src/db');
|
|
|
|
// Mock the db module to replace ensureUserExists
|
|
|
|
dbModule.ensureUserExists = mockEnsureUserExists;
|
|
|
|
mock.module('../../src/db', () => ({
|
|
|
|
|
|
|
|
db: {},
|
|
|
|
|
|
|
|
getDb: () => ({}),
|
|
|
|
|
|
|
|
initializeDatabase: () => {},
|
|
|
|
|
|
|
|
ensureUserExists: mockEnsureUserExists
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
originalConsoleLog = console.log;
|
|
|
|
consoleSpy = mock(() => {});
|
|
|
|
consoleSpy = mock(() => {});
|
|
|
|
console.log = consoleSpy;
|
|
|
|
console.log = consoleSpy;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
afterEach(() => {
|
|
|
|
mockEnsureUserExists.mockRestore();
|
|
|
|
console.log = originalConsoleLog;
|
|
|
|
consoleSpy.mockRestore();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test('should proceed with valid user', async () => {
|
|
|
|
test('should proceed with valid user', async () => {
|
|
|
|
|