feat: removed usage of structuredClone inside the editorWarningSystem

ref: N25B-450
This commit is contained in:
JGerla
2026-01-22 12:02:20 +01:00
parent d6d74d4c6b
commit c9c7f55aa0
4 changed files with 42 additions and 29 deletions

View File

@@ -1,5 +1,10 @@
import {act} from '@testing-library/react';
import type {Connection, Edge, Node} from "@xyflow/react";
import {
type Connection,
type Edge,
type Node,
useReactFlow
} from "@xyflow/react";
import type {HandleRule, RuleResult} from "../../../../src/pages/VisProgPage/visualProgrammingUI/HandleRuleLogic.ts";
import { NodeDisconnections } from "../../../../src/pages/VisProgPage/visualProgrammingUI/NodeRegistry.ts";
import type {PhaseNodeData} from "../../../../src/pages/VisProgPage/visualProgrammingUI/nodes/PhaseNode.tsx";
@@ -397,9 +402,9 @@ describe('FlowStore Functionality', () => {
target: 'B'
}]
});
const {deleteElements} = useReactFlow();
act(()=> {
deleteNode(nodeId);
deleteNode(nodeId, deleteElements);
});
const updatedState = useFlowStore.getState();

View File

@@ -1,5 +1,10 @@
import '@testing-library/jest-dom';
import { cleanup } from '@testing-library/react';
import {
type CompositeWarningKey,
type SeverityIndex,
type WarningRegistry
} from "../src/pages/VisProgPage/visualProgrammingUI/components/EditorWarnings.tsx";
import useFlowStore from '../src/pages/VisProgPage/visualProgrammingUI/VisProgStores.tsx';
if (!globalThis.structuredClone) {
@@ -69,31 +74,33 @@ export const mockReactFlow = () => {
};
const emptySeverityIndex : SeverityIndex = new Map([
['INFO', new Set<CompositeWarningKey>()],
['WARNING', new Set<CompositeWarningKey>()],
['ERROR', new Set<CompositeWarningKey>()],
]);
const emptyWarningRegistry : WarningRegistry = new Map();
const defaultState = {
nodes: [],
edges: [],
past: [],
future: [],
isBatchAction: false,
edgeReconnectSuccessful: true,
ruleRegistry: new Map(),
editorWarningRegistry: emptyWarningRegistry,
severityIndex: emptySeverityIndex,
}
beforeAll(() => {
useFlowStore.setState({
nodes: [],
edges: [],
past: [],
future: [],
isBatchAction: false,
edgeReconnectSuccessful: true,
ruleRegistry: new Map()
});
useFlowStore.setState(defaultState);
});
afterEach(() => {
cleanup();
useFlowStore.setState({
nodes: [],
edges: [],
past: [],
future: [],
isBatchAction: false,
edgeReconnectSuccessful: true,
ruleRegistry: new Map()
});
useFlowStore.setState(defaultState);
});
if (typeof HTMLDialogElement !== 'undefined') {

View File

@@ -2,6 +2,9 @@
import { render, type RenderOptions } from '@testing-library/react';
import { type ReactElement, type ReactNode } from 'react';
import { ReactFlowProvider } from '@xyflow/react';
import {mockReactFlow} from "../setupFlowTests.ts";
mockReactFlow();
/**
* Custom render function that wraps components with necessary providers