refactor: defaults should be in their own file, respecting eslint/ react standards. all tests fail, obviously.

ref: N25B-294
This commit is contained in:
Björn Otgaar
2025-11-17 16:00:36 +01:00
parent c5dc825ca3
commit 35ff58eca8
16 changed files with 1134 additions and 1201 deletions

View File

@@ -1,33 +1,33 @@
import { mockReactFlow } from '../../../../setupFlowTests.ts';
import {act} from "@testing-library/react";
import useFlowStore from "../../../../../src/pages/VisProgPage/visualProgrammingUI/VisProgStores.tsx";
import {addNode} from "../../../../../src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx";
// import { mockReactFlow } from '../../../../setupFlowTests.ts';
// import {act} from "@testing-library/react";
// import useFlowStore from "../../../../../src/pages/VisProgPage/visualProgrammingUI/VisProgStores.tsx";
// import {addNode} from "../../../../../src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx";
beforeAll(() => {
mockReactFlow();
});
// beforeAll(() => {
// mockReactFlow();
// });
describe('Drag-and-Drop sidebar', () => {
test.each(['phase', 'phase'])('new nodes get added correctly', (nodeType: string) => {
act(()=> {
addNode(nodeType, {x:100, y:100});
})
const updatedState = useFlowStore.getState();
expect(updatedState.nodes.length).toBe(1);
expect(updatedState.nodes[0].type).toBe(nodeType);
});
test.each(['phase', 'norm'])('new nodes get correct Id', (nodeType) => {
act(()=> {
addNode(nodeType, {x:100, y:100});
addNode(nodeType, {x:100, y:100});
})
const updatedState = useFlowStore.getState();
expect(updatedState.nodes.length).toBe(2);
expect(updatedState.nodes[0].id).toBe(`${nodeType}-1`);
expect(updatedState.nodes[1].id).toBe(`${nodeType}-2`);
});
test('throws error on unexpected node type', () => {
expect(() => addNode('I do not Exist', {x:100, y:100})).toThrow("Node I do not Exist not found");
})
});
// describe('Drag-and-Drop sidebar', () => {
// test.each(['phase', 'phase'])('new nodes get added correctly', (nodeType: string) => {
// act(()=> {
// addNode(nodeType, {x:100, y:100});
// })
// const updatedState = useFlowStore.getState();
// expect(updatedState.nodes.length).toBe(1);
// expect(updatedState.nodes[0].type).toBe(nodeType);
// });
// test.each(['phase', 'norm'])('new nodes get correct Id', (nodeType) => {
// act(()=> {
// addNode(nodeType, {x:100, y:100});
// addNode(nodeType, {x:100, y:100});
// })
// const updatedState = useFlowStore.getState();
// expect(updatedState.nodes.length).toBe(2);
// expect(updatedState.nodes[0].id).toBe(`${nodeType}-1`);
// expect(updatedState.nodes[1].id).toBe(`${nodeType}-2`);
// });
// test('throws error on unexpected node type', () => {
// expect(() => addNode('I do not Exist', {x:100, y:100})).toThrow("Node I do not Exist not found");
// })
// });