fix no profile errors (#5877)

* fix no profile errors

* add test and tweak a couple things

* quick fix

* fix animation

* add another test

* Use actor.getSnapshot in the debug function

So we don't have to rebuild that listener every time that the state
changes.

* try fix tests

---------

Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
This commit is contained in:
Kurt Hutten
2025-03-20 08:30:11 +11:00
committed by GitHub
parent e7d00f148b
commit 4b6166dc4f
9 changed files with 195 additions and 31 deletions

View File

@ -1662,6 +1662,96 @@ profile003 = startProfileAt([206.63, -56.73], sketch001)
})
}
)
test('can enter sketch mode for sketch with no profiles', async ({
scene,
toolbar,
editor,
cmdBar,
page,
homePage,
}) => {
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`sketch001 = startSketchOn('XY')
`
)
})
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await scene.connectionEstablished()
await scene.settled(cmdBar)
await expect(
page.getByRole('button', { name: 'Start Sketch' })
).not.toBeDisabled()
// open feature tree and double click the first sketch
await (await toolbar.getFeatureTreeOperation('Sketch', 0)).dblclick()
await page.waitForTimeout(600)
// click in the scene twice to add a segment
const [startProfile1] = scene.makeMouseHelpers(658, 140)
const [segment1Clk] = scene.makeMouseHelpers(701, 200)
// wait for line to be aria pressed
await expect
.poll(async () => toolbar.lineBtn.getAttribute('aria-pressed'))
.toBe('true')
await startProfile1()
await editor.expectEditor.toContain(`profile001 = startProfileAt`)
await segment1Clk()
await editor.expectEditor.toContain(`|> line(end`)
})
test('can delete all profiles in sketch mode and user can still equip a tool and draw something', async ({
scene,
toolbar,
editor,
page,
homePage,
}) => {
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await scene.connectionEstablished()
await expect(
page.getByRole('button', { name: 'Start Sketch' })
).not.toBeDisabled()
const [selectXZPlane] = scene.makeMouseHelpers(650, 150)
await toolbar.startSketchPlaneSelection()
await selectXZPlane()
// timeout wait for engine animation is unavoidable
await page.waitForTimeout(600)
await editor.expectEditor.toContain(`sketch001 = startSketchOn('XZ')`)
const [startProfile1] = scene.makeMouseHelpers(568, 70)
const [segment1Clk] = scene.makeMouseHelpers(701, 78)
const [segment2Clk] = scene.makeMouseHelpers(745, 189)
await test.step('add two segments', async () => {
await startProfile1()
await editor.expectEditor.toContain(
`profile001 = startProfileAt([4.61, 12.21], sketch001)`
)
await segment1Clk()
await editor.expectEditor.toContain(`|> line(end`)
await segment2Clk()
await editor.expectEditor.toContain(`|> line(end = [2.98, -7.52])`)
})
await test.step('delete all profiles', async () => {
await editor.replaceCode('', "sketch001 = startSketchOn('XZ')\n")
await page.waitForTimeout(600) // wait for deferred execution
})
await test.step('equip circle and draw it', async () => {
await toolbar.circleBtn.click()
await page.mouse.click(700, 200)
await page.mouse.click(750, 200)
await editor.expectEditor.toContain('circle(sketch001, center = [')
})
})
test('Can add multiple profiles to a sketch (all tool types)', async ({
scene,
toolbar,