refactor(editor): Move editor-ui and design-system to frontend dir (no-changelog) (#13564)

This commit is contained in:
Alex Grozav
2025-02-28 14:28:30 +02:00
committed by GitHub
parent 684353436d
commit f5743176e5
1635 changed files with 805 additions and 1079 deletions

View File

@@ -0,0 +1,64 @@
import { mock } from 'vitest-mock-extended';
import type { IWorkflowTemplateNode } from '@/Interface';
import {
keyFromCredentialTypeAndName,
replaceAllTemplateNodeCredentials,
} from '@/utils/templates/templateTransforms';
describe('templateTransforms', () => {
describe('replaceAllTemplateNodeCredentials', () => {
it('should replace credentials of nodes that have credentials', () => {
const nodeTypeProvider = {
getNodeType: vitest.fn(),
};
const node = mock<IWorkflowTemplateNode>({
id: 'twitter',
type: 'n8n-nodes-base.twitter',
credentials: {
twitterOAuth1Api: 'old1',
},
});
const toReplaceWith = {
[keyFromCredentialTypeAndName('twitterOAuth1Api', 'old1')]: {
id: 'new1',
name: 'Twitter creds',
},
};
const [replacedNode] = replaceAllTemplateNodeCredentials(
nodeTypeProvider,
[node],
toReplaceWith,
);
expect(replacedNode.credentials).toEqual({
twitterOAuth1Api: { id: 'new1', name: 'Twitter creds' },
});
});
it('should not replace credentials of nodes that do not have credentials', () => {
const nodeTypeProvider = {
getNodeType: vitest.fn(),
};
const node = mock<IWorkflowTemplateNode>({
id: 'twitter',
type: 'n8n-nodes-base.twitter',
});
const toReplaceWith = {
[keyFromCredentialTypeAndName('twitterOAuth1Api', 'old1')]: {
id: 'new1',
name: 'Twitter creds',
},
};
const [replacedNode] = replaceAllTemplateNodeCredentials(
nodeTypeProvider,
[node],
toReplaceWith,
);
expect(replacedNode.credentials).toBeUndefined();
});
});
});