mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(Gmail Trigger Node): Don't return date instances, but date strings instead (#10582)
This commit is contained in:
@@ -202,6 +202,11 @@ export async function parseRawEmail(
|
||||
headers,
|
||||
headerLines: undefined,
|
||||
attachments: undefined,
|
||||
// Having data in IDataObjects that is not representable in JSON leads to
|
||||
// inconsistencies between test executions and production executions.
|
||||
// During a manual execution this would be stringified and during a
|
||||
// production execution the next node would receive a date instance.
|
||||
date: responseData.date ? responseData.date.toISOString() : responseData.date,
|
||||
}) as IDataObject;
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { INode } from 'n8n-workflow';
|
||||
import type { IExecuteFunctions, INode } from 'n8n-workflow';
|
||||
import { DateTime } from 'luxon';
|
||||
import { prepareTimestamp } from '../../GenericFunctions';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { parseRawEmail, prepareTimestamp } from '../../GenericFunctions';
|
||||
|
||||
const node: INode = {
|
||||
id: '1',
|
||||
@@ -108,3 +109,21 @@ describe('Google Gmail v2, prepareTimestamp', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseRawEmail', () => {
|
||||
it('should return a date string', async () => {
|
||||
// ARRANGE
|
||||
const executionFunctions = mock<IExecuteFunctions>();
|
||||
const rawEmail = 'Date: Wed, 28 Aug 2024 00:36:37 -0700'.replace(/\n/g, '\r\n');
|
||||
|
||||
// ACT
|
||||
const { json } = await parseRawEmail.call(
|
||||
executionFunctions,
|
||||
{ raw: Buffer.from(rawEmail, 'utf8').toString('base64') },
|
||||
'attachment_',
|
||||
);
|
||||
|
||||
// ASSERT
|
||||
expect(typeof json.date).toBe('string');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user