mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-13 13:57:29 -08:00
fix(editor): Fix TypeError: Cannot read properties of undefined (reading '0') (#11399)
This commit is contained in:
parent
8147038cf8
commit
ae37c520a9
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue