feat: The Big One UI

This commit is contained in:
Gerla, J. (Justin)
2026-01-28 08:27:30 +00:00
committed by Pim Hutting
parent f9e0eb95f8
commit 82785dc8cb
45 changed files with 4147 additions and 143 deletions

View File

@@ -2,7 +2,7 @@
import { describe, it, beforeEach } from '@jest/globals';
import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { renderWithProviders } from '../.././/./../../test-utils/test-utils';
import { renderWithProviders } from '../../../../test-utils/test-utils.tsx';
import BasicBeliefNode, { type BasicBeliefNodeData } from '../../../../../src/pages/VisProgPage/visualProgrammingUI/nodes/BasicBeliefNode.tsx';
import useFlowStore from '../../../../../src/pages/VisProgPage/visualProgrammingUI/VisProgStores';
import type { Node } from '@xyflow/react';
@@ -150,7 +150,7 @@ describe('BasicBeliefNode', () => {
expect(screen.getByDisplayValue('Emotion recognised:')).toBeInTheDocument();
// For emotion type, we should check that the select has the correct value selected
const selectElement = screen.getByDisplayValue('Happy');
const selectElement = screen.getByDisplayValue('happy');
expect(selectElement).toBeInTheDocument();
expect((selectElement as HTMLSelectElement).value).toBe('happy');
});
@@ -185,14 +185,14 @@ describe('BasicBeliefNode', () => {
/>
);
const selectElement = screen.getByDisplayValue('Happy');
const selectElement = screen.getByDisplayValue('happy');
expect(selectElement).toBeInTheDocument();
// Check that all emotion options are present
expect(screen.getByText('Happy')).toBeInTheDocument();
expect(screen.getByText('Angry')).toBeInTheDocument();
expect(screen.getByText('Sad')).toBeInTheDocument();
expect(screen.getByText('Cheerful')).toBeInTheDocument();
expect(screen.getByText('happy')).toBeInTheDocument();
expect(screen.getByText('angry')).toBeInTheDocument();
expect(screen.getByText('sad')).toBeInTheDocument();
expect(screen.getByText('surprise')).toBeInTheDocument();
});
it('should render without wrapping quotes for object type', () => {
@@ -382,7 +382,7 @@ describe('BasicBeliefNode', () => {
data: {
label: 'Belief',
droppable: true,
belief: { type: 'emotion', id: 'em1', value: 'happy', label: 'Emotion recognised:' },
belief: { type: 'emotion', id: 'em1', value: 'sad', label: 'Emotion recognised:' },
hasReduce: true,
},
};
@@ -409,13 +409,13 @@ describe('BasicBeliefNode', () => {
/>
);
const select = screen.getByDisplayValue('Happy');
await user.selectOptions(select, 'sad');
const select = screen.getByDisplayValue('sad');
await user.selectOptions(select, 'happy');
await waitFor(() => {
const state = useFlowStore.getState();
const updatedNode = state.nodes.find(n => n.id === 'belief-1') as Node<BasicBeliefNodeData>;
expect(updatedNode?.data.belief.value).toBe('sad');
expect(updatedNode?.data.belief.value).toBe('happy');
});
});
@@ -511,13 +511,11 @@ describe('BasicBeliefNode', () => {
expect(updatedNode?.data.belief.type).toBe('emotion');
// The component doesn't reset the value when changing types
// So it keeps the old value even though it doesn't make sense for emotion type
expect(updatedNode?.data.belief.value).toBe('Happy');
expect(updatedNode?.data.belief.value).toBe('sad');
});
});
});
// ... rest of the tests remain the same, just fixing the Integration with Store section ...
describe('Integration with Store', () => {
it('should properly update the store when changing belief value', async () => {
const mockNode: Node<BasicBeliefNodeData> = {

View File

@@ -14,7 +14,7 @@ import { BasicBeliefNodeDefaults } from '../../../../../src/pages/VisProgPage/vi
import { defaultPlan } from '../../../../../src/pages/VisProgPage/visualProgrammingUI/components/Plan.default.ts';
import { NormNodeDefaults } from '../../../../../src/pages/VisProgPage/visualProgrammingUI/nodes/NormNode.default.ts';
import { GoalNodeDefaults } from '../../../../../src/pages/VisProgPage/visualProgrammingUI/nodes/GoalNode.default.ts';
import { act } from 'react-dom/test-utils';
import { act } from '@testing-library/react';
describe('TriggerNode', () => {
@@ -137,7 +137,6 @@ describe('TriggerNode', () => {
});
});
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.
@@ -162,7 +161,6 @@ describe('TriggerNode', () => {
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();
@@ -181,4 +179,4 @@ describe('TriggerNode', () => {
expect(stillHas).toBeUndefined();
});
});
});
});