Clean up and working pw test
This commit is contained in:
@ -687,18 +687,18 @@ test(`Loft point-and-click`, async ({
|
||||
cmdBar,
|
||||
}) => {
|
||||
const initialCode = `sketch001 = startSketchOn('XZ')
|
||||
|> circle({ center = [0, 0], radius = 10 }, %)
|
||||
plane001 = offsetPlane('XZ', 20)
|
||||
|> circle({ center = [0, 0], radius = 30 }, %)
|
||||
plane001 = offsetPlane('XZ', 50)
|
||||
sketch002 = startSketchOn(plane001)
|
||||
|> circle({ center = [0, 0], radius = 5 }, %)
|
||||
|> circle({ center = [0, 0], radius = 20 }, %)
|
||||
`
|
||||
await app.initialise(initialCode)
|
||||
|
||||
// One dumb hardcoded screen pixel value
|
||||
const testPoint = { x: 575, y: 200 }
|
||||
const [clickOnSketch1] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
|
||||
const [clickOnSketch2] = scene.makeMouseHelpers(testPoint.x, testPoint.y + 50)
|
||||
const expectedOutput = `${initialCode}loft001 = loft([sketch001, sketch002])`
|
||||
const [clickOnSketch2] = scene.makeMouseHelpers(testPoint.x, testPoint.y + 80)
|
||||
const loftDeclaration = 'loft001 = loft([sketch001, sketch002])'
|
||||
|
||||
await test.step(`Look for the white of the sketch001 shape`, async () => {
|
||||
await scene.expectPixelColor([254, 254, 254], testPoint, 15)
|
||||
@ -716,6 +716,8 @@ sketch002 = startSketchOn(plane001)
|
||||
await clickOnSketch1()
|
||||
await page.keyboard.down('Shift')
|
||||
await clickOnSketch2()
|
||||
await app.page.waitForTimeout(500)
|
||||
await page.keyboard.up('Shift')
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.expectState({
|
||||
stage: 'review',
|
||||
@ -726,12 +728,12 @@ sketch002 = startSketchOn(plane001)
|
||||
})
|
||||
|
||||
await test.step(`Confirm code is added to the editor, scene has changed`, async () => {
|
||||
await editor.expectEditor.toContain(expectedOutput)
|
||||
await editor.expectEditor.toContain(loftDeclaration)
|
||||
await editor.expectState({
|
||||
diagnostics: [],
|
||||
activeLines: [expectedOutput],
|
||||
activeLines: [loftDeclaration],
|
||||
highlightedCode: '',
|
||||
})
|
||||
await scene.expectPixelColor([74, 74, 74], testPoint, 15)
|
||||
await scene.expectPixelColor([109, 109, 109], testPoint, 15)
|
||||
})
|
||||
})
|
||||
|
@ -577,10 +577,6 @@ export const ModelingMachineProvider = ({
|
||||
isSelectionLastLine(selectionRanges, codeManager.code)
|
||||
|
||||
if (hasNoSelection) {
|
||||
// TODO: can't select more than one face now if not done prior
|
||||
// they have no selection, we should enable the button
|
||||
// so they can select the faces through the cmdbar
|
||||
// BUT only if there's two extrudable geometry
|
||||
const count = 2
|
||||
return doesSceneHaveSweepableSketch(kclManager.ast, count)
|
||||
}
|
||||
|
@ -355,23 +355,20 @@ export function loftSketches(
|
||||
pathToLoftArg: PathToNode
|
||||
}
|
||||
| Error {
|
||||
const _node = structuredClone(node)
|
||||
|
||||
const modifiedAst = structuredClone(node)
|
||||
const variableDeclarators = []
|
||||
const pathsToDeclaration = []
|
||||
for (const path of nodePaths) {
|
||||
const node = getNodeFromPath<VariableDeclarator>(
|
||||
_node,
|
||||
const nodeFromPath = getNodeFromPath<VariableDeclarator>(
|
||||
modifiedAst,
|
||||
path,
|
||||
'VariableDeclarator'
|
||||
)
|
||||
if (err(node)) {
|
||||
return node
|
||||
|
||||
if (err(nodeFromPath)) {
|
||||
return nodeFromPath
|
||||
}
|
||||
|
||||
const { node: variableDeclarator, shallowPath: pathToDecleration } = node
|
||||
variableDeclarators.push(variableDeclarator)
|
||||
pathsToDeclaration.push(pathToDecleration)
|
||||
variableDeclarators.push(nodeFromPath.node)
|
||||
}
|
||||
|
||||
const identifiers = createArrayExpression(
|
||||
@ -379,32 +376,20 @@ export function loftSketches(
|
||||
)
|
||||
const loftCall = createCallExpressionStdLib('loft', [identifiers])
|
||||
const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.LOFT)
|
||||
const VariableDeclaration = createVariableDeclaration(name, loftCall)
|
||||
|
||||
const sketchIndexInPathToNode = (path: PathToNode) =>
|
||||
path.findIndex((a) => a[0] === 'body') + 1
|
||||
pathsToDeclaration.sort(
|
||||
(a, b) =>
|
||||
(a[sketchIndexInPathToNode(a)][0] as number) -
|
||||
(b[sketchIndexInPathToNode(b)][0] as number)
|
||||
)
|
||||
const lastPath = pathsToDeclaration[pathsToDeclaration.length - 1]
|
||||
const sketchIndexInBody = lastPath[
|
||||
sketchIndexInPathToNode(lastPath)
|
||||
][0] as number
|
||||
_node.body.splice(sketchIndexInBody + 1, 0, VariableDeclaration)
|
||||
|
||||
const loftDeclaration = createVariableDeclaration(name, loftCall)
|
||||
modifiedAst.body.push(loftDeclaration)
|
||||
const pathToLoftArg: PathToNode = [
|
||||
['body', ''],
|
||||
[sketchIndexInBody + 1, 'index'],
|
||||
[modifiedAst.body.length - 1, 'index'],
|
||||
['declarations', 'VariableDeclaration'],
|
||||
[0, 'index'],
|
||||
['0', 'index'],
|
||||
['init', 'VariableDeclarator'],
|
||||
['arguments', 'CallExpression'],
|
||||
[0, 'index'],
|
||||
]
|
||||
|
||||
return {
|
||||
modifiedAst: _node,
|
||||
modifiedAst,
|
||||
pathToLoftArg,
|
||||
}
|
||||
}
|
||||
|
@ -564,12 +564,9 @@ export function canSweepSelection(selection: Selections) {
|
||||
}
|
||||
|
||||
export function canLoftSelection(selection: Selections) {
|
||||
console.log('selection', selection)
|
||||
const commonNodes = selection.graphSelections.map((_, i) =>
|
||||
buildCommonNodeFromSelection(selection, i)
|
||||
)
|
||||
console.log('commonNodes', commonNodes)
|
||||
console.log('isSketchPipe', isSketchPipe(selection))
|
||||
return (
|
||||
!!isCursorInSketchCommandRange(
|
||||
engineCommandManager.artifactGraph,
|
||||
|
Reference in New Issue
Block a user