mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Prevent calling internal hook email event if emailing is disabled (#8462)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -19,6 +19,7 @@ import { createUser } from '../shared/db/users';
|
||||
import { createWorkflow, getWorkflowSharing, shareWorkflowWithUsers } from '../shared/db/workflows';
|
||||
import { License } from '@/License';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
import config from '@/config';
|
||||
|
||||
let owner: User;
|
||||
let member: User;
|
||||
@@ -149,7 +150,7 @@ describe('PUT /workflows/:id', () => {
|
||||
|
||||
const secondSharedWorkflows = await getWorkflowSharing(workflow);
|
||||
expect(secondSharedWorkflows).toHaveLength(2);
|
||||
expect(mailer.notifyWorkflowShared).toHaveBeenCalledTimes(1);
|
||||
expect(mailer.notifyWorkflowShared).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('PUT /workflows/:id/share should allow sharing by the owner of the workflow', async () => {
|
||||
@@ -225,6 +226,20 @@ describe('PUT /workflows/:id', () => {
|
||||
expect(sharedWorkflows).toHaveLength(1);
|
||||
expect(mailer.notifyWorkflowShared).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test('should not call internal hooks listener for email sent if emailing is disabled', async () => {
|
||||
config.set('userManagement.emails.mode', '');
|
||||
|
||||
const workflow = await createWorkflow({}, owner);
|
||||
|
||||
const response = await authOwnerAgent
|
||||
.put(`/workflows/${workflow.id}/share`)
|
||||
.send({ shareWithIds: [member.id] });
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
|
||||
config.set('userManagement.emails.mode', 'smtp');
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /workflows/new', () => {
|
||||
|
||||
Reference in New Issue
Block a user