Merging dev into main #49
@@ -119,7 +119,6 @@ export function NormReduce(node: Node, nodes: Node[]) {
|
|||||||
*/
|
*/
|
||||||
export function NormConnectionTarget(_thisNode: Node, _sourceNodeId: string) {
|
export function NormConnectionTarget(_thisNode: Node, _sourceNodeId: string) {
|
||||||
const data = _thisNode.data as NormNodeData;
|
const data = _thisNode.data as NormNodeData;
|
||||||
|
|
||||||
// If we got a belief connected, this is a condition for the norm.
|
// If we got a belief connected, this is a condition for the norm.
|
||||||
if ((useFlowStore.getState().nodes.find((node) => node.id === _sourceNodeId && node.type === 'basic_belief' /* TODO: Add the option for an inferred belief */))) {
|
if ((useFlowStore.getState().nodes.find((node) => node.id === _sourceNodeId && node.type === 'basic_belief' /* TODO: Add the option for an inferred belief */))) {
|
||||||
data.conditions.push(_sourceNodeId);
|
data.conditions.push(_sourceNodeId);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ describe('NormNode', () => {
|
|||||||
id: 'norm-1',
|
id: 'norm-1',
|
||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: NormNodeDefaults,
|
data: {...JSON.parse(JSON.stringify(NormNodeDefaults))},
|
||||||
};
|
};
|
||||||
|
|
||||||
renderWithProviders(
|
renderWithProviders(
|
||||||
@@ -56,7 +56,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Be respectful to humans',
|
norm: 'Be respectful to humans',
|
||||||
@@ -91,7 +91,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
conditions: [],
|
conditions: [],
|
||||||
@@ -128,7 +128,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Dragged norm',
|
norm: 'Dragged norm',
|
||||||
@@ -165,7 +165,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: '',
|
norm: '',
|
||||||
@@ -211,7 +211,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Initial norm text',
|
norm: 'Initial norm text',
|
||||||
@@ -263,7 +263,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: '',
|
norm: '',
|
||||||
@@ -317,7 +317,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: '',
|
norm: '',
|
||||||
@@ -362,7 +362,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: '',
|
norm: '',
|
||||||
@@ -409,7 +409,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Safety Norm',
|
label: 'Safety Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Never harm humans',
|
norm: 'Never harm humans',
|
||||||
@@ -435,7 +435,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Norm 1',
|
label: 'Norm 1',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Be helpful',
|
norm: 'Be helpful',
|
||||||
@@ -448,7 +448,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 100, y: 0 },
|
position: { x: 100, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Norm 2',
|
label: 'Norm 2',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Be honest',
|
norm: 'Be honest',
|
||||||
@@ -473,7 +473,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Empty Norm',
|
label: 'Empty Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: '',
|
norm: '',
|
||||||
@@ -493,7 +493,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Custom Label',
|
label: 'Custom Label',
|
||||||
droppable: false,
|
droppable: false,
|
||||||
norm: 'Test norm',
|
norm: 'Test norm',
|
||||||
@@ -514,7 +514,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Test',
|
norm: 'Test',
|
||||||
@@ -527,7 +527,7 @@ describe('NormNode', () => {
|
|||||||
type: 'phase',
|
type: 'phase',
|
||||||
position: { x: 100, y: 0 },
|
position: { x: 100, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Phase 1',
|
label: 'Phase 1',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
children: [],
|
children: [],
|
||||||
@@ -546,7 +546,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Test',
|
norm: 'Test',
|
||||||
@@ -559,7 +559,7 @@ describe('NormNode', () => {
|
|||||||
type: 'phase',
|
type: 'phase',
|
||||||
position: { x: 100, y: 0 },
|
position: { x: 100, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Phase 1',
|
label: 'Phase 1',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
children: [],
|
children: [],
|
||||||
@@ -600,7 +600,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: '',
|
norm: '',
|
||||||
@@ -652,7 +652,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: '',
|
norm: '',
|
||||||
@@ -701,7 +701,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Norm 1',
|
label: 'Norm 1',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Original norm 1',
|
norm: 'Original norm 1',
|
||||||
@@ -714,7 +714,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 100, y: 0 },
|
position: { x: 100, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Norm 2',
|
label: 'Norm 2',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'Original norm 2',
|
norm: 'Original norm 2',
|
||||||
@@ -827,7 +827,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'haa haa fuyaaah - link',
|
norm: 'haa haa fuyaaah - link',
|
||||||
@@ -840,7 +840,7 @@ describe('NormNode', () => {
|
|||||||
type: 'basic_belief',
|
type: 'basic_belief',
|
||||||
position: {x:100, y:100},
|
position: {x:100, y:100},
|
||||||
data: {
|
data: {
|
||||||
...BasicBeliefNodeDefaults
|
...JSON.parse(JSON.stringify(BasicBeliefNodeDefaults))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -889,6 +889,8 @@ describe('NormNode', () => {
|
|||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByTestId('norm-condition-information')).toBeInTheDocument();
|
expect(screen.getByTestId('norm-condition-information')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the data when adding beliefs', async () => {
|
it('should update the data when adding beliefs', async () => {
|
||||||
@@ -898,7 +900,7 @@ describe('NormNode', () => {
|
|||||||
type: 'norm',
|
type: 'norm',
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
data: {
|
data: {
|
||||||
...NormNodeDefaults,
|
...JSON.parse(JSON.stringify(NormNodeDefaults)),
|
||||||
label: 'Test Norm',
|
label: 'Test Norm',
|
||||||
droppable: true,
|
droppable: true,
|
||||||
norm: 'haa haa fuyaaah - link',
|
norm: 'haa haa fuyaaah - link',
|
||||||
@@ -911,7 +913,7 @@ describe('NormNode', () => {
|
|||||||
type: 'basic_belief',
|
type: 'basic_belief',
|
||||||
position: {x:100, y:100},
|
position: {x:100, y:100},
|
||||||
data: {
|
data: {
|
||||||
...BasicBeliefNodeDefaults
|
...JSON.parse(JSON.stringify(BasicBeliefNodeDefaults))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -920,7 +922,7 @@ describe('NormNode', () => {
|
|||||||
type: 'basic_belief',
|
type: 'basic_belief',
|
||||||
position: {x:300, y:300},
|
position: {x:300, y:300},
|
||||||
data: {
|
data: {
|
||||||
...BasicBeliefNodeDefaults
|
...JSON.parse(JSON.stringify(BasicBeliefNodeDefaults))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -947,7 +949,7 @@ describe('NormNode', () => {
|
|||||||
const state = useFlowStore.getState();
|
const state = useFlowStore.getState();
|
||||||
const updatedNorm = state.nodes.find(n => n.id === 'norm-1');
|
const updatedNorm = state.nodes.find(n => n.id === 'norm-1');
|
||||||
console.log(updatedNorm?.data.conditions);
|
console.log(updatedNorm?.data.conditions);
|
||||||
expect(updatedNorm?.data.conditions).toEqual(["basic_belief-1", "basic_belief-1", "basic_belief-2"]);
|
expect(updatedNorm?.data.conditions).toEqual(["basic_belief-1", "basic_belief-2"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user