diff --git a/packages/editor-ui/src/components/WorkflowSettings.test.ts b/packages/editor-ui/src/components/WorkflowSettings.test.ts index fdca2d5f33..ae0e27131f 100644 --- a/packages/editor-ui/src/components/WorkflowSettings.test.ts +++ b/packages/editor-ui/src/components/WorkflowSettings.test.ts @@ -2,6 +2,7 @@ import { createPinia, setActivePinia } from 'pinia'; import WorkflowSettingsVue from '@/components/WorkflowSettings.vue'; import { setupServer } from '@/__tests__/server'; +import type { MockInstance } from 'vitest'; import { afterAll, beforeAll } from 'vitest'; import { within } from '@testing-library/vue'; import userEvent from '@testing-library/user-event'; @@ -24,6 +25,8 @@ let workflowsStore: ReturnType; let settingsStore: ReturnType; let uiStore: ReturnType; +let fetchAllWorkflowsSpy: MockInstance<(typeof workflowsStore)['fetchAllWorkflows']>; + const createComponent = createComponentRenderer(WorkflowSettingsVue); describe('WorkflowSettingsVue', () => { @@ -46,6 +49,18 @@ describe('WorkflowSettingsVue', () => { vi.spyOn(workflowsStore, 'workflowName', 'get').mockReturnValue('Test Workflow'); vi.spyOn(workflowsStore, 'workflowId', 'get').mockReturnValue('1'); + fetchAllWorkflowsSpy = vi.spyOn(workflowsStore, 'fetchAllWorkflows').mockResolvedValue([ + { + id: '1', + name: 'Test Workflow', + active: true, + nodes: [], + connections: {}, + createdAt: 1, + updatedAt: 1, + versionId: '123', + }, + ]); vi.spyOn(workflowsStore, 'getWorkflowById').mockReturnValue({ id: '1', name: 'Test Workflow', @@ -113,6 +128,20 @@ describe('WorkflowSettingsVue', () => { expect(getByTestId('workflow-caller-policy-workflow-ids')).toBeVisible(); }); + it('should fetch all workflows and render them in the error workflows dropdown', async () => { + settingsStore.settings.enterprise[EnterpriseEditionFeature.Sharing] = true; + const { getByTestId } = createComponent({ pinia }); + + await nextTick(); + const dropdownItems = await getDropdownItems(getByTestId('error-workflow')); + + // first is `- No Workflow -`, second is the workflow returned by + // `workflowsStore.fetchAllWorkflows` + expect(dropdownItems).toHaveLength(2); + expect(fetchAllWorkflowsSpy).toHaveBeenCalledTimes(1); + expect(fetchAllWorkflowsSpy).toHaveBeenCalledWith(); + }); + it('should not remove valid workflow ID characters', async () => { const validWorkflowList = '1234567890, abcde, efgh, 1234'; diff --git a/packages/editor-ui/src/components/WorkflowSettings.vue b/packages/editor-ui/src/components/WorkflowSettings.vue index 910ea4ba16..c6571769e2 100644 --- a/packages/editor-ui/src/components/WorkflowSettings.vue +++ b/packages/editor-ui/src/components/WorkflowSettings.vue @@ -266,9 +266,7 @@ const loadTimezones = async () => { }; const loadWorkflows = async () => { - const workflowsData = (await workflowsStore.fetchAllWorkflows( - workflow.value.homeProject?.id, - )) as IWorkflowShortResponse[]; + const workflowsData = (await workflowsStore.fetchAllWorkflows()) as IWorkflowShortResponse[]; workflowsData.sort((a, b) => { if (a.name.toLowerCase() < b.name.toLowerCase()) { return -1; @@ -506,7 +504,7 @@ onMounted(async () => { - + {{ i18n.baseText('workflowSettings.errorWorkflow') + ':' }}