@ -2761,37 +2761,51 @@ const part002 = startSketchOn('XZ')
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
test.describe('Test Angle constraint single selection', () => {
|
test.describe('Test Angle/Length constraint single selection', () => {
|
||||||
const cases = [
|
const cases = [
|
||||||
{
|
{
|
||||||
testName: 'Add variable',
|
testName: 'Angle - Add variable',
|
||||||
addVariable: true,
|
addVariable: true,
|
||||||
value: 'angle001',
|
constraint: 'angle',
|
||||||
|
value: 'angle001, 78.33',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: 'No variable',
|
testName: 'Angle - No variable',
|
||||||
addVariable: false,
|
addVariable: false,
|
||||||
value: '83',
|
constraint: 'angle',
|
||||||
|
value: '83, 78.33',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: 'Length - Add variable',
|
||||||
|
addVariable: true,
|
||||||
|
constraint: 'length',
|
||||||
|
value: '83, length001',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: 'Length - No variable',
|
||||||
|
addVariable: false,
|
||||||
|
constraint: 'length',
|
||||||
|
value: '83, 78.33',
|
||||||
},
|
},
|
||||||
] as const
|
] as const
|
||||||
for (const { testName, addVariable, value } of cases) {
|
for (const { testName, addVariable, value, constraint } of cases) {
|
||||||
test(`${testName}`, async ({ page }) => {
|
test(`${testName}`, async ({ page }) => {
|
||||||
await page.addInitScript(async () => {
|
await page.addInitScript(async () => {
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
'persistCode',
|
'persistCode',
|
||||||
`const yo = 5
|
`const yo = 5
|
||||||
const part001 = startSketchOn('XZ')
|
const part001 = startSketchOn('XZ')
|
||||||
|> startProfileAt([-7.54, -26.74], %)
|
|> startProfileAt([-7.54, -26.74], %)
|
||||||
|> line([74.36, 130.4], %)
|
|> line([74.36, 130.4], %)
|
||||||
|> line([78.92, -120.11], %)
|
|> line([78.92, -120.11], %)
|
||||||
|> line([9.16, 77.79], %)
|
|> line([9.16, 77.79], %)
|
||||||
|> line([41.19, 28.97], %)
|
|> line([41.19, 28.97], %)
|
||||||
const part002 = startSketchOn('XZ')
|
const part002 = startSketchOn('XZ')
|
||||||
|> startProfileAt([299.05, 231.45], %)
|
|> startProfileAt([299.05, 231.45], %)
|
||||||
|> xLine(-425.34, %, 'seg-what')
|
|> xLine(-425.34, %, 'seg-what')
|
||||||
|> yLine(-264.06, %)
|
|> yLine(-264.06, %)
|
||||||
|> xLine(segLen('seg-what', %), %)
|
|> xLine(segLen('seg-what', %), %)
|
||||||
|> lineTo([profileStartX(%), profileStartY(%)], %)`
|
|> lineTo([profileStartX(%), profileStartY(%)], %)`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
const u = await getUtils(page)
|
const u = await getUtils(page)
|
||||||
@ -2812,7 +2826,7 @@ const part002 = startSketchOn('XZ')
|
|||||||
name: 'Constrain',
|
name: 'Constrain',
|
||||||
})
|
})
|
||||||
.click()
|
.click()
|
||||||
await page.getByTestId('angle').click()
|
await page.getByTestId(constraint).click()
|
||||||
|
|
||||||
if (!addVariable) {
|
if (!addVariable) {
|
||||||
await page.getByTestId('create-new-variable-checkbox').click()
|
await page.getByTestId('create-new-variable-checkbox').click()
|
||||||
@ -2821,7 +2835,7 @@ const part002 = startSketchOn('XZ')
|
|||||||
.getByRole('button', { name: 'Add constraining value' })
|
.getByRole('button', { name: 'Add constraining value' })
|
||||||
.click()
|
.click()
|
||||||
|
|
||||||
const changedCode = `|> angledLine([${value}, 78.33], %)`
|
const changedCode = `|> angledLine([${value}], %)`
|
||||||
await expect(page.locator('.cm-content')).toContainText(changedCode)
|
await expect(page.locator('.cm-content')).toContainText(changedCode)
|
||||||
// checking active assures the cursor is where it should be
|
// checking active assures the cursor is where it should be
|
||||||
await expect(page.locator('.cm-activeLine')).toHaveText(changedCode)
|
await expect(page.locator('.cm-activeLine')).toHaveText(changedCode)
|
||||||
|
@ -609,10 +609,23 @@ export const ModelingMachineProvider = ({
|
|||||||
},
|
},
|
||||||
'Get length info': async ({
|
'Get length info': async ({
|
||||||
selectionRanges,
|
selectionRanges,
|
||||||
|
sketchDetails,
|
||||||
}): Promise<SetSelections> => {
|
}): Promise<SetSelections> => {
|
||||||
const { modifiedAst, pathToNodeMap } =
|
const { modifiedAst, pathToNodeMap } =
|
||||||
await applyConstraintAngleLength({ selectionRanges })
|
await applyConstraintAngleLength({ selectionRanges })
|
||||||
await kclManager.updateAst(modifiedAst, true)
|
const _modifiedAst = parse(recast(modifiedAst))
|
||||||
|
if (!sketchDetails) throw new Error('No sketch details')
|
||||||
|
const updatedPathToNode = updatePathToNodeFromMap(
|
||||||
|
sketchDetails.sketchPathToNode,
|
||||||
|
pathToNodeMap
|
||||||
|
)
|
||||||
|
await sceneEntitiesManager.updateAstAndRejigSketch(
|
||||||
|
updatedPathToNode,
|
||||||
|
_modifiedAst,
|
||||||
|
sketchDetails.zAxis,
|
||||||
|
sketchDetails.yAxis,
|
||||||
|
sketchDetails.origin
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
selectionType: 'completeSelection',
|
selectionType: 'completeSelection',
|
||||||
selection: pathMapToSelections(
|
selection: pathMapToSelections(
|
||||||
@ -620,6 +633,7 @@ export const ModelingMachineProvider = ({
|
|||||||
selectionRanges,
|
selectionRanges,
|
||||||
pathToNodeMap
|
pathToNodeMap
|
||||||
),
|
),
|
||||||
|
updatedPathToNode,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Get perpendicular distance info': async ({
|
'Get perpendicular distance info': async ({
|
||||||
|
Reference in New Issue
Block a user