mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(editor): Expose View Execution links for erroneous sub-executions (#13185)
This commit is contained in:
30
packages/workflow/test/MetadataUtils.test.ts
Normal file
30
packages/workflow/test/MetadataUtils.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { parseErrorMetadata } from '@/MetadataUtils';
|
||||
|
||||
describe('MetadataUtils', () => {
|
||||
describe('parseMetadataFromError', () => {
|
||||
it('should return undefined if error does not have response', () => {
|
||||
const error = { message: 'An error occurred' };
|
||||
const result = parseErrorMetadata(error);
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
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 expectedMetadata = {
|
||||
subExecution: {
|
||||
executionId: '123',
|
||||
workflowId: '456',
|
||||
},
|
||||
subExecutionsCount: 1,
|
||||
};
|
||||
const result = parseErrorMetadata(error);
|
||||
expect(result).toEqual(expectedMetadata);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
fileTypeFromMimeType,
|
||||
randomInt,
|
||||
randomString,
|
||||
hasKey,
|
||||
} from '@/utils';
|
||||
|
||||
describe('isObjectEmpty', () => {
|
||||
@@ -290,3 +291,78 @@ describe('randomString', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
type Expect<T extends true> = T;
|
||||
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
||||
? true
|
||||
: false;
|
||||
|
||||
describe('hasKey', () => {
|
||||
it('should return false if the input is null', () => {
|
||||
const x = null;
|
||||
const result = hasKey(x, 'key');
|
||||
|
||||
expect(result).toEqual(false);
|
||||
});
|
||||
it('should return false if the input is undefined', () => {
|
||||
const x = undefined;
|
||||
const result = hasKey(x, 'key');
|
||||
|
||||
expect(result).toEqual(false);
|
||||
});
|
||||
it('should return false if the input is a number', () => {
|
||||
const x = 1;
|
||||
const result = hasKey(x, 'key');
|
||||
|
||||
expect(result).toEqual(false);
|
||||
});
|
||||
it('should return false if the input is an array out of bounds', () => {
|
||||
const x = [1, 2];
|
||||
const result = hasKey(x, 5);
|
||||
|
||||
expect(result).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return true if the input is an array within bounds', () => {
|
||||
const x = [1, 2];
|
||||
const result = hasKey(x, 1);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
it('should return true if the input is an array with the key `length`', () => {
|
||||
const x = [1, 2];
|
||||
const result = hasKey(x, 'length');
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
it('should return false if the input is an array with the key `toString`', () => {
|
||||
const x = [1, 2];
|
||||
const result = hasKey(x, 'toString');
|
||||
|
||||
expect(result).toEqual(false);
|
||||
});
|
||||
it('should return false if the input is an object without the key', () => {
|
||||
const x = { a: 3 };
|
||||
const result = hasKey(x, 'a');
|
||||
|
||||
expect(result).toEqual(true);
|
||||
});
|
||||
|
||||
it('should return true if the input is an object with the key', () => {
|
||||
const x = { a: 3 };
|
||||
const result = hasKey(x, 'b');
|
||||
|
||||
expect(result).toEqual(false);
|
||||
});
|
||||
|
||||
it('should provide a type guard', () => {
|
||||
const x: unknown = { a: 3 };
|
||||
if (hasKey(x, '0')) {
|
||||
const y: Expect<Equal<typeof x, Record<'0', unknown>>> = true;
|
||||
y;
|
||||
} else {
|
||||
const z: Expect<Equal<typeof x, unknown>> = true;
|
||||
z;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user