feat: removed usage of structuredClone inside the editorWarningSystem
ref: N25B-450
This commit is contained in:
@@ -138,9 +138,8 @@ export function editorWarningRegistry(get: ZustandGet, set: ZustandSet) : Editor
|
|||||||
const { scope: {id, handleId}, type, severity } = warning;
|
const { scope: {id, handleId}, type, severity } = warning;
|
||||||
const warningKey = handleId ? `${type}:${handleId}` : type;
|
const warningKey = handleId ? `${type}:${handleId}` : type;
|
||||||
const compositeKey = `${id}|${warningKey}`;
|
const compositeKey = `${id}|${warningKey}`;
|
||||||
const wRegistry = structuredClone(get().editorWarningRegistry);
|
const wRegistry = get().editorWarningRegistry;
|
||||||
const sIndex = structuredClone(get().severityIndex);
|
const sIndex = get().severityIndex;
|
||||||
console.log("register")
|
|
||||||
// add to warning registry
|
// add to warning registry
|
||||||
if (!wRegistry.has(id)) {
|
if (!wRegistry.has(id)) {
|
||||||
wRegistry.set(id, new Map());
|
wRegistry.set(id, new Map());
|
||||||
@@ -160,9 +159,8 @@ export function editorWarningRegistry(get: ZustandGet, set: ZustandSet) : Editor
|
|||||||
},
|
},
|
||||||
|
|
||||||
unregisterWarning: (id, warningKey) => {
|
unregisterWarning: (id, warningKey) => {
|
||||||
const wRegistry = structuredClone(get().editorWarningRegistry);
|
const wRegistry = get().editorWarningRegistry;
|
||||||
const sIndex = structuredClone(get().severityIndex);
|
const sIndex = get().severityIndex;
|
||||||
console.log("unregister")
|
|
||||||
// verify if the warning was created already
|
// verify if the warning was created already
|
||||||
const warning = wRegistry.get(id)?.get(warningKey);
|
const warning = wRegistry.get(id)?.get(warningKey);
|
||||||
if (!warning) return;
|
if (!warning) return;
|
||||||
@@ -181,8 +179,8 @@ export function editorWarningRegistry(get: ZustandGet, set: ZustandSet) : Editor
|
|||||||
},
|
},
|
||||||
|
|
||||||
unregisterWarningsForId: (id) => {
|
unregisterWarningsForId: (id) => {
|
||||||
const wRegistry = structuredClone(get().editorWarningRegistry);
|
const wRegistry = get().editorWarningRegistry;
|
||||||
const sIndex = structuredClone(get().severityIndex);
|
const sIndex = get().severityIndex;
|
||||||
|
|
||||||
const nodeWarnings = wRegistry.get(id);
|
const nodeWarnings = wRegistry.get(id);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import {act} from '@testing-library/react';
|
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 type {HandleRule, RuleResult} from "../../../../src/pages/VisProgPage/visualProgrammingUI/HandleRuleLogic.ts";
|
||||||
import { NodeDisconnections } from "../../../../src/pages/VisProgPage/visualProgrammingUI/NodeRegistry.ts";
|
import { NodeDisconnections } from "../../../../src/pages/VisProgPage/visualProgrammingUI/NodeRegistry.ts";
|
||||||
import type {PhaseNodeData} from "../../../../src/pages/VisProgPage/visualProgrammingUI/nodes/PhaseNode.tsx";
|
import type {PhaseNodeData} from "../../../../src/pages/VisProgPage/visualProgrammingUI/nodes/PhaseNode.tsx";
|
||||||
@@ -397,9 +402,9 @@ describe('FlowStore Functionality', () => {
|
|||||||
target: 'B'
|
target: 'B'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
const {deleteElements} = useReactFlow();
|
||||||
act(()=> {
|
act(()=> {
|
||||||
deleteNode(nodeId);
|
deleteNode(nodeId, deleteElements);
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatedState = useFlowStore.getState();
|
const updatedState = useFlowStore.getState();
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import { cleanup } from '@testing-library/react';
|
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';
|
import useFlowStore from '../src/pages/VisProgPage/visualProgrammingUI/VisProgStores.tsx';
|
||||||
|
|
||||||
if (!globalThis.structuredClone) {
|
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();
|
||||||
|
|
||||||
beforeAll(() => {
|
const defaultState = {
|
||||||
useFlowStore.setState({
|
|
||||||
nodes: [],
|
nodes: [],
|
||||||
edges: [],
|
edges: [],
|
||||||
past: [],
|
past: [],
|
||||||
future: [],
|
future: [],
|
||||||
isBatchAction: false,
|
isBatchAction: false,
|
||||||
edgeReconnectSuccessful: true,
|
edgeReconnectSuccessful: true,
|
||||||
ruleRegistry: new Map()
|
ruleRegistry: new Map(),
|
||||||
});
|
editorWarningRegistry: emptyWarningRegistry,
|
||||||
|
severityIndex: emptySeverityIndex,
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
useFlowStore.setState(defaultState);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
cleanup();
|
cleanup();
|
||||||
useFlowStore.setState({
|
useFlowStore.setState(defaultState);
|
||||||
nodes: [],
|
|
||||||
edges: [],
|
|
||||||
past: [],
|
|
||||||
future: [],
|
|
||||||
isBatchAction: false,
|
|
||||||
edgeReconnectSuccessful: true,
|
|
||||||
ruleRegistry: new Map()
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof HTMLDialogElement !== 'undefined') {
|
if (typeof HTMLDialogElement !== 'undefined') {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
import { render, type RenderOptions } from '@testing-library/react';
|
import { render, type RenderOptions } from '@testing-library/react';
|
||||||
import { type ReactElement, type ReactNode } from 'react';
|
import { type ReactElement, type ReactNode } from 'react';
|
||||||
import { ReactFlowProvider } from '@xyflow/react';
|
import { ReactFlowProvider } from '@xyflow/react';
|
||||||
|
import {mockReactFlow} from "../setupFlowTests.ts";
|
||||||
|
|
||||||
|
mockReactFlow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom render function that wraps components with necessary providers
|
* Custom render function that wraps components with necessary providers
|
||||||
|
|||||||
Reference in New Issue
Block a user