mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
fix: Run workflow if active and single webhook service has pin data (#12425)
This commit is contained in:
parent
452a7bfe2c
commit
8053a4a176
|
@ -219,6 +219,55 @@ describe('useRunWorkflow({ router })', () => {
|
||||||
type: 'error',
|
type: 'error',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('should execute workflow has pin data and is active with single webhook trigger', async () => {
|
||||||
|
const pinia = createTestingPinia({ stubActions: false });
|
||||||
|
setActivePinia(pinia);
|
||||||
|
const toast = useToast();
|
||||||
|
const i18n = useI18n();
|
||||||
|
const { runWorkflow } = useRunWorkflow({ router });
|
||||||
|
|
||||||
|
vi.mocked(workflowsStore).isWorkflowActive = true;
|
||||||
|
|
||||||
|
vi.mocked(useWorkflowHelpers({ router })).getWorkflowDataToSave.mockResolvedValue({
|
||||||
|
nodes: [
|
||||||
|
{
|
||||||
|
name: 'Slack',
|
||||||
|
type: 'n8n-nodes-base.slackTrigger',
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
pinData: {
|
||||||
|
Slack: [{ json: { value: 'data2' } }],
|
||||||
|
},
|
||||||
|
} as unknown as IWorkflowData);
|
||||||
|
|
||||||
|
const mockExecutionResponse = { executionId: '123' };
|
||||||
|
|
||||||
|
vi.mocked(uiStore).activeActions = [''];
|
||||||
|
vi.mocked(workflowHelpers).getCurrentWorkflow.mockReturnValue({
|
||||||
|
name: 'Test Workflow',
|
||||||
|
} as unknown as Workflow);
|
||||||
|
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockExecutionResponse);
|
||||||
|
vi.mocked(workflowsStore).nodesIssuesExist = true;
|
||||||
|
vi.mocked(workflowHelpers).getWorkflowDataToSave.mockResolvedValue({
|
||||||
|
id: 'workflowId',
|
||||||
|
nodes: [],
|
||||||
|
} as unknown as IWorkflowData);
|
||||||
|
vi.mocked(workflowsStore).getWorkflowRunData = {
|
||||||
|
NodeName: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await runWorkflow({});
|
||||||
|
expect(result).toEqual(mockExecutionResponse);
|
||||||
|
|
||||||
|
expect(toast.showMessage).not.toHaveBeenCalledWith({
|
||||||
|
title: i18n.baseText('workflowRun.showError.deactivate'),
|
||||||
|
message: i18n.baseText('workflowRun.showError.productionActive', {
|
||||||
|
interpolate: { nodeName: 'Webhook' },
|
||||||
|
}),
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('runWorkflow()', () => {
|
describe('runWorkflow()', () => {
|
||||||
|
|
|
@ -240,7 +240,11 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||||
SINGLE_WEBHOOK_TRIGGERS.includes(node.type),
|
SINGLE_WEBHOOK_TRIGGERS.includes(node.type),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (singleWebhookTrigger && workflowsStore.isWorkflowActive) {
|
if (
|
||||||
|
singleWebhookTrigger &&
|
||||||
|
workflowsStore.isWorkflowActive &&
|
||||||
|
!workflowData.pinData?.[singleWebhookTrigger.name]
|
||||||
|
) {
|
||||||
toast.showMessage({
|
toast.showMessage({
|
||||||
title: i18n.baseText('workflowRun.showError.deactivate'),
|
title: i18n.baseText('workflowRun.showError.deactivate'),
|
||||||
message: i18n.baseText('workflowRun.showError.productionActive', {
|
message: i18n.baseText('workflowRun.showError.productionActive', {
|
||||||
|
|
Loading…
Reference in a new issue