@@ -1845,49 +1845,53 @@ tangentialArc(end = [-10.82, 144.95])`
1845
1845
scene,
1846
1846
toolbar,
1847
1847
editor,
1848
+ cmdBar,
1848
1849
page,
1849
1850
homePage,
1850
1851
} ) => {
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
+ `
1874
1860
)
1875
- await segment1Clk ( )
1876
- await editor . expectEditor . toContain ( `|> line(end` )
1877
- await segment2Clk ( )
1878
- await editor . expectEditor . toContain ( `|> line(end = [2.98, -4.81])` )
1879
1861
} )
1862
+ await homePage . goToModelingScene ( )
1863
+ await scene . settled ( cmdBar )
1864
+ await toolbar . editSketch ( 0 )
1880
1865
1881
1866
await test . step ( 'delete all profiles' , async ( ) => {
1882
1867
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 ( )
1884
1878
} )
1885
1879
1886
1880
await test . step ( 'equip circle and draw it' , async ( ) => {
1887
1881
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
+ )
1891
1895
} )
1892
1896
} )
1893
1897
test ( 'Can add multiple profiles to a sketch (all tool types)' , async ( {
0 commit comments