Skip to content

Commit eb93d95

Browse files
committed
Update "delete all profiles" test to not draw the initial sketch
Tested against main, so this is eligible for a breakout PR if we want. Revealed a gotcha with sketch mode state after direct code modifications.
1 parent f76c05e commit eb93d95

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

e2e/playwright/sketch-tests.spec.ts

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,49 +1845,53 @@ tangentialArc(end = [-10.82, 144.95])`
18451845
scene,
18461846
toolbar,
18471847
editor,
1848+
cmdBar,
18481849
page,
18491850
homePage,
18501851
}) => {
1851-
await page.setBodyDimensions({ width: 1000, height: 500 })
1852-
await homePage.goToModelingScene()
1853-
await scene.connectionEstablished()
1854-
await expect(
1855-
page.getByRole('button', { name: 'Start Sketch' })
1856-
).not.toBeDisabled()
1857-
1858-
const [selectXZPlane] = scene.makeMouseHelpers(650, 150)
1859-
1860-
await toolbar.startSketchPlaneSelection()
1861-
await selectXZPlane()
1862-
// timeout wait for engine animation is unavoidable
1863-
await page.waitForTimeout(600)
1864-
await editor.expectEditor.toContain(`sketch001 = startSketchOn(XZ)`)
1865-
1866-
const [startProfile1] = scene.makeMouseHelpers(568, 110)
1867-
const [segment1Clk] = scene.makeMouseHelpers(701, 118)
1868-
const [segment2Clk] = scene.makeMouseHelpers(745, 189)
1869-
1870-
await test.step('add two segments', async () => {
1871-
await startProfile1()
1872-
await editor.expectEditor.toContain(
1873-
`profile001 = startProfile(sketch001, at = [4.61, 9.49])`
1852+
await page.addInitScript(async () => {
1853+
localStorage.setItem(
1854+
'persistCode',
1855+
`sketch001 = startSketchOn(XZ)
1856+
profile001 = startProfile(sketch001, at=[0, 0])
1857+
|> angledLine(angle=45deg, length=1in)
1858+
|> angledLine(angle=180deg, length=0.5in)
1859+
`
18741860
)
1875-
await segment1Clk()
1876-
await editor.expectEditor.toContain(`|> line(end`)
1877-
await segment2Clk()
1878-
await editor.expectEditor.toContain(`|> line(end = [2.98, -4.81])`)
18791861
})
1862+
await homePage.goToModelingScene()
1863+
await scene.settled(cmdBar)
1864+
await toolbar.editSketch(0)
18801865

18811866
await test.step('delete all profiles', async () => {
18821867
await editor.replaceCode('', 'sketch001 = startSketchOn(XZ)\n')
1883-
await page.waitForTimeout(600) // wait for deferred execution
1868+
})
1869+
1870+
await test.step('wait for execution', async () => {
1871+
// TODO: there is a gap between deleting the code and the re-execution during which
1872+
// there seems to be no signal to the system that we are in a "dirty" state awaiting re-execution.
1873+
// Need a better signal to the system (and by extension Playwright) that a re-execution is coming,
1874+
// because if the user (or test) equips a new tool and draws with it in this state, the tool will
1875+
// be unequipped and the code will be half-reset when execution completes.
1876+
await expect(toolbar.exitSketchBtn).toBeDisabled()
1877+
await expect(toolbar.exitSketchBtn).toBeEnabled()
18841878
})
18851879

18861880
await test.step('equip circle and draw it', async () => {
18871881
await toolbar.circleBtn.click()
1888-
await page.mouse.click(700, 200)
1889-
await page.mouse.click(750, 200)
1890-
await editor.expectEditor.toContain('circle(sketch001, center = [')
1882+
const [circleCenterClick] = scene.makeMouseHelpers(0.5, 0.5, {
1883+
format: 'ratio',
1884+
})
1885+
const [circlePerimeterClick] = scene.makeMouseHelpers(0.75, 0.75, {
1886+
format: 'ratio',
1887+
})
1888+
await expect(toolbar.circleBtn).toHaveAttribute('aria-pressed', 'true')
1889+
await circleCenterClick()
1890+
await circlePerimeterClick()
1891+
await editor.expectEditor.not.toContain('profile001 = angledLine(')
1892+
await editor.expectEditor.toContain(
1893+
'profile001 = circle(sketch001, center = ['
1894+
)
18911895
})
18921896
})
18931897
test('Can add multiple profiles to a sketch (all tool types)', async ({

0 commit comments

Comments
 (0)