Files
n8n/packages/workflow/test/metadata-utils.test.ts
alighasami 3d5eaf9445
Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

50 lines
1.6 KiB
TypeScript

import { parseErrorMetadata } from '../src/metadata-utils';
describe('MetadataUtils', () => {
describe('parseMetadataFromError', () => {
const expectedMetadata = {
subExecution: {
executionId: '123',
workflowId: '456',
},
subExecutionsCount: 1,
};
it('should return undefined if error does not have response or both keys on the object', () => {
const error = { message: 'An error occurred' };
const result = parseErrorMetadata(error);
expect(result).toBeUndefined();
});
it('should return undefined if errorResponse only has workflowId key', () => {
const error = { errorResponse: { executionId: '123' } };
const result = parseErrorMetadata(error);
expect(result).toBeUndefined();
});
it('should return undefined if error only has executionId key', () => {
const error = { executionId: '123' };
const result = parseErrorMetadata(error);
expect(result).toBeUndefined();
});
it('should support executionId and workflowId key directly on the error object', () => {
const error = { executionId: '123', workflowId: '456' };
const result = parseErrorMetadata(error);
expect(result).toEqual(expectedMetadata);
});
it('should return undefined if error response does not have subworkflow data', () => {
const error = { errorResponse: { someKey: 'someValue' } };
const result = parseErrorMetadata(error);
expect(result).toBeUndefined();
});
it('should return metadata if error response has subworkflow data', () => {
const error = { errorResponse: { executionId: '123', workflowId: '456' } };
const result = parseErrorMetadata(error);
expect(result).toEqual(expectedMetadata);
});
});
});