mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Use the configured timezone in task runner (#12032)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import type { CodeExecutionMode, IDataObject } from 'n8n-workflow';
|
||||
import { setGlobalState, type CodeExecutionMode, type IDataObject } from 'n8n-workflow';
|
||||
import fs from 'node:fs';
|
||||
import { builtinModules } from 'node:module';
|
||||
|
||||
@@ -326,6 +326,43 @@ describe('JsTaskRunner', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('timezone', () => {
|
||||
it('should use the specified timezone in the workflow', async () => {
|
||||
const taskData = newDataRequestResponse(inputItems.map(wrapIntoJson), {});
|
||||
taskData.workflow.settings = {
|
||||
timezone: 'Europe/Helsinki',
|
||||
};
|
||||
|
||||
const outcome = await execTaskWithParams({
|
||||
task: newTaskWithSettings({
|
||||
code: 'return { val: $now.toSeconds() }',
|
||||
nodeMode: 'runOnceForAllItems',
|
||||
}),
|
||||
taskData,
|
||||
});
|
||||
|
||||
const helsinkiTimeNow = DateTime.now().setZone('Europe/Helsinki').toSeconds();
|
||||
expect(outcome.result[0].json.val).toBeCloseTo(helsinkiTimeNow, 1);
|
||||
});
|
||||
|
||||
it('should use the default timezone', async () => {
|
||||
setGlobalState({
|
||||
defaultTimezone: 'Europe/Helsinki',
|
||||
});
|
||||
|
||||
const outcome = await execTaskWithParams({
|
||||
task: newTaskWithSettings({
|
||||
code: 'return { val: $now.toSeconds() }',
|
||||
nodeMode: 'runOnceForAllItems',
|
||||
}),
|
||||
taskData: newDataRequestResponse(inputItems.map(wrapIntoJson), {}),
|
||||
});
|
||||
|
||||
const helsinkiTimeNow = DateTime.now().setZone('Europe/Helsinki').toSeconds();
|
||||
expect(outcome.result[0].json.val).toBeCloseTo(helsinkiTimeNow, 1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow access to Node.js Buffers', async () => {
|
||||
const outcomeAll = await execTaskWithParams({
|
||||
task: newTaskWithSettings({
|
||||
|
||||
Reference in New Issue
Block a user