mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
fix(core): Do not cache dynamic webhooks (#15176)
This commit is contained in:
@@ -360,4 +360,30 @@ describe('WebhookService', () => {
|
||||
expect(nodeType.webhook).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('findCached()', () => {
|
||||
test('should not cache dynamic webhooks', async () => {
|
||||
const method = 'GET';
|
||||
const webhookId = uuid();
|
||||
const fullPath = `${webhookId}/user/123/posts`;
|
||||
const dynamicWebhook = createWebhook(method, 'user/:id/posts', webhookId, 3);
|
||||
|
||||
webhookRepository.findOneBy.mockResolvedValueOnce(null); // static lookup
|
||||
webhookRepository.findBy.mockResolvedValueOnce([dynamicWebhook]); // dynamic lookup
|
||||
|
||||
const result1 = await webhookService.findWebhook(method, fullPath);
|
||||
expect(result1).toBe(dynamicWebhook);
|
||||
|
||||
expect(cacheService.set).not.toHaveBeenCalled();
|
||||
|
||||
webhookRepository.findOneBy.mockResolvedValueOnce(null);
|
||||
webhookRepository.findBy.mockResolvedValueOnce([dynamicWebhook]);
|
||||
|
||||
const result2 = await webhookService.findWebhook(method, fullPath);
|
||||
expect(result2).toBe(dynamicWebhook);
|
||||
|
||||
expect(webhookRepository.findOneBy).toHaveBeenCalledTimes(2);
|
||||
expect(webhookRepository.findBy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user