mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(Wait Node): Validate datetime for specific time mode (#14701)
Co-authored-by: Danny Martini <danny@n8n.io> Co-authored-by: Elias Meire <elias@meire.dev>
This commit is contained in:
committed by
GitHub
parent
3feab31792
commit
3641c1fb87
@@ -1,6 +1,6 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { DateTime, Settings } from 'luxon';
|
||||
|
||||
import { getValueDescription, validateFieldType } from '@/TypeValidation';
|
||||
import { getValueDescription, tryToParseDateTime, validateFieldType } from '@/TypeValidation';
|
||||
|
||||
describe('Type Validation', () => {
|
||||
describe('Dates', () => {
|
||||
@@ -292,4 +292,39 @@ describe('Type Validation', () => {
|
||||
expect(getValueDescription({})).toBe('object');
|
||||
});
|
||||
});
|
||||
|
||||
describe('tryToParseDateTime', () => {
|
||||
it('should NOT use defaultZone if set', () => {
|
||||
const result = tryToParseDateTime('2025-04-17T06:22:20-04:00', 'Europe/Brussels');
|
||||
|
||||
expect(result.zoneName).toEqual('UTC-4');
|
||||
expect(result.toISO()).toEqual('2025-04-17T06:22:20.000-04:00');
|
||||
});
|
||||
|
||||
it('should use defaultZone if timezone is not set', () => {
|
||||
const result = tryToParseDateTime('2025-04-17T06:22:20', 'Europe/Brussels');
|
||||
|
||||
expect(result.zoneName).toEqual('Europe/Brussels');
|
||||
expect(result.toISO()).toEqual('2025-04-17T06:22:20.000+02:00');
|
||||
});
|
||||
|
||||
it('should use the system timezone when defaultZone arg is not given', () => {
|
||||
Settings.defaultZone = 'UTC-7';
|
||||
const result = tryToParseDateTime('2025-04-17T06:22:20');
|
||||
|
||||
expect(result.zoneName).toEqual('UTC-7');
|
||||
expect(result.toISO()).toEqual('2025-04-17T06:22:20.000-07:00');
|
||||
});
|
||||
|
||||
it('should not impact DateTime zone', () => {
|
||||
const dateTime = DateTime.fromObject(
|
||||
{ year: 2025, month: 1, day: 1 },
|
||||
{ zone: 'Asia/Tokyo' },
|
||||
);
|
||||
const result = tryToParseDateTime(dateTime, 'Europe/Brussels');
|
||||
|
||||
expect(result.zoneName).toEqual('Asia/Tokyo');
|
||||
expect(result.toISO()).toEqual('2025-01-01T00:00:00.000+09:00');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user