chore: change goal text, correct output for gestures, allow step specific reducing, fix tests/ add tests for new things
This commit is contained in:
@@ -3,10 +3,11 @@ import userEvent from '@testing-library/user-event';
|
||||
import { renderWithProviders, screen } from '../../../../test-utils/test-utils.tsx';
|
||||
import GestureValueEditor from '../../../../../src/pages/VisProgPage/visualProgrammingUI/components/GestureValueEditor';
|
||||
|
||||
function TestHarness({ initialValue = '', placeholder = 'Gesture name' } : { initialValue?: string, placeholder?: string }) {
|
||||
function TestHarness({ initialValue = '', initialType=true, placeholder = 'Gesture name' } : { initialValue?: string, initialType?: boolean, placeholder?: string }) {
|
||||
const [value, setValue] = useState(initialValue);
|
||||
const [_, setType] = useState(initialType)
|
||||
return (
|
||||
<GestureValueEditor value={value} setValue={setValue} placeholder={placeholder} />
|
||||
<GestureValueEditor value={value} setValue={setValue} setType={setType} placeholder={placeholder} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { screen, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { renderWithProviders } from '../../../../test-utils/test-utils.tsx';
|
||||
import PlanEditorDialog from '../../../../../src/pages/VisProgPage/visualProgrammingUI/components/PlanEditor';
|
||||
import type { Plan } from '../../../../../src/pages/VisProgPage/visualProgrammingUI/components/Plan';
|
||||
import { PlanReduce, type Plan } from '../../../../../src/pages/VisProgPage/visualProgrammingUI/components/Plan';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
// Mock structuredClone
|
||||
@@ -28,12 +28,48 @@ describe('PlanEditorDialog', () => {
|
||||
steps: [],
|
||||
};
|
||||
|
||||
const extendedPlan: Plan = {
|
||||
id: 'extended-plan-1',
|
||||
name: 'extended test plan',
|
||||
steps: [
|
||||
// Step 1: A wave tag gesture
|
||||
{
|
||||
id: 'firststep',
|
||||
type: 'gesture',
|
||||
isTag: true,
|
||||
gesture: "hello"
|
||||
},
|
||||
|
||||
// Step 2: A single tag gesture
|
||||
{
|
||||
id: 'secondstep',
|
||||
type: 'gesture',
|
||||
isTag: false,
|
||||
gesture: "somefolder/somegesture"
|
||||
},
|
||||
|
||||
// Step 3: A LLM action
|
||||
{
|
||||
id: 'thirdstep',
|
||||
type: 'llm',
|
||||
goal: 'ask the user something or whatever'
|
||||
},
|
||||
|
||||
// Step 4: A speech action
|
||||
{
|
||||
id: 'fourthstep',
|
||||
type: 'speech',
|
||||
text: "I'm a cyborg ninja :>"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
const planWithSteps: Plan = {
|
||||
id: 'plan-2',
|
||||
name: 'Existing Plan',
|
||||
steps: [
|
||||
{ id: 'step-1', text: 'Hello world', type: 'speech' as const },
|
||||
{ id: 'step-2', gesture: 'Wave', type: 'gesture' as const },
|
||||
{ id: 'step-2', gesture: 'Wave', isTag:true, type: 'gesture' as const },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -429,4 +465,42 @@ describe('PlanEditorDialog', () => {
|
||||
expect(llmInput).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Plan reducing', () => {
|
||||
it('should correctly reduce the plan given the elements of the plan', () => {
|
||||
const testplan = extendedPlan
|
||||
const expectedResult = {
|
||||
name: "extended test plan",
|
||||
id: "extended-plan-1",
|
||||
steps: [
|
||||
{
|
||||
id: "firststep",
|
||||
gesture: {
|
||||
type: "tag",
|
||||
name: "hello"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "secondstep",
|
||||
gesture: {
|
||||
type: "single",
|
||||
name: "somefolder/somegesture"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "thirdstep",
|
||||
goal: "ask the user something or whatever"
|
||||
},
|
||||
{
|
||||
id: "fourthstep",
|
||||
text: "I'm a cyborg ninja :>"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const actualResult = PlanReduce(testplan)
|
||||
|
||||
expect(actualResult).toEqual(expectedResult)
|
||||
});
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user