mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
fix(editor): Disable Ask AI button in deprecated nodes (no-changelog) (#11194)
This commit is contained in:
parent
6e990175c7
commit
98759701e4
|
@ -840,6 +840,7 @@ exports[`AskAssistantChat > renders default placeholder chat correctly 1`] = `
|
|||
For specific tasks, you’ll see the
|
||||
<button
|
||||
class="button"
|
||||
data-test-id="ask-assistant-button"
|
||||
style="height: 18px;"
|
||||
tabindex="-1"
|
||||
>
|
||||
|
@ -1082,6 +1083,7 @@ exports[`AskAssistantChat > renders end of session chat correctly 1`] = `
|
|||
</span>
|
||||
<button
|
||||
class="button"
|
||||
data-test-id="ask-assistant-button"
|
||||
style="height: 18px;"
|
||||
tabindex="-1"
|
||||
>
|
||||
|
|
|
@ -50,6 +50,7 @@ const onClick = () => {
|
|||
:style="{ height: sizes[size].height }"
|
||||
:disabled="asked"
|
||||
:tabindex="static ? '-1' : ''"
|
||||
data-test-id="ask-assistant-button"
|
||||
@click="onClick"
|
||||
>
|
||||
<div>
|
||||
|
|
|
@ -121,7 +121,8 @@ const isAskAssistantAvailable = computed(() => {
|
|||
return false;
|
||||
}
|
||||
const isCustomNode = node.value.type === undefined || isCommunityPackageName(node.value.type);
|
||||
return assistantStore.canShowAssistantButtonsOnCanvas && !isCustomNode;
|
||||
|
||||
return assistantStore.canShowAssistantButtonsOnCanvas && !isCustomNode && !nodeIsHidden();
|
||||
});
|
||||
|
||||
const assistantAlreadyAsked = computed(() => {
|
||||
|
@ -384,6 +385,11 @@ function copySuccess() {
|
|||
});
|
||||
}
|
||||
|
||||
function nodeIsHidden() {
|
||||
const nodeType = nodeTypesStore.getNodeType(node?.value.type);
|
||||
return nodeType?.hidden ?? false;
|
||||
}
|
||||
|
||||
async function onAskAssistantClick() {
|
||||
const { message, lineNumber, description } = props.error;
|
||||
const sessionInProgress = !assistantStore.isSessionEnded;
|
||||
|
|
|
@ -4,6 +4,8 @@ import NodeErrorView from '@/components/Error/NodeErrorView.vue';
|
|||
import { STORES } from '@/constants';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { type INode } from 'n8n-workflow';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
|
||||
const DEFAULT_SETUP = {
|
||||
pinia: createTestingPinia({
|
||||
|
@ -63,4 +65,35 @@ describe('NodeErrorView.vue', () => {
|
|||
|
||||
expect(errorMessage).toHaveTextContent('Unexpected identifier [line 1]');
|
||||
});
|
||||
|
||||
it('should not render AI assistant button when error happens in deprecated function node', async () => {
|
||||
const aiAssistantStore = useAssistantStore(DEFAULT_SETUP.pinia);
|
||||
const nodeTypeStore = useNodeTypesStore(DEFAULT_SETUP.pinia);
|
||||
|
||||
//@ts-expect-error
|
||||
nodeTypeStore.getNodeType = vi.fn(() => ({
|
||||
type: 'n8n-nodes-base.function',
|
||||
typeVersion: 1,
|
||||
hidden: true,
|
||||
}));
|
||||
|
||||
//@ts-expect-error
|
||||
aiAssistantStore.canShowAssistantButtonsOnCanvas = true;
|
||||
|
||||
const { queryByTestId } = renderComponent({
|
||||
props: {
|
||||
error: {
|
||||
node: {
|
||||
...mockNode,
|
||||
type: 'n8n-nodes-base.function',
|
||||
typeVersion: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const aiAssistantButton = queryByTestId('ask-assistant-button');
|
||||
|
||||
expect(aiAssistantButton).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue