Fix edit issue in e2e
This commit is contained in:
@ -1406,7 +1406,7 @@ sketch002 = startSketchOn('XZ')
|
|||||||
})
|
})
|
||||||
await clickOnSketch2()
|
await clickOnSketch2()
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
await cmdBar.selectOption({ name: 'False' }).click()
|
await cmdBar.progressCmdBar()
|
||||||
await cmdBar.expectState({
|
await cmdBar.expectState({
|
||||||
commandName: 'Sweep',
|
commandName: 'Sweep',
|
||||||
headerArguments: {
|
headerArguments: {
|
||||||
@ -1432,23 +1432,20 @@ sketch002 = startSketchOn('XZ')
|
|||||||
await toolbar.closePane('code')
|
await toolbar.closePane('code')
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: this test hits a case that happens sometimes in manual testing where
|
|
||||||
// we can't edit the sweep right after its creation. As if the codemod didn't fully
|
|
||||||
// register during the initall add flow.
|
|
||||||
await test.step('Edit sweep via feature tree selection works', async () => {
|
await test.step('Edit sweep via feature tree selection works', async () => {
|
||||||
await toolbar.openPane('feature-tree')
|
await toolbar.openPane('feature-tree')
|
||||||
const operationButton = await toolbar.getFeatureTreeOperation('Sweep', 0)
|
const operationButton = await toolbar.getFeatureTreeOperation('Sweep', 0)
|
||||||
await operationButton.dblclick({ button: 'left' })
|
await operationButton.dblclick({ button: 'left' })
|
||||||
await cmdBar.selectOption({ name: 'True' }).click()
|
|
||||||
await cmdBar.expectState({
|
await cmdBar.expectState({
|
||||||
commandName: 'Sweep',
|
commandName: 'Sweep',
|
||||||
|
currentArgKey: 'sectional',
|
||||||
|
currentArgValue: '',
|
||||||
headerArguments: {
|
headerArguments: {
|
||||||
Sectional: '',
|
Sectional: '',
|
||||||
},
|
},
|
||||||
stage: 'review',
|
highlightedHeaderArg: 'sectional',
|
||||||
|
stage: 'arguments',
|
||||||
})
|
})
|
||||||
const submitButton = page.getByRole('button', { name: 'Submit command' })
|
|
||||||
await submitButton.press('Shift+Backspace')
|
|
||||||
await cmdBar.selectOption({ name: 'True' }).click()
|
await cmdBar.selectOption({ name: 'True' }).click()
|
||||||
await cmdBar.expectState({
|
await cmdBar.expectState({
|
||||||
commandName: 'Sweep',
|
commandName: 'Sweep',
|
||||||
|
|||||||
@ -475,9 +475,24 @@ export function addSweep({
|
|||||||
modifiedAst: Node<Program>
|
modifiedAst: Node<Program>
|
||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
} {
|
} {
|
||||||
|
console.log(
|
||||||
|
'addSweep',
|
||||||
|
JSON.stringify({
|
||||||
|
node,
|
||||||
|
targetDeclarator,
|
||||||
|
trajectoryDeclarator,
|
||||||
|
sectional,
|
||||||
|
variableName,
|
||||||
|
insertIndex,
|
||||||
|
})
|
||||||
|
)
|
||||||
const modifiedAst = structuredClone(node)
|
const modifiedAst = structuredClone(node)
|
||||||
|
console.log('modifiedAst')
|
||||||
const name =
|
const name =
|
||||||
variableName ?? findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SWEEP)
|
variableName ?? findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SWEEP)
|
||||||
|
console.log('name', name)
|
||||||
|
console.log('targetDeclarator', JSON.stringify(targetDeclarator))
|
||||||
|
console.log('targetDeclarator.id.name', targetDeclarator.id.name)
|
||||||
const call = createCallExpressionStdLibKw(
|
const call = createCallExpressionStdLibKw(
|
||||||
'sweep',
|
'sweep',
|
||||||
createIdentifier(targetDeclarator.id.name),
|
createIdentifier(targetDeclarator.id.name),
|
||||||
@ -486,7 +501,9 @@ export function addSweep({
|
|||||||
createLabeledArg('sectional', createLiteral(sectional)),
|
createLabeledArg('sectional', createLiteral(sectional)),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
console.log('call')
|
||||||
const variable = createVariableDeclaration(name, call)
|
const variable = createVariableDeclaration(name, call)
|
||||||
|
console.log('variable')
|
||||||
const insertAt =
|
const insertAt =
|
||||||
insertIndex !== undefined
|
insertIndex !== undefined
|
||||||
? insertIndex
|
? insertIndex
|
||||||
@ -494,6 +511,9 @@ export function addSweep({
|
|||||||
? modifiedAst.body.length
|
? modifiedAst.body.length
|
||||||
: 0
|
: 0
|
||||||
|
|
||||||
|
console.log('insertAt', insertAt)
|
||||||
|
console.log('modifiedAst.body.length', modifiedAst.body.length)
|
||||||
|
|
||||||
modifiedAst.body.length
|
modifiedAst.body.length
|
||||||
? modifiedAst.body.splice(insertAt, 0, variable)
|
? modifiedAst.body.splice(insertAt, 0, variable)
|
||||||
: modifiedAst.body.push(variable)
|
: modifiedAst.body.push(variable)
|
||||||
|
|||||||
@ -70,7 +70,7 @@ import {
|
|||||||
import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConfig'
|
import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConfig'
|
||||||
import { err, reportRejection, trap } from 'lib/trap'
|
import { err, reportRejection, trap } from 'lib/trap'
|
||||||
import { DefaultPlaneStr } from 'lib/planes'
|
import { DefaultPlaneStr } from 'lib/planes'
|
||||||
import { uuidv4 } from 'lib/utils'
|
import { isArray, uuidv4 } from 'lib/utils'
|
||||||
import { Coords2d } from 'lang/std/sketch'
|
import { Coords2d } from 'lang/std/sketch'
|
||||||
import { deleteSegment } from 'clientSideScene/ClientSideSceneComp'
|
import { deleteSegment } from 'clientSideScene/ClientSideSceneComp'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
@ -1891,7 +1891,7 @@ export const modelingMachine = setup({
|
|||||||
let variableName: string | undefined = undefined
|
let variableName: string | undefined = undefined
|
||||||
let insertIndex: number | undefined = undefined
|
let insertIndex: number | undefined = undefined
|
||||||
|
|
||||||
// If this is an edit flow, first we're going to remove the old extrusion
|
// If this is an edit flow, first we're going to remove the old one
|
||||||
if (nodeToEdit !== undefined && typeof nodeToEdit[1][0] === 'number') {
|
if (nodeToEdit !== undefined && typeof nodeToEdit[1][0] === 'number') {
|
||||||
// Extract the plane name from the node to edit
|
// Extract the plane name from the node to edit
|
||||||
const variableNode = getNodeFromPath<VariableDeclaration>(
|
const variableNode = getNodeFromPath<VariableDeclaration>(
|
||||||
@ -1918,30 +1918,36 @@ export const modelingMachine = setup({
|
|||||||
ast,
|
ast,
|
||||||
target.graphSelections[0].codeRef.range
|
target.graphSelections[0].codeRef.range
|
||||||
)
|
)
|
||||||
const targetNode = getNodeFromPath<VariableDeclarator>(
|
// Gotchas, not sure why
|
||||||
ast,
|
// - it seems like in some cases we get a list on edit, especially the state that e2e hits
|
||||||
targetNodePath,
|
// - looking for a VariableDeclaration seems more robust than VariableDeclarator
|
||||||
'VariableDeclarator'
|
const targetNode = getNodeFromPath<
|
||||||
)
|
VariableDeclaration | VariableDeclaration[]
|
||||||
|
>(ast, targetNodePath, 'VariableDeclaration')
|
||||||
if (err(targetNode)) {
|
if (err(targetNode)) {
|
||||||
return new Error("Couldn't parse profile selection")
|
return new Error("Couldn't parse profile selection")
|
||||||
}
|
}
|
||||||
const targetDeclarator = targetNode.node
|
|
||||||
|
const targetDeclarator = isArray(targetNode.node)
|
||||||
|
? targetNode.node[0].declaration
|
||||||
|
: targetNode.node.declaration
|
||||||
|
|
||||||
// Find the trajectory (or path) declaration
|
// Find the trajectory (or path) declaration
|
||||||
const trajectoryNodePath = getNodePathFromSourceRange(
|
const trajectoryNodePath = getNodePathFromSourceRange(
|
||||||
ast,
|
ast,
|
||||||
trajectory.graphSelections[0].codeRef.range
|
trajectory.graphSelections[0].codeRef.range
|
||||||
)
|
)
|
||||||
const trajectoryNode = getNodeFromPath<VariableDeclarator>(
|
// Also looking for VariableDeclaration for consistency here
|
||||||
|
const trajectoryNode = getNodeFromPath<VariableDeclaration>(
|
||||||
ast,
|
ast,
|
||||||
trajectoryNodePath,
|
trajectoryNodePath,
|
||||||
'VariableDeclarator'
|
'VariableDeclaration'
|
||||||
)
|
)
|
||||||
if (err(trajectoryNode)) {
|
if (err(trajectoryNode)) {
|
||||||
return new Error("Couldn't parse path selection")
|
return new Error("Couldn't parse path selection")
|
||||||
}
|
}
|
||||||
const trajectoryDeclarator = trajectoryNode.node
|
|
||||||
|
const trajectoryDeclarator = trajectoryNode.node.declaration
|
||||||
|
|
||||||
// Perform the sweep
|
// Perform the sweep
|
||||||
const addResult = addSweep({
|
const addResult = addSweep({
|
||||||
@ -1966,6 +1972,8 @@ export const modelingMachine = setup({
|
|||||||
if (updatedAst?.selections) {
|
if (updatedAst?.selections) {
|
||||||
editorManager.selectRange(updatedAst?.selections)
|
editorManager.selectRange(updatedAst?.selections)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('end of sweepastmod')
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
loftAstMod: fromPromise(
|
loftAstMod: fromPromise(
|
||||||
|
|||||||
Reference in New Issue
Block a user