Add rectangle based sweep test case
This commit is contained in:
@ -1333,135 +1333,166 @@ loft001 = loft([sketch001, sketch002])
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test(`Sweep point-and-click base`, async ({
|
const sweepCases = [
|
||||||
context,
|
{
|
||||||
page,
|
targetType: 'circle',
|
||||||
homePage,
|
testPoint: { x: 700, y: 250 },
|
||||||
scene,
|
initialCode: `sketch001 = startSketchOn('YZ')
|
||||||
editor,
|
profile001 = circle(sketch001, center = [0, 0], radius = 500)
|
||||||
toolbar,
|
|
||||||
cmdBar,
|
|
||||||
}) => {
|
|
||||||
const initialCode = `sketch001 = startSketchOn('YZ')
|
|
||||||
|> circle(
|
|
||||||
center = [0, 0],
|
|
||||||
radius = 500
|
|
||||||
)
|
|
||||||
sketch002 = startSketchOn('XZ')
|
sketch002 = startSketchOn('XZ')
|
||||||
|> startProfileAt([0, 0], %)
|
|> startProfileAt([0, 0], %)
|
||||||
|> xLine(length = -500)
|
|> xLine(length = -500)
|
||||||
|> tangentialArcTo([-2000, 500], %)
|
|> tangentialArcTo([-2000, 500], %)`,
|
||||||
`
|
},
|
||||||
await context.addInitScript((initialCode) => {
|
{
|
||||||
localStorage.setItem('persistCode', initialCode)
|
targetType: 'rectangle',
|
||||||
}, initialCode)
|
testPoint: { x: 710, y: 255 },
|
||||||
await page.setBodyDimensions({ width: 1000, height: 500 })
|
initialCode: `sketch001 = startSketchOn('YZ')
|
||||||
await homePage.goToModelingScene()
|
profile001 = startProfileAt([-400, -400], sketch001)
|
||||||
await scene.waitForExecutionDone()
|
|> 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,
|
||||||
|
scene,
|
||||||
|
editor,
|
||||||
|
toolbar,
|
||||||
|
cmdBar,
|
||||||
|
}) => {
|
||||||
|
await context.addInitScript((initialCode) => {
|
||||||
|
localStorage.setItem('persistCode', initialCode)
|
||||||
|
}, initialCode)
|
||||||
|
await page.setBodyDimensions({ width: 1000, height: 500 })
|
||||||
|
await homePage.goToModelingScene()
|
||||||
|
await scene.waitForExecutionDone()
|
||||||
|
|
||||||
// One dumb hardcoded screen pixel value
|
// One dumb hardcoded screen pixel value
|
||||||
const testPoint = { x: 700, y: 250 }
|
const [clickOnSketch1] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
|
||||||
const [clickOnSketch1] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
|
const [clickOnSketch2] = scene.makeMouseHelpers(
|
||||||
const [clickOnSketch2] = scene.makeMouseHelpers(
|
testPoint.x - 50,
|
||||||
testPoint.x - 50,
|
testPoint.y
|
||||||
testPoint.y
|
)
|
||||||
)
|
const sweepDeclaration =
|
||||||
const sweepDeclaration =
|
'sweep001 = sweep(profile001, path = sketch002, sectional = false)'
|
||||||
'sweep001 = sweep(sketch001, path = sketch002, sectional = false)'
|
const editedSweepDeclaration =
|
||||||
const editedSweepDeclaration =
|
'sweep001 = sweep(profile001, path = sketch002, sectional = true)'
|
||||||
'sweep001 = sweep(sketch001, path = sketch002, sectional = true)'
|
|
||||||
|
|
||||||
await test.step(`Look for sketch001`, async () => {
|
await test.step(`Look for sketch001`, async () => {
|
||||||
await toolbar.closePane('code')
|
await toolbar.closePane('code')
|
||||||
await scene.expectPixelColor([53, 53, 53], testPoint, 15)
|
await scene.expectPixelColor([53, 53, 53], testPoint, 15)
|
||||||
})
|
|
||||||
|
|
||||||
await test.step(`Go through the command bar flow`, async () => {
|
|
||||||
await toolbar.sweepButton.click()
|
|
||||||
await cmdBar.expectState({
|
|
||||||
commandName: 'Sweep',
|
|
||||||
currentArgKey: 'target',
|
|
||||||
currentArgValue: '',
|
|
||||||
headerArguments: {
|
|
||||||
Sectional: '',
|
|
||||||
Target: '',
|
|
||||||
Trajectory: '',
|
|
||||||
},
|
|
||||||
highlightedHeaderArg: 'target',
|
|
||||||
stage: 'arguments',
|
|
||||||
})
|
})
|
||||||
await clickOnSketch1()
|
|
||||||
await cmdBar.expectState({
|
|
||||||
commandName: 'Sweep',
|
|
||||||
currentArgKey: 'trajectory',
|
|
||||||
currentArgValue: '',
|
|
||||||
headerArguments: {
|
|
||||||
Sectional: '',
|
|
||||||
Target: '1 face',
|
|
||||||
Trajectory: '',
|
|
||||||
},
|
|
||||||
highlightedHeaderArg: 'trajectory',
|
|
||||||
stage: 'arguments',
|
|
||||||
})
|
|
||||||
await clickOnSketch2()
|
|
||||||
await page.waitForTimeout(500)
|
|
||||||
await cmdBar.progressCmdBar()
|
|
||||||
await cmdBar.expectState({
|
|
||||||
commandName: 'Sweep',
|
|
||||||
headerArguments: {
|
|
||||||
Target: '1 face',
|
|
||||||
Trajectory: '1 segment',
|
|
||||||
Sectional: '',
|
|
||||||
},
|
|
||||||
stage: 'review',
|
|
||||||
})
|
|
||||||
await cmdBar.progressCmdBar()
|
|
||||||
})
|
|
||||||
|
|
||||||
await test.step(`Confirm code is added to the editor, scene has changed`, async () => {
|
await test.step(`Go through the command bar flow`, async () => {
|
||||||
await toolbar.openPane('code')
|
await toolbar.sweepButton.click()
|
||||||
await editor.expectEditor.toContain(sweepDeclaration)
|
await cmdBar.expectState({
|
||||||
await toolbar.closePane('code')
|
commandName: 'Sweep',
|
||||||
})
|
currentArgKey: 'target',
|
||||||
|
currentArgValue: '',
|
||||||
await test.step('Edit sweep via feature tree selection works', async () => {
|
headerArguments: {
|
||||||
await toolbar.openPane('feature-tree')
|
Sectional: '',
|
||||||
const operationButton = await toolbar.getFeatureTreeOperation('Sweep', 0)
|
Target: '',
|
||||||
await operationButton.dblclick({ button: 'left' })
|
Trajectory: '',
|
||||||
await cmdBar.expectState({
|
},
|
||||||
commandName: 'Sweep',
|
highlightedHeaderArg: 'target',
|
||||||
currentArgKey: 'sectional',
|
stage: 'arguments',
|
||||||
currentArgValue: '',
|
})
|
||||||
headerArguments: {
|
await clickOnSketch1()
|
||||||
Sectional: '',
|
await cmdBar.expectState({
|
||||||
},
|
commandName: 'Sweep',
|
||||||
highlightedHeaderArg: 'sectional',
|
currentArgKey: 'trajectory',
|
||||||
stage: 'arguments',
|
currentArgValue: '',
|
||||||
|
headerArguments: {
|
||||||
|
Sectional: '',
|
||||||
|
Target: '1 face',
|
||||||
|
Trajectory: '',
|
||||||
|
},
|
||||||
|
highlightedHeaderArg: 'trajectory',
|
||||||
|
stage: 'arguments',
|
||||||
|
})
|
||||||
|
await clickOnSketch2()
|
||||||
|
await page.waitForTimeout(500)
|
||||||
|
await cmdBar.progressCmdBar()
|
||||||
|
await cmdBar.expectState({
|
||||||
|
commandName: 'Sweep',
|
||||||
|
headerArguments: {
|
||||||
|
Target: '1 face',
|
||||||
|
Trajectory: '1 segment',
|
||||||
|
Sectional: '',
|
||||||
|
},
|
||||||
|
stage: 'review',
|
||||||
|
})
|
||||||
|
await cmdBar.progressCmdBar()
|
||||||
})
|
})
|
||||||
await cmdBar.selectOption({ name: 'True' }).click()
|
|
||||||
await cmdBar.expectState({
|
|
||||||
commandName: 'Sweep',
|
|
||||||
headerArguments: {
|
|
||||||
Sectional: '',
|
|
||||||
},
|
|
||||||
stage: 'review',
|
|
||||||
})
|
|
||||||
await cmdBar.progressCmdBar()
|
|
||||||
await toolbar.closePane('feature-tree')
|
|
||||||
await toolbar.openPane('code')
|
|
||||||
await editor.expectEditor.toContain(editedSweepDeclaration)
|
|
||||||
await toolbar.closePane('code')
|
|
||||||
})
|
|
||||||
|
|
||||||
await test.step('Delete sweep via feature tree selection', async () => {
|
await test.step(`Confirm code is added to the editor, scene has changed`, async () => {
|
||||||
await toolbar.openPane('feature-tree')
|
await toolbar.openPane('code')
|
||||||
await page.waitForTimeout(500)
|
await editor.expectEditor.toContain(sweepDeclaration)
|
||||||
const operationButton = await toolbar.getFeatureTreeOperation('Sweep', 0)
|
await scene.expectPixelColor([120, 120, 120], testPoint, 40)
|
||||||
await operationButton.click({ button: 'left' })
|
await toolbar.closePane('code')
|
||||||
await page.keyboard.press('Delete')
|
})
|
||||||
await page.waitForTimeout(500)
|
|
||||||
await toolbar.closePane('feature-tree')
|
await test.step('Edit sweep via feature tree selection works', async () => {
|
||||||
await scene.expectPixelColor([53, 53, 53], testPoint, 15)
|
await toolbar.openPane('feature-tree')
|
||||||
|
const operationButton = await toolbar.getFeatureTreeOperation(
|
||||||
|
'Sweep',
|
||||||
|
0
|
||||||
|
)
|
||||||
|
await operationButton.dblclick({ button: 'left' })
|
||||||
|
await cmdBar.expectState({
|
||||||
|
commandName: 'Sweep',
|
||||||
|
currentArgKey: 'sectional',
|
||||||
|
currentArgValue: '',
|
||||||
|
headerArguments: {
|
||||||
|
Sectional: '',
|
||||||
|
},
|
||||||
|
highlightedHeaderArg: 'sectional',
|
||||||
|
stage: 'arguments',
|
||||||
|
})
|
||||||
|
await cmdBar.selectOption({ name: 'True' }).click()
|
||||||
|
await cmdBar.expectState({
|
||||||
|
commandName: 'Sweep',
|
||||||
|
headerArguments: {
|
||||||
|
Sectional: '',
|
||||||
|
},
|
||||||
|
stage: 'review',
|
||||||
|
})
|
||||||
|
await cmdBar.progressCmdBar()
|
||||||
|
await toolbar.closePane('feature-tree')
|
||||||
|
await toolbar.openPane('code')
|
||||||
|
await editor.expectEditor.toContain(editedSweepDeclaration)
|
||||||
|
await toolbar.closePane('code')
|
||||||
|
})
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
await operationButton.click({ button: 'left' })
|
||||||
|
await page.keyboard.press('Delete')
|
||||||
|
await page.waitForTimeout(500)
|
||||||
|
await toolbar.closePane('feature-tree')
|
||||||
|
await scene.expectPixelColor([53, 53, 53], testPoint, 15)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user