chore: added tests for monitoringpage
also moved some functions from VisProg outside VisProg.tsx into VisProgLogic.tsx so I can reuse it for the reset experiment function of monitor page Also fixed a small merge error in TriggerNodes.tsx ref: N25B-400
This commit is contained in:
@@ -137,47 +137,46 @@ describe('TriggerNode', () => {
|
||||
});
|
||||
});
|
||||
|
||||
//doesnt work anymore, but I have no idea how to fix it
|
||||
// describe('TriggerConnects Function', () => {
|
||||
// it('should correctly remove a goal from the triggers plan after it has been disconnected', () => {
|
||||
// // first, define the goal node and trigger node.
|
||||
// const goal: Node = {
|
||||
// id: 'g-1',
|
||||
// type: 'goal',
|
||||
// position: { x: 0, y: 0 },
|
||||
// data: { ...JSON.parse(JSON.stringify(GoalNodeDefaults)), name: 'Goal 1' },
|
||||
// };
|
||||
describe('TriggerConnects Function', () => {
|
||||
it('should correctly remove a goal from the triggers plan after it has been disconnected', () => {
|
||||
// first, define the goal node and trigger node.
|
||||
const goal: Node = {
|
||||
id: 'g-1',
|
||||
type: 'goal',
|
||||
position: { x: 0, y: 0 },
|
||||
data: { ...JSON.parse(JSON.stringify(GoalNodeDefaults)), name: 'Goal 1' },
|
||||
};
|
||||
|
||||
// const trigger: Node<TriggerNodeData> = {
|
||||
// id: 'trigger-1',
|
||||
// type: 'trigger',
|
||||
// position: { x: 0, y: 0 },
|
||||
// data: { ...JSON.parse(JSON.stringify(TriggerNodeDefaults)) },
|
||||
// };
|
||||
const trigger: Node<TriggerNodeData> = {
|
||||
id: 'trigger-1',
|
||||
type: 'trigger',
|
||||
position: { x: 0, y: 0 },
|
||||
data: { ...JSON.parse(JSON.stringify(TriggerNodeDefaults)) },
|
||||
};
|
||||
|
||||
// // set initial store
|
||||
// useFlowStore.setState({ nodes: [goal, trigger], edges: [] });
|
||||
// set initial store
|
||||
useFlowStore.setState({ nodes: [goal, trigger], edges: [] });
|
||||
|
||||
// // then, connect the goal to the trigger.
|
||||
// act(() => {
|
||||
// useFlowStore.getState().onConnect({ source: 'g-1', target: 'trigger-1', sourceHandle: null, targetHandle: null });
|
||||
// });
|
||||
// // expect the goal id to be part of a goal step of the plan.
|
||||
// let updatedTrigger = useFlowStore.getState().nodes.find((n) => n.id === 'trigger-1');
|
||||
// expect(updatedTrigger?.data.plan).toBeDefined();
|
||||
// const plan = updatedTrigger?.data.plan as any;
|
||||
// expect(plan.steps.find((s: any) => s.id === 'g-1')).toBeDefined();
|
||||
// then, connect the goal to the trigger.
|
||||
act(() => {
|
||||
useFlowStore.getState().onConnect({ source: 'g-1', target: 'trigger-1', sourceHandle: null, targetHandle: null });
|
||||
});
|
||||
// expect the goal id to be part of a goal step of the plan.
|
||||
let updatedTrigger = useFlowStore.getState().nodes.find((n) => n.id === 'trigger-1');
|
||||
expect(updatedTrigger?.data.plan).toBeDefined();
|
||||
const plan = updatedTrigger?.data.plan as any;
|
||||
expect(plan.steps.find((s: any) => s.id === 'g-1')).toBeDefined();
|
||||
|
||||
// // then, disconnect the goal from the trigger.
|
||||
// act(() => {
|
||||
// useFlowStore.getState().onEdgesDelete([{ id: 'g-1-trigger-1', source: 'g-1', target: 'trigger-1' } as any]);
|
||||
// });
|
||||
// then, disconnect the goal from the trigger.
|
||||
act(() => {
|
||||
useFlowStore.getState().onEdgesDelete([{ id: 'g-1-trigger-1', source: 'g-1', target: 'trigger-1' } as any]);
|
||||
});
|
||||
|
||||
// // finally, expect the goal id to NOT be part of the goal step of the plan.
|
||||
// updatedTrigger = useFlowStore.getState().nodes.find((n) => n.id === 'trigger-1');
|
||||
// const planAfter = updatedTrigger?.data.plan as any;
|
||||
// const stillHas = planAfter?.steps?.find((s: any) => s.id === 'g-1');
|
||||
// expect(stillHas).toBeUndefined();
|
||||
// });
|
||||
// });
|
||||
// finally, expect the goal id to NOT be part of the goal step of the plan.
|
||||
updatedTrigger = useFlowStore.getState().nodes.find((n) => n.id === 'trigger-1');
|
||||
const planAfter = updatedTrigger?.data.plan as any;
|
||||
const stillHas = planAfter?.steps?.find((s: any) => s.id === 'g-1');
|
||||
expect(stillHas).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user