@5minds/node-red-contrib-processcube-tools 1.0.1-feature-258a01-mfm4xbwl → 1.0.1-feature-9a380c-mfm58gob

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube-tools",
3
- "version": "1.0.1-feature-258a01-mfm4xbwl",
3
+ "version": "1.0.1-feature-9a380c-mfm58gob",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED tools nodes for ProcessCube",
6
6
  "scripts": {
@@ -93,7 +93,7 @@ function createMockNodemailer(options = {}) {
93
93
  shouldFail: false,
94
94
  // New options for different email statuses
95
95
  rejectedEmails: [], // Array of emails to mark as rejected
96
- pendingEmails: [], // Array of emails to mark as pending
96
+ pendingEmails: [], // Array of emails to mark as pending
97
97
  acceptedEmails: [], // Array of emails to mark as accepted (overrides default)
98
98
  },
99
99
  options,
@@ -118,7 +118,11 @@ function createMockNodemailer(options = {}) {
118
118
  let rejected = [];
119
119
  let pending = [];
120
120
 
121
- if (settings.rejectedEmails.length > 0 || settings.pendingEmails.length > 0 || settings.acceptedEmails.length > 0) {
121
+ if (
122
+ settings.rejectedEmails.length > 0 ||
123
+ settings.pendingEmails.length > 0 ||
124
+ settings.acceptedEmails.length > 0
125
+ ) {
122
126
  // Use explicit configuration
123
127
  if (settings.rejectedEmails.includes(toEmail)) {
124
128
  rejected = [toEmail];
@@ -9,7 +9,7 @@ const {
9
9
  testUtils,
10
10
  } = require('../helpers/email-receiver.mocks.js');
11
11
 
12
- describe('Email Receiver Node - Integration Tests with Helpers', function () {
12
+ describe('E-Mail Receiver Node - Integration Tests', function () {
13
13
  // Set a reasonable timeout for integration tests
14
14
  this.timeout(10000);
15
15
 
@@ -1,16 +1,13 @@
1
1
  const { expect } = require('chai');
2
2
  const helper = require('node-red-node-test-helper');
3
- const emailSender = require('../../email-sender/email-sender.js');
4
3
  const {
5
- createMockNodemailer,
6
4
  setupModuleMocks,
7
- getMockNode,
8
5
  emailSenderConfigs,
9
6
  testFlows,
10
7
  testUtils,
11
8
  } = require('../../test/helpers/email-sender.mocks.js');
12
9
 
13
- describe('EmailSenderNode Integration Tests', function () {
10
+ describe('E-Mail Sender Node - Integration Tests', function () {
14
11
  // Set a reasonable timeout for integration tests
15
12
  this.timeout(10000);
16
13
 
@@ -1,7 +1,7 @@
1
1
  const { expect } = require('chai');
2
2
  const { createMockNodeRED, setupModuleMocks, testConfigs, testUtils } = require('../helpers/email-receiver.mocks.js');
3
3
 
4
- describe('Email Receiver Node - Unit Tests with Helpers', function () {
4
+ describe('E-Mail Receiver Node - Unit Tests', function () {
5
5
  this.timeout(10000);
6
6
 
7
7
  let emailReceiverNode;
@@ -6,7 +6,7 @@ const {
6
6
  createMockNodemailer,
7
7
  } = require('../helpers/email-sender.mocks.js');
8
8
 
9
- describe('E-Mail Sender Node Unit Tests', function () {
9
+ describe('E-Mail Sender Node - Unit Tests', function () {
10
10
  this.timeout(10000);
11
11
 
12
12
  let emailSenderNode;
@@ -100,7 +100,7 @@ describe('E-Mail Sender Node Unit Tests', function () {
100
100
  it('should send email successfully and set status to "sent"', function (done) {
101
101
  let statusSet = false;
102
102
 
103
- // ARRANGE: Initialisiere mockNodemailer
103
+ // ARRANGE: Initialize mockNodemailer
104
104
  const mockNodemailer = createMockNodemailer();
105
105
 
106
106
  // Mock the nodemailer module
@@ -147,16 +147,13 @@ describe('E-Mail Sender Node Unit Tests', function () {
147
147
  let redStatusSet = false;
148
148
 
149
149
  function checkDone() {
150
- console.log('Check done - Error:', errorHandlerCalled, 'Status:', redStatusSet);
151
150
  if (errorHandlerCalled && redStatusSet) {
152
151
  done();
153
152
  }
154
153
  }
155
154
 
156
- // Explizit shouldFail auf true setzen
155
+ // Explicitly set shouldFail to true
157
156
  const mockOptions = { shouldFail: true };
158
- console.log('Creating mock with options:', mockOptions); // Debug log
159
-
160
157
  const mockNodemailer = createMockNodemailer(mockOptions);
161
158
 
162
159
  // Mock the nodemailer module
@@ -172,14 +169,12 @@ describe('E-Mail Sender Node Unit Tests', function () {
172
169
  }
173
170
  },
174
171
  statusHandler: function (status) {
175
- console.log('Status received:', status);
176
172
  if (status.fill === 'red' && status.text === 'error sending') {
177
173
  redStatusSet = true;
178
174
  checkDone();
179
175
  }
180
176
  },
181
177
  errorHandler: function (err) {
182
- console.log('Error received:', err);
183
178
  expect(err.message).to.equal('Mock sendMail error');
184
179
  errorHandlerCalled = true;
185
180
  checkDone();
@@ -203,9 +198,7 @@ describe('E-Mail Sender Node Unit Tests', function () {
203
198
  let statusSet = false;
204
199
 
205
200
  function checkDone() {
206
- console.log('checkDone called - attachmentsChecked:', attachmentsChecked, 'statusSet:', statusSet);
207
201
  if (attachmentsChecked && statusSet) {
208
- console.log('Both conditions met, calling done');
209
202
  done();
210
203
  }
211
204
  }
@@ -221,54 +214,44 @@ describe('E-Mail Sender Node Unit Tests', function () {
221
214
  content: 'This is the second test file.',
222
215
  },
223
216
  ];
224
- console.log('Test attachments configured');
225
217
 
226
218
  const mockNodemailer = createMockNodemailer({
227
219
  onSendMail: (mailOptions) => {
228
- console.log('onSendMail called with attachments:', mailOptions.attachments);
229
220
  expect(mailOptions.attachments).to.be.an('array').with.lengthOf(2);
230
221
  expect(mailOptions.attachments[0].filename).to.equal('test1.txt');
231
222
  expect(mailOptions.attachments[1].content).to.equal('This is the second test file.');
232
223
  attachmentsChecked = true;
233
- console.log('Attachments checked successfully');
234
224
  checkDone();
235
225
  },
236
226
  });
237
- console.log('Mock nodemailer created');
238
227
 
239
228
  // Mock the nodemailer module
240
229
  delete require.cache[require.resolve('nodemailer')];
241
230
  require.cache[require.resolve('nodemailer')] = {
242
231
  exports: mockNodemailer,
243
232
  };
244
- console.log('Nodemailer mock installed');
245
233
 
246
234
  const mockRED = createMockNodeRED({
247
235
  onHandler: function (event, callback) {
248
- console.log('onHandler called with event:', event);
249
236
  if (event === 'input') {
250
237
  this.inputCallback = callback;
251
238
  }
252
239
  },
253
240
  statusHandler: function (status) {
254
- console.log('statusHandler called with status:', status);
255
241
  if (status.fill === 'green') {
256
242
  expect(status.text).to.include('sent');
257
243
  expect(status.shape).to.equal('dot');
258
244
  statusSet = true;
259
- console.log('Status set successfully');
260
245
  checkDone();
261
246
  }
262
247
  },
263
248
  errorHandler: function (err) {
264
- console.log('errorHandler called with:', err);
265
249
  done(err || new Error('Unexpected error handler called'));
266
250
  },
267
251
  });
268
252
 
269
253
  const emailSenderNode = require('../../email-sender/email-sender.js');
270
254
  emailSenderNode(mockRED);
271
- console.log('Email sender node initialized');
272
255
 
273
256
  const config = { ...emailSenderConfigs.valid };
274
257
  config.attachments = JSON.stringify(attachments);
@@ -276,7 +259,6 @@ describe('E-Mail Sender Node Unit Tests', function () {
276
259
 
277
260
  const nodeConstructor = mockRED.nodes.lastRegisteredConstructor;
278
261
  const nodeInstance = new nodeConstructor(config);
279
- console.log('Node instance created');
280
262
 
281
263
  setTimeout(() => {
282
264
  nodeInstance.inputCallback({
@@ -291,7 +273,6 @@ describe('E-Mail Sender Node Unit Tests', function () {
291
273
  let redStatusSet = false;
292
274
 
293
275
  function checkDone() {
294
- console.log('Check done - Error:', errorHandlerCalled, 'Status:', redStatusSet);
295
276
  if (errorHandlerCalled && redStatusSet) {
296
277
  done();
297
278
  }
@@ -330,7 +311,6 @@ describe('E-Mail Sender Node Unit Tests', function () {
330
311
  }
331
312
  },
332
313
  errorHandler: function (err) {
333
- console.log('Error received:', err);
334
314
  expect(err).to.equal("Attachment object is missing 'filename' or 'content' property.");
335
315
  errorHandlerCalled = true;
336
316
  checkDone();
@@ -352,14 +332,12 @@ describe('E-Mail Sender Node Unit Tests', function () {
352
332
  topic: 'test message',
353
333
  });
354
334
  });
355
- });
356
335
 
357
- it('should handle rejected emails and set status to rejected', function (done) {
336
+ it('should handle rejected emails and set status to rejected', function (done) {
358
337
  let errorHandlerCalled = false;
359
338
  let redStatusSet = false;
360
339
 
361
340
  function checkDone() {
362
- console.log('Check done - Error:', errorHandlerCalled, 'Status:', redStatusSet);
363
341
  if (errorHandlerCalled && redStatusSet) {
364
342
  done();
365
343
  }
@@ -368,9 +346,8 @@ describe('E-Mail Sender Node Unit Tests', function () {
368
346
  // ARRANGE: Configure mock to simulate rejected emails
369
347
  const mockOptions = {
370
348
  rejectedEmails: ['recipient@example.com'],
371
- acceptedEmails: [] // Ensure no emails are accepted
349
+ acceptedEmails: [], // Ensure no emails are accepted
372
350
  };
373
- console.log('Creating mock with rejected email options:', mockOptions);
374
351
 
375
352
  const mockNodemailer = createMockNodemailer(mockOptions);
376
353
 
@@ -387,14 +364,12 @@ describe('E-Mail Sender Node Unit Tests', function () {
387
364
  }
388
365
  },
389
366
  statusHandler: function (status) {
390
- console.log('Status received:', status);
391
367
  if (status.fill === 'red' && status.text === 'rejected') {
392
368
  redStatusSet = true;
393
369
  checkDone();
394
370
  }
395
371
  },
396
372
  errorHandler: function (err) {
397
- console.log('Error received:', err);
398
373
  expect(err.message).to.include('Email rejected: recipient@example.com');
399
374
  errorHandlerCalled = true;
400
375
  checkDone();
@@ -418,7 +393,6 @@ describe('E-Mail Sender Node Unit Tests', function () {
418
393
  let yellowStatusSet = false;
419
394
 
420
395
  function checkDone() {
421
- console.log('Check done - Error:', errorHandlerCalled, 'Status:', yellowStatusSet);
422
396
  if (errorHandlerCalled && yellowStatusSet) {
423
397
  done();
424
398
  }
@@ -427,9 +401,8 @@ describe('E-Mail Sender Node Unit Tests', function () {
427
401
  // ARRANGE: Configure mock to simulate pending emails
428
402
  const mockOptions = {
429
403
  pendingEmails: ['recipient@example.com'],
430
- acceptedEmails: [] // Ensure no emails are accepted
404
+ acceptedEmails: [], // Ensure no emails are accepted
431
405
  };
432
- console.log('Creating mock with pending email options:', mockOptions);
433
406
 
434
407
  const mockNodemailer = createMockNodemailer(mockOptions);
435
408
 
@@ -446,14 +419,12 @@ describe('E-Mail Sender Node Unit Tests', function () {
446
419
  }
447
420
  },
448
421
  statusHandler: function (status) {
449
- console.log('Status received:', status);
450
422
  if (status.fill === 'yellow' && status.text === 'pending') {
451
423
  yellowStatusSet = true;
452
424
  checkDone();
453
425
  }
454
426
  },
455
427
  errorHandler: function (err) {
456
- console.log('Error received:', err);
457
428
  expect(err.message).to.include('Email pending: recipient@example.com');
458
429
  errorHandlerCalled = true;
459
430
  checkDone();
@@ -477,9 +448,7 @@ describe('E-Mail Sender Node Unit Tests', function () {
477
448
  let statusSet = false;
478
449
 
479
450
  function checkDone() {
480
- console.log('checkDone called - attachmentChecked:', attachmentChecked, 'statusSet:', statusSet);
481
451
  if (attachmentChecked && statusSet) {
482
- console.log('Both conditions met, calling done');
483
452
  done();
484
453
  }
485
454
  }
@@ -489,54 +458,44 @@ describe('E-Mail Sender Node Unit Tests', function () {
489
458
  filename: 'single-test.txt',
490
459
  content: 'This is a single test file.',
491
460
  };
492
- console.log('Single attachment configured:', singleAttachment);
493
461
 
494
462
  const mockNodemailer = createMockNodemailer({
495
463
  onSendMail: (mailOptions) => {
496
- console.log('onSendMail called with attachments:', mailOptions.attachments);
497
464
  expect(mailOptions.attachments).to.be.an('array').with.lengthOf(1);
498
465
  expect(mailOptions.attachments[0].filename).to.equal('single-test.txt');
499
466
  expect(mailOptions.attachments[0].content).to.equal('This is a single test file.');
500
467
  attachmentChecked = true;
501
- console.log('Single attachment checked successfully');
502
468
  checkDone();
503
469
  },
504
470
  });
505
- console.log('Mock nodemailer created for single attachment');
506
471
 
507
472
  // Mock the nodemailer module
508
473
  delete require.cache[require.resolve('nodemailer')];
509
474
  require.cache[require.resolve('nodemailer')] = {
510
475
  exports: mockNodemailer,
511
476
  };
512
- console.log('Nodemailer mock installed');
513
477
 
514
478
  const mockRED = createMockNodeRED({
515
479
  onHandler: function (event, callback) {
516
- console.log('onHandler called with event:', event);
517
480
  if (event === 'input') {
518
481
  this.inputCallback = callback;
519
482
  }
520
483
  },
521
484
  statusHandler: function (status) {
522
- console.log('statusHandler called with status:', status);
523
485
  if (status.fill === 'green') {
524
486
  expect(status.text).to.include('sent');
525
487
  expect(status.shape).to.equal('dot');
526
488
  statusSet = true;
527
- console.log('Status set successfully for single attachment');
528
489
  checkDone();
529
490
  }
530
491
  },
531
492
  errorHandler: function (err) {
532
- console.log('errorHandler called with:', err);
533
493
  done(err || new Error('Unexpected error handler called'));
534
494
  },
535
495
  });
536
496
 
537
497
  const emailSenderNode = require('../../email-sender/email-sender.js');
538
498
  emailSenderNode(mockRED);
539
- console.log('Email sender node initialized for single attachment');
540
499
 
541
500
  const config = { ...emailSenderConfigs.valid };
542
501
  config.attachments = JSON.stringify(singleAttachment);
@@ -544,7 +503,6 @@ describe('E-Mail Sender Node Unit Tests', function () {
544
503
 
545
504
  const nodeConstructor = mockRED.nodes.lastRegisteredConstructor;
546
505
  const nodeInstance = new nodeConstructor(config);
547
- console.log('Node instance created with single attachment');
548
506
 
549
507
  setTimeout(() => {
550
508
  nodeInstance.inputCallback({
@@ -560,47 +518,38 @@ describe('E-Mail Sender Node Unit Tests', function () {
560
518
  // ARRANGE: Create mock nodemailer to verify no attachments are processed
561
519
  const mockNodemailer = createMockNodemailer({
562
520
  onSendMail: (mailOptions) => {
563
- console.log('onSendMail called with attachments:', mailOptions.attachments);
564
521
  // Should be an empty array when no attachments are provided
565
522
  expect(mailOptions.attachments).to.be.an('array').with.lengthOf(0);
566
- console.log('Empty attachments verified successfully');
567
523
  },
568
524
  });
569
- console.log('Mock nodemailer created for empty attachments test');
570
525
 
571
526
  // Mock the nodemailer module
572
527
  delete require.cache[require.resolve('nodemailer')];
573
528
  require.cache[require.resolve('nodemailer')] = {
574
529
  exports: mockNodemailer,
575
530
  };
576
- console.log('Nodemailer mock installed');
577
531
 
578
532
  const mockRED = createMockNodeRED({
579
533
  onHandler: function (event, callback) {
580
- console.log('onHandler called with event:', event);
581
534
  if (event === 'input') {
582
535
  this.inputCallback = callback;
583
536
  }
584
537
  },
585
538
  statusHandler: function (status) {
586
- console.log('statusHandler called with status:', status);
587
539
  if (status.fill === 'green') {
588
540
  expect(status.text).to.include('sent');
589
541
  expect(status.shape).to.equal('dot');
590
542
  statusSet = true;
591
- console.log('Status set successfully for empty attachments');
592
543
  done();
593
544
  }
594
545
  },
595
546
  errorHandler: function (err) {
596
- console.log('errorHandler called with:', err);
597
547
  done(err || new Error('Unexpected error handler called'));
598
548
  },
599
549
  });
600
550
 
601
551
  const emailSenderNode = require('../../email-sender/email-sender.js');
602
552
  emailSenderNode(mockRED);
603
- console.log('Email sender node initialized for empty attachments');
604
553
 
605
554
  const config = { ...emailSenderConfigs.valid };
606
555
  // Set attachments to empty string to test this scenario
@@ -609,7 +558,6 @@ describe('E-Mail Sender Node Unit Tests', function () {
609
558
 
610
559
  const nodeConstructor = mockRED.nodes.lastRegisteredConstructor;
611
560
  const nodeInstance = new nodeConstructor(config);
612
- console.log('Node instance created with empty attachments');
613
561
 
614
562
  setTimeout(() => {
615
563
  nodeInstance.inputCallback({
@@ -618,4 +566,5 @@ describe('E-Mail Sender Node Unit Tests', function () {
618
566
  });
619
567
  }, 100);
620
568
  });
569
+ });
621
570
  });