Fix tests

This commit is contained in:
Charlie Kolb 2024-11-12 10:51:12 +01:00
parent 21f126cc46
commit 98ec7370b3
No known key found for this signature in database
2 changed files with 7 additions and 7 deletions

View file

@ -8,7 +8,6 @@ describe('adjustNewlyConnectedNodes', () => {
adjustNewlyConnectedNodes(parent, child); adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({ expect(child).toEqual({
type: AGENT_NODE_TYPE, type: AGENT_NODE_TYPE,
parameters: { promptType: 'define' },
}); });
}); });
it('does not modify promptType with ManualTrigger->Agent', () => { it('does not modify promptType with ManualTrigger->Agent', () => {
@ -17,24 +16,25 @@ describe('adjustNewlyConnectedNodes', () => {
adjustNewlyConnectedNodes(parent, child); adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({ expect(child).toEqual({
type: AGENT_NODE_TYPE, type: AGENT_NODE_TYPE,
parameters: { promptType: 'define' },
}); });
}); });
it('modifies sessionId with ChatTrigger->Memory', () => { it('modifies sessionId with ChatTrigger->Memory', () => {
const parent = { type: CHAT_TRIGGER_NODE_TYPE }; const parent = { type: CHAT_TRIGGER_NODE_TYPE };
const child = { type: 'memoryBufferWindow' }; const child = { type: '@n8n/n8n-nodes-langchain.memoryBufferWindow' };
adjustNewlyConnectedNodes(parent, child); adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({ expect(child).toEqual({
type: 'memoryBufferWindow', type: '@n8n/n8n-nodes-langchain.memoryBufferWindow',
}); });
}); });
it('does not modify sessionId with ManualTrigger->Memory', () => { it('does not modify sessionId with ManualTrigger->Memory', () => {
const parent = { type: MANUAL_TRIGGER_NODE_TYPE }; const parent = { type: MANUAL_TRIGGER_NODE_TYPE };
const child = { type: 'memoryBufferWindow' }; const child = { type: '@n8n/n8n-nodes-langchain.memoryBufferWindow' };
adjustNewlyConnectedNodes(parent, child); adjustNewlyConnectedNodes(parent, child);
expect(child).toEqual({ expect(child).toEqual({
type: 'memoryBufferWindow', type: '@n8n/n8n-nodes-langchain.memoryBufferWindow',
parameters: { sessionIdType: 'customKey' }, parameters: { sessionIdType: 'customKey' },
}); });
}); });

View file

@ -30,12 +30,12 @@ const PROMPT_PROVIDER_NODE_NAMES = [CHAT_TRIGGER_NODE_TYPE];
type NodeWithType = Pick<INode, 'type'>; type NodeWithType = Pick<INode, 'type'>;
export function adjustNewlyConnectedNodes(parent: NodeWithType, child: NodeWithType) { export function adjustNewlyConnectedNodes(parent: NodeWithType, child: NodeWithType) {
if (!PROMPT_PROVIDER_NODE_NAMES.includes(child.type) && AI_NODES.includes(parent.type)) { if (!PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && AI_NODES.includes(child.type)) {
Object.assign<NodeWithType, Partial<INode>>(child, { Object.assign<NodeWithType, Partial<INode>>(child, {
parameters: { promptType: 'define' }, parameters: { promptType: 'define' },
}); });
} }
if (PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && MEMORY_NODE_NAMES.includes(child.type)) { if (!PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && MEMORY_NODE_NAMES.includes(child.type)) {
Object.assign<NodeWithType, Partial<INode>>(child, { Object.assign<NodeWithType, Partial<INode>>(child, {
parameters: { sessionIdType: 'customKey' }, parameters: { sessionIdType: 'customKey' },
}); });