mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-19 07:36:52 +00:00
fix(editor): Hide template setup button when only disabled nodes lack credentials
This commit is contained in:
+41
@@ -300,6 +300,47 @@ describe('SetupWorkflowCredentialsButton', () => {
|
||||
const { getByTestId } = renderComponent();
|
||||
expect(getByTestId('setup-credentials-button')).toBeVisible();
|
||||
});
|
||||
|
||||
it('ignores disabled nodes when deciding whether all credentials are filled', () => {
|
||||
const nodes = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'OpenAI Model',
|
||||
type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
|
||||
typeVersion: 1,
|
||||
position: [0, 0] as [number, number],
|
||||
parameters: {},
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
name: 'Disabled Slack',
|
||||
type: 'n8n-nodes-base.slack',
|
||||
typeVersion: 1,
|
||||
position: [200, 0] as [number, number],
|
||||
parameters: {},
|
||||
disabled: true,
|
||||
},
|
||||
];
|
||||
workflowsStore.workflowId = workflowWithNodes.id;
|
||||
setWorkflowDocumentStoreState(
|
||||
{ templateId: '2722', templateCredsSetupCompleted: false },
|
||||
nodes,
|
||||
);
|
||||
setupPanelStore.isFeatureEnabled = true;
|
||||
// The enabled node has its credentials filled; the disabled node does not.
|
||||
mockDoesNodeHaveAllCredentialsFilled.mockImplementation(
|
||||
(_provider: unknown, node: { id: string }) => node.id === '1',
|
||||
);
|
||||
|
||||
const { queryByTestId } = renderComponent();
|
||||
|
||||
expect(queryByTestId('setup-credentials-button')).toBeNull();
|
||||
// The disabled node must never be checked for credentials.
|
||||
expect(mockDoesNodeHaveAllCredentialsFilled).not.toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
expect.objectContaining({ id: '2' }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('modal auto-open on mount', () => {
|
||||
|
||||
+3
-1
@@ -38,7 +38,9 @@ const allCredentialsFilled = computed(() => {
|
||||
return true;
|
||||
}
|
||||
|
||||
const nodes = workflowDocumentStore?.value?.allNodes ?? [];
|
||||
// Disabled nodes are skipped during execution, so their unfilled
|
||||
// credentials must not keep the setup button visible.
|
||||
const nodes = (workflowDocumentStore?.value?.allNodes ?? []).filter((node) => !node.disabled);
|
||||
if (!nodes.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user