mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
fix(editor): Show all workflows in the error workflow dropdown in the workflow settings (#12413)
This commit is contained in:
parent
f043ff12c6
commit
ccda7f9c62
|
@ -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<typeof useWorkflowsStore>;
|
|||
let settingsStore: ReturnType<typeof useSettingsStore>;
|
||||
let uiStore: ReturnType<typeof useUIStore>;
|
||||
|
||||
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';
|
||||
|
||||
|
|
|
@ -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 () => {
|
|||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-row data-test-id="error-workflow">
|
||||
<el-col :span="10" class="setting-name">
|
||||
{{ i18n.baseText('workflowSettings.errorWorkflow') + ':' }}
|
||||
<n8n-tooltip placement="top">
|
||||
|
|
Loading…
Reference in a new issue