mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-09-05 01:56:33 +02:00
fix(core): Fix task runner logging to browser console (#15111)
This commit is contained in:
+33
@@ -226,4 +226,37 @@ describe('ExecuteContext', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('logNodeOutput', () => {
|
||||
it('when in manual mode, should parse JSON', () => {
|
||||
const json = '{"key": "value", "nested": {"foo": "bar"}}';
|
||||
const expectedParsedObject = { key: 'value', nested: { foo: 'bar' } };
|
||||
const numberArg = 42;
|
||||
const stringArg = 'hello world!';
|
||||
|
||||
const manualModeContext = new ExecuteContext(
|
||||
workflow,
|
||||
node,
|
||||
additionalData,
|
||||
'manual',
|
||||
runExecutionData,
|
||||
runIndex,
|
||||
connectionInputData,
|
||||
inputData,
|
||||
executeData,
|
||||
[closeFn],
|
||||
abortSignal,
|
||||
);
|
||||
|
||||
const sendMessageSpy = jest.spyOn(manualModeContext, 'sendMessageToUI');
|
||||
|
||||
manualModeContext.logNodeOutput(json, numberArg, stringArg);
|
||||
|
||||
expect(sendMessageSpy.mock.calls[0][0]).toEqual(expectedParsedObject);
|
||||
expect(sendMessageSpy.mock.calls[0][1]).toBe(numberArg);
|
||||
expect(sendMessageSpy.mock.calls[0][2]).toBe(stringArg);
|
||||
|
||||
sendMessageSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
ApplicationError,
|
||||
createDeferredPromise,
|
||||
createEnvProviderState,
|
||||
jsonParse,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -183,7 +184,10 @@ export class ExecuteContext extends BaseExecuteContext implements IExecuteFuncti
|
||||
|
||||
logNodeOutput(...args: unknown[]): void {
|
||||
if (this.mode === 'manual') {
|
||||
this.sendMessageToUI(...args);
|
||||
const parsedLogArgs = args.map((arg) =>
|
||||
typeof arg === 'string' ? jsonParse(arg, { fallbackValue: arg }) : arg,
|
||||
);
|
||||
this.sendMessageToUI(...parsedLogArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user