Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Fix TypeError: Cannot read properties of undefined (reading '0') #11399

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions packages/editor-ui/src/composables/useExecutionDebugging.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createTestingPinia } from '@pinia/testing';
import { setActivePinia } from 'pinia';
import { mockedStore } from '@/__tests__/utils';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useExecutionDebugging } from './useExecutionDebugging';
import type { INodeUi, IExecutionResponse } from '@/Interface';
import type { Workflow } from 'n8n-workflow';

describe('useExecutionDebugging()', () => {
it('should applyExecutionData', async () => {
setActivePinia(createTestingPinia());
const mockExecution = {
data: {
resultData: {
runData: {
testNode: [
{
data: {},
},
],
},
},
},
} as unknown as IExecutionResponse;

const workflowStore = mockedStore(useWorkflowsStore);
workflowStore.getNodes.mockReturnValue([{ name: 'testNode' }] as INodeUi[]);
workflowStore.getExecution.mockResolvedValueOnce(mockExecution);
workflowStore.getCurrentWorkflow.mockReturnValue({
pinData: {},
getParentNodes: vi.fn().mockReturnValue([]),
} as unknown as Workflow);

const { applyExecutionData } = useExecutionDebugging();

await applyExecutionData('1');

expect(workflowStore.setWorkflowExecutionData).toHaveBeenCalledWith(mockExecution);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const useExecutionDebugging = () => {
let pinnings = 0;

pinnableNodes.forEach((node: INodeUi) => {
const nodeData = runData[node.name]?.[0].data?.main[0];
const nodeData = runData[node.name]?.[0].data?.main?.[0];
if (nodeData) {
pinnings++;
workflowsStore.pinData({
Expand Down
Loading