mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(editor): Fix nodes and connection debouncing during execution (no-changelog) (#14208)
This commit is contained in:
@@ -14,16 +14,13 @@ import {
|
||||
defaultNodeDescriptions,
|
||||
} from '@/__tests__/mocks';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import * as lodash from 'lodash-es';
|
||||
import * as vueuse from '@vueuse/core';
|
||||
|
||||
vi.mock('lodash-es', async () => {
|
||||
const actual = await vi.importActual('lodash-es');
|
||||
vi.mock('@vueuse/core', async () => {
|
||||
const actual = await vi.importActual('@vueuse/core');
|
||||
return {
|
||||
...actual,
|
||||
debounce: vi.fn((fn) => {
|
||||
// Return a function that immediately calls the provided function
|
||||
return (...args: unknown[]) => fn(...args);
|
||||
}),
|
||||
debouncedRef: vi.fn(actual.debouncedRef as typeof vueuse.debouncedRef),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -157,34 +154,6 @@ describe('WorkflowCanvas', () => {
|
||||
});
|
||||
|
||||
describe('debouncing behavior', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should initialize debounced watchers on component mount', async () => {
|
||||
renderComponent();
|
||||
|
||||
expect(lodash.debounce).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it('should configure debouncing with no delay when not executing', async () => {
|
||||
renderComponent({
|
||||
props: {
|
||||
executing: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(lodash.debounce).toHaveBeenCalledTimes(3);
|
||||
|
||||
// Find calls related to our specific debouncing logic
|
||||
const calls = vi.mocked(lodash.debounce).mock.calls;
|
||||
const nonExecutingCalls = calls.filter((call) => call[1] === 0 && call[2]?.maxWait === 0);
|
||||
|
||||
expect(nonExecutingCalls.length).toBeGreaterThanOrEqual(2);
|
||||
expect(nonExecutingCalls[0][1]).toBe(0);
|
||||
expect(nonExecutingCalls[0][2]).toEqual({ maxWait: 0 });
|
||||
});
|
||||
|
||||
it('should configure debouncing with delay when executing', async () => {
|
||||
renderComponent({
|
||||
props: {
|
||||
@@ -192,10 +161,10 @@ describe('WorkflowCanvas', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(lodash.debounce).toHaveBeenCalledTimes(3);
|
||||
expect(vueuse.debouncedRef).toHaveBeenCalledTimes(2);
|
||||
|
||||
// Find calls related to our specific debouncing logic
|
||||
const calls = vi.mocked(lodash.debounce).mock.calls;
|
||||
const calls = vi.mocked(vueuse.debouncedRef).mock.calls;
|
||||
const executingCalls = calls.filter((call) => call[1] === 200 && call[2]?.maxWait === 50);
|
||||
|
||||
expect(executingCalls.length).toBeGreaterThanOrEqual(2);
|
||||
|
||||
Reference in New Issue
Block a user