chore: create new tests for the UI, namely normnode, and one for all nodes

This commit is contained in:
Björn Otgaar
2025-11-27 17:14:19 +01:00
parent f87c7fed03
commit c5d9b8342d
7 changed files with 999 additions and 11 deletions

View File

@@ -0,0 +1,35 @@
// __tests__/utils/test-utils.tsx
import { render, type RenderOptions } from '@testing-library/react';
import { type ReactElement, type ReactNode } from 'react';
import { ReactFlowProvider } from '@xyflow/react';
import useFlowStore from '../../src/pages/VisProgPage/visualProgrammingUI/VisProgStores';
/**
* Custom render function that wraps components with necessary providers
* This ensures all components have access to ReactFlow context
*/
export function renderWithProviders(
ui: ReactElement,
options?: Omit<RenderOptions, 'wrapper'>
) {
function Wrapper({ children }: { children: ReactNode }) {
return <ReactFlowProvider>{children}</ReactFlowProvider>;
}
return render(ui, { wrapper: Wrapper, ...options });
}
/**
* Helper to reset the Zustand store between tests
* This ensures test isolation
*/
export function resetFlowStore() {
useFlowStore.setState({
nodes: [],
edges: [],
edgeReconnectSuccessful: true,
});
}
// Re-export everything from testing library
export * from '@testing-library/react';