mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
Add tests
This commit is contained in:
parent
ca9a61a00b
commit
8e77acf867
|
@ -52,6 +52,10 @@ export function getOutputPanelTable() {
|
||||||
return getOutputPanelDataContainer().get('table');
|
return getOutputPanelDataContainer().get('table');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getNoToolsUsedCallout() {
|
||||||
|
return cy.getByTestId('no-tools-used-callout');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,6 +27,8 @@ import {
|
||||||
clickCreateNewCredential,
|
clickCreateNewCredential,
|
||||||
clickExecuteNode,
|
clickExecuteNode,
|
||||||
clickGetBackToCanvas,
|
clickGetBackToCanvas,
|
||||||
|
getNoToolsUsedCallout,
|
||||||
|
getOutputPanelTable,
|
||||||
toggleParameterCheckboxInputByName,
|
toggleParameterCheckboxInputByName,
|
||||||
} from '../composables/ndv';
|
} from '../composables/ndv';
|
||||||
import {
|
import {
|
||||||
|
@ -411,4 +413,101 @@ describe('Langchain Integration', () => {
|
||||||
assertInputOutputText('Berlin', 'not.exist');
|
assertInputOutputText('Berlin', 'not.exist');
|
||||||
assertInputOutputText('Kyiv', 'not.exist');
|
assertInputOutputText('Kyiv', 'not.exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.only('should show tool info notice if no existing tools were used during execution', () => {
|
||||||
|
addNodeToCanvas(MANUAL_CHAT_TRIGGER_NODE_NAME, true);
|
||||||
|
addNodeToCanvas(AGENT_NODE_NAME, true);
|
||||||
|
|
||||||
|
addLanguageModelNodeToParent(
|
||||||
|
AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME,
|
||||||
|
AGENT_NODE_NAME,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
clickCreateNewCredential();
|
||||||
|
setCredentialValues({
|
||||||
|
apiKey: 'sk_test_123',
|
||||||
|
});
|
||||||
|
clickGetBackToCanvas();
|
||||||
|
|
||||||
|
addToolNodeToParent(AI_TOOL_CALCULATOR_NODE_NAME, AGENT_NODE_NAME);
|
||||||
|
clickGetBackToCanvas();
|
||||||
|
openNode(AGENT_NODE_NAME);
|
||||||
|
|
||||||
|
const inputMessage = 'Hello!';
|
||||||
|
const outputMessage = 'Hi there! How can I assist you today?';
|
||||||
|
|
||||||
|
clickExecuteNode();
|
||||||
|
|
||||||
|
runMockWorkflowExecution({
|
||||||
|
trigger: () => sendManualChatMessage(inputMessage),
|
||||||
|
runData: [
|
||||||
|
createMockNodeExecutionData(AGENT_NODE_NAME, {
|
||||||
|
jsonData: {
|
||||||
|
main: { output: outputMessage },
|
||||||
|
},
|
||||||
|
metadata: {
|
||||||
|
subRun: [{ node: AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, runIndex: 0 }],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
lastNodeExecuted: AGENT_NODE_NAME,
|
||||||
|
});
|
||||||
|
closeManualChatModal();
|
||||||
|
openNode(AGENT_NODE_NAME);
|
||||||
|
|
||||||
|
getNoToolsUsedCallout().should('exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show tool info notice if tools were used during execution', () => {
|
||||||
|
addNodeToCanvas(MANUAL_CHAT_TRIGGER_NODE_NAME, true);
|
||||||
|
addNodeToCanvas(AGENT_NODE_NAME, true);
|
||||||
|
|
||||||
|
addLanguageModelNodeToParent(
|
||||||
|
AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME,
|
||||||
|
AGENT_NODE_NAME,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
clickCreateNewCredential();
|
||||||
|
setCredentialValues({
|
||||||
|
apiKey: 'sk_test_123',
|
||||||
|
});
|
||||||
|
clickGetBackToCanvas();
|
||||||
|
|
||||||
|
addToolNodeToParent(AI_TOOL_CALCULATOR_NODE_NAME, AGENT_NODE_NAME);
|
||||||
|
clickGetBackToCanvas();
|
||||||
|
openNode(AGENT_NODE_NAME);
|
||||||
|
|
||||||
|
const inputMessage = 'Hello!';
|
||||||
|
const outputMessage = 'Hi there! How can I assist you today?';
|
||||||
|
|
||||||
|
clickExecuteNode();
|
||||||
|
|
||||||
|
runMockWorkflowExecution({
|
||||||
|
trigger: () => sendManualChatMessage(inputMessage),
|
||||||
|
runData: [
|
||||||
|
createMockNodeExecutionData(AGENT_NODE_NAME, {
|
||||||
|
jsonData: {
|
||||||
|
main: { output: outputMessage },
|
||||||
|
},
|
||||||
|
metadata: {
|
||||||
|
subRun: [
|
||||||
|
{ node: AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, runIndex: 0 },
|
||||||
|
{ node: AI_TOOL_CALCULATOR_NODE_NAME, runIndex: 0 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
createMockNodeExecutionData(AI_TOOL_CALCULATOR_NODE_NAME, {}),
|
||||||
|
],
|
||||||
|
lastNodeExecuted: AGENT_NODE_NAME,
|
||||||
|
});
|
||||||
|
|
||||||
|
closeManualChatModal();
|
||||||
|
openNode(AGENT_NODE_NAME);
|
||||||
|
// This waits to ensure the output panel is rendered
|
||||||
|
getOutputPanelTable();
|
||||||
|
|
||||||
|
getNoToolsUsedCallout().should('not.exist');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -388,7 +388,7 @@ const shouldShowWarning = computed(() => {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="shouldShowWarning" #table-user-info>
|
<template v-if="shouldShowWarning" #table-user-info>
|
||||||
<div :class="$style.noToolsUsedAlert">
|
<div :class="$style.noToolsUsedAlert" data-test-id="no-tools-used-callout">
|
||||||
<N8nCallout theme="secondary">
|
<N8nCallout theme="secondary">
|
||||||
{{
|
{{
|
||||||
i18n.baseText('ndv.output.noToolUsedInfo.title') +
|
i18n.baseText('ndv.output.noToolUsedInfo.title') +
|
||||||
|
|
Loading…
Reference in a new issue