Add tests

This commit is contained in:
Charlie Kolb 2024-11-11 09:15:15 +01:00
parent ca9a61a00b
commit 8e77acf867
No known key found for this signature in database
3 changed files with 104 additions and 1 deletions

View file

@ -52,6 +52,10 @@ export function getOutputPanelTable() {
return getOutputPanelDataContainer().get('table');
}
export function getNoToolsUsedCallout() {
return cy.getByTestId('no-tools-used-callout');
}
/**
* Actions
*/

View file

@ -27,6 +27,8 @@ import {
clickCreateNewCredential,
clickExecuteNode,
clickGetBackToCanvas,
getNoToolsUsedCallout,
getOutputPanelTable,
toggleParameterCheckboxInputByName,
} from '../composables/ndv';
import {
@ -411,4 +413,101 @@ describe('Langchain Integration', () => {
assertInputOutputText('Berlin', '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');
});
});

View file

@ -388,7 +388,7 @@ const shouldShowWarning = computed(() => {
</template>
<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">
{{
i18n.baseText('ndv.output.noToolUsedInfo.title') +