chore: change goal text, correct output for gestures, allow step specific reducing, fix tests/ add tests for new things

This commit is contained in:
Björn Otgaar
2026-01-05 16:38:06 +01:00
parent 111400bd82
commit 216b136a75
6 changed files with 122 additions and 8 deletions

View File

@@ -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)
});
})
});