WIP improving helix flows and fixing tests

This commit is contained in:
Pierre Jacquier
2025-06-25 12:59:39 -04:00
parent 7a72a69cc5
commit 4d5f3a3c9d
3 changed files with 25 additions and 35 deletions

View File

@ -1151,8 +1151,7 @@ openSketch = startSketchOn(XY)
cmdBar, cmdBar,
}) => { }) => {
// One dumb hardcoded screen pixel value // One dumb hardcoded screen pixel value
const testPoint = { x: 620, y: 257 } const expectedOutput = `helix001 = helix( axis = X, radius = 5, length = 5, revolutions = 1, angleStart = 270,)`
const expectedOutput = `helix001 = helix( axis = X, radius = 5, length = 5, revolutions = 1, angleStart = 270, ccw = false,)`
const expectedLine = `axis=X,` const expectedLine = `axis=X,`
await homePage.goToModelingScene() await homePage.goToModelingScene()
@ -1169,7 +1168,6 @@ openSketch = startSketchOn(XY)
AngleStart: '', AngleStart: '',
Revolutions: '', Revolutions: '',
Radius: '', Radius: '',
CounterClockWise: '',
}, },
highlightedHeaderArg: 'mode', highlightedHeaderArg: 'mode',
commandName: 'Helix', commandName: 'Helix',
@ -1190,7 +1188,6 @@ openSketch = startSketchOn(XY)
AngleStart: '', AngleStart: '',
Length: '', Length: '',
Radius: '', Radius: '',
CounterClockWise: '',
}, },
commandName: 'Helix', commandName: 'Helix',
}) })
@ -1207,11 +1204,10 @@ openSketch = startSketchOn(XY)
Revolutions: '1', Revolutions: '1',
Length: '5', Length: '5',
Radius: '5', Radius: '5',
CounterClockWise: '',
}, },
commandName: 'Helix', commandName: 'Helix',
}) })
await cmdBar.progressCmdBar() await cmdBar.submit()
}) })
await test.step(`Confirm code is added to the editor, scene has changed`, async () => { await test.step(`Confirm code is added to the editor, scene has changed`, async () => {
@ -1221,8 +1217,6 @@ openSketch = startSketchOn(XY)
activeLines: [expectedLine], activeLines: [expectedLine],
highlightedCode: '', highlightedCode: '',
}) })
// Red plane is now gone, white helix is there
await scene.expectPixelColor([250, 250, 250], testPoint, 15)
}) })
await test.step(`Edit helix through the feature tree`, async () => { await test.step(`Edit helix through the feature tree`, async () => {
@ -1234,21 +1228,18 @@ openSketch = startSketchOn(XY)
await cmdBar.expectState({ await cmdBar.expectState({
commandName: 'Helix', commandName: 'Helix',
stage: 'arguments', stage: 'arguments',
currentArgKey: 'CounterClockWise', currentArgKey: 'length',
currentArgValue: '', currentArgValue: '5',
headerArguments: { headerArguments: {
Axis: 'X', Axis: 'X',
AngleStart: '270', AngleStart: '270',
Revolutions: '1', Revolutions: '1',
Radius: '5', Radius: '5',
Length: initialInput, Length: initialInput,
CounterClockWise: '',
}, },
highlightedHeaderArg: 'CounterClockWise', highlightedHeaderArg: 'length',
}) })
await page.keyboard.press('Shift+Backspace') await page.keyboard.insertText(newInput)
await expect(cmdBar.currentArgumentInput).toBeVisible()
await cmdBar.currentArgumentInput.locator('.cm-content').fill(newInput)
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await cmdBar.expectState({ await cmdBar.expectState({
stage: 'review', stage: 'review',
@ -1258,11 +1249,10 @@ openSketch = startSketchOn(XY)
Revolutions: '1', Revolutions: '1',
Radius: '5', Radius: '5',
Length: newInput, Length: newInput,
CounterClockWise: '',
}, },
commandName: 'Helix', commandName: 'Helix',
}) })
await cmdBar.progressCmdBar() await cmdBar.submit()
await toolbar.closeFeatureTreePane() await toolbar.closeFeatureTreePane()
await editor.openPane() await editor.openPane()
await editor.expectEditor.toContain('length = ' + newInput) await editor.expectEditor.toContain('length = ' + newInput)
@ -1273,8 +1263,8 @@ openSketch = startSketchOn(XY)
const operationButton = await toolbar.getFeatureTreeOperation('Helix', 0) const operationButton = await toolbar.getFeatureTreeOperation('Helix', 0)
await operationButton.click({ button: 'left' }) await operationButton.click({ button: 'left' })
await page.keyboard.press('Delete') await page.keyboard.press('Delete')
// Red plane is back await scene.settled(cmdBar)
await scene.expectPixelColor([96, 52, 52], testPoint, 15) await editor.expectEditor.not.toContain('helix')
}) })
}) })

View File

@ -590,7 +590,7 @@ export function addHelix({
angleStart: Expr angleStart: Expr
radius?: Expr radius?: Expr
length?: Expr length?: Expr
ccw: boolean ccw?: boolean
insertIndex?: number insertIndex?: number
variableName?: string variableName?: string
}): { modifiedAst: Node<Program>; pathToNode: PathToNode } { }): { modifiedAst: Node<Program>; pathToNode: PathToNode } {
@ -610,6 +610,9 @@ export function addHelix({
) )
} }
// Extra labeled args expressions
const ccwExpr = ccw ? [createLabeledArg('ccw', createLiteral(ccw))] : []
const variable = createVariableDeclaration( const variable = createVariableDeclaration(
name, name,
createCallExpressionStdLibKw( createCallExpressionStdLibKw(
@ -619,7 +622,7 @@ export function addHelix({
...modeArgs, ...modeArgs,
createLabeledArg('revolutions', revolutions), createLabeledArg('revolutions', revolutions),
createLabeledArg('angleStart', angleStart), createLabeledArg('angleStart', angleStart),
createLabeledArg('ccw', createLiteral(ccw)), ...ccwExpr,
] ]
) )
) )

View File

@ -690,14 +690,15 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
}, },
axis: { axis: {
inputType: 'options', inputType: 'options',
required: (commandContext) =>
['Axis'].includes(commandContext.argumentsToSubmit.mode as string),
options: [ options: [
{ name: 'X Axis', value: 'X' }, { name: 'X Axis', value: 'X' },
{ name: 'Y Axis', value: 'Y' }, { name: 'Y Axis', value: 'Y' },
{ name: 'Z Axis', value: 'Z' }, { name: 'Z Axis', value: 'Z' },
], ],
hidden: false, // for consistency here, we can actually edit here since it's not a selection required: (context) =>
['Axis'].includes(context.argumentsToSubmit.mode as string),
hidden: (context) =>
!['Axis'].includes(context.argumentsToSubmit.mode as string),
}, },
edge: { edge: {
inputType: 'selection', inputType: 'selection',
@ -732,34 +733,30 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
radius: { radius: {
inputType: 'kcl', inputType: 'kcl',
defaultValue: KCL_DEFAULT_LENGTH, defaultValue: KCL_DEFAULT_LENGTH,
required: (commandContext) => required: (context) =>
!['Cylinder'].includes( !['Cylinder'].includes(context.argumentsToSubmit.mode as string),
commandContext.argumentsToSubmit.mode as string hidden: (context) =>
), ['Cylinder'].includes(context.argumentsToSubmit.mode as string),
}, },
length: { length: {
inputType: 'kcl', inputType: 'kcl',
defaultValue: KCL_DEFAULT_LENGTH, defaultValue: KCL_DEFAULT_LENGTH,
required: (commandContext) => required: (commandContext) =>
['Axis'].includes(commandContext.argumentsToSubmit.mode as string), ['Axis'].includes(commandContext.argumentsToSubmit.mode as string),
// No need for hidden here, as it works with all modes
}, },
ccw: { ccw: {
inputType: 'options', inputType: 'options',
skip: true, required: false,
required: true,
defaultValue: false,
valueSummary: (value) => String(value),
displayName: 'CounterClockWise', displayName: 'CounterClockWise',
options: (commandContext) => [ options: [
{ {
name: 'False', name: 'False',
value: false, value: false,
isCurrent: !Boolean(commandContext.argumentsToSubmit.ccw),
}, },
{ {
name: 'True', name: 'True',
value: true, value: true,
isCurrent: Boolean(commandContext.argumentsToSubmit.ccw),
}, },
], ],
}, },