Add rectangle based sweep test case

This commit is contained in:
Pierre Jacquier
2025-03-20 11:55:17 -04:00
parent f9b2750356
commit f94cc40fcc

View File

@ -1333,7 +1333,41 @@ loft001 = loft([sketch001, sketch002])
})
})
test(`Sweep point-and-click base`, async ({
const sweepCases = [
{
targetType: 'circle',
testPoint: { x: 700, y: 250 },
initialCode: `sketch001 = startSketchOn('YZ')
profile001 = circle(sketch001, center = [0, 0], radius = 500)
sketch002 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> xLine(length = -500)
|> tangentialArcTo([-2000, 500], %)`,
},
{
targetType: 'rectangle',
testPoint: { x: 710, y: 255 },
initialCode: `sketch001 = startSketchOn('YZ')
profile001 = startProfileAt([-400, -400], sketch001)
|> angledLine([0, 800], %, $rectangleSegmentA001)
|> angledLine([
segAng(rectangleSegmentA001) + 90,
800
], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
sketch002 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> xLine(length = -500)
|> tangentialArcTo([-2000, 500], %)`,
},
]
sweepCases.map(({ initialCode, targetType, testPoint }) => {
test(`Sweep point-and-click ${targetType}`, async ({
context,
page,
homePage,
@ -1342,16 +1376,6 @@ loft001 = loft([sketch001, sketch002])
toolbar,
cmdBar,
}) => {
const initialCode = `sketch001 = startSketchOn('YZ')
|> circle(
center = [0, 0],
radius = 500
)
sketch002 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> xLine(length = -500)
|> tangentialArcTo([-2000, 500], %)
`
await context.addInitScript((initialCode) => {
localStorage.setItem('persistCode', initialCode)
}, initialCode)
@ -1360,16 +1384,15 @@ sketch002 = startSketchOn('XZ')
await scene.waitForExecutionDone()
// One dumb hardcoded screen pixel value
const testPoint = { x: 700, y: 250 }
const [clickOnSketch1] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
const [clickOnSketch2] = scene.makeMouseHelpers(
testPoint.x - 50,
testPoint.y
)
const sweepDeclaration =
'sweep001 = sweep(sketch001, path = sketch002, sectional = false)'
'sweep001 = sweep(profile001, path = sketch002, sectional = false)'
const editedSweepDeclaration =
'sweep001 = sweep(sketch001, path = sketch002, sectional = true)'
'sweep001 = sweep(profile001, path = sketch002, sectional = true)'
await test.step(`Look for sketch001`, async () => {
await toolbar.closePane('code')
@ -1421,12 +1444,16 @@ sketch002 = startSketchOn('XZ')
await test.step(`Confirm code is added to the editor, scene has changed`, async () => {
await toolbar.openPane('code')
await editor.expectEditor.toContain(sweepDeclaration)
await scene.expectPixelColor([120, 120, 120], testPoint, 40)
await toolbar.closePane('code')
})
await test.step('Edit sweep via feature tree selection works', async () => {
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 cmdBar.expectState({
commandName: 'Sweep',
@ -1456,7 +1483,10 @@ sketch002 = startSketchOn('XZ')
await test.step('Delete sweep via feature tree selection', async () => {
await toolbar.openPane('feature-tree')
await page.waitForTimeout(500)
const operationButton = await toolbar.getFeatureTreeOperation('Sweep', 0)
const operationButton = await toolbar.getFeatureTreeOperation(
'Sweep',
0
)
await operationButton.click({ button: 'left' })
await page.keyboard.press('Delete')
await page.waitForTimeout(500)
@ -1464,6 +1494,7 @@ sketch002 = startSketchOn('XZ')
await scene.expectPixelColor([53, 53, 53], testPoint, 15)
})
})
})
test(`Sweep point-and-click failing validation`, async ({
context,