Skip to content

Commit

Permalink
chore: implemented web playwright test to catch this regression (#3982)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadr0 authored Oct 4, 2024
1 parent 074c285 commit bcf2572
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions e2e/playwright/sketch-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,102 @@ sketch002 = startSketchOn(extrude001, 'END')
).toHaveAttribute('aria-pressed', 'true')
}).toPass({ timeout: 40_000, intervals: [1_000] })
})

test('Can sketch on face when user defined function was used in the sketch', async ({
page,
}) => {
const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 })

// Checking for a regression that performs a sketch when a user defined function
// is declared at the top of the file and used in the sketch that is being drawn on.
// fn in2mm is declared at the top of the file and used rail which does a an extrusion with the function.

await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`fn in2mm = (inches) => {
return inches * 25.4
}
const railTop = in2mm(.748)
const railSide = in2mm(.024)
const railBaseWidth = in2mm(.612)
const railWideWidth = in2mm(.835)
const railBaseLength = in2mm(.200)
const railClampable = in2mm(.200)
const rail = startSketchOn('XZ')
|> startProfileAt([
-railTop / 2,
railClampable + railBaseLength
], %)
|> lineTo([
railTop / 2,
railClampable + railBaseLength
], %)
|> lineTo([
railWideWidth / 2,
railClampable / 2 + railBaseLength
], %, $seg01)
|> lineTo([railTop / 2, railBaseLength], %)
|> lineTo([railBaseWidth / 2, railBaseLength], %)
|> lineTo([railBaseWidth / 2, 0], %)
|> lineTo([-railBaseWidth / 2, 0], %)
|> lineTo([-railBaseWidth / 2, railBaseLength], %)
|> lineTo([-railTop / 2, railBaseLength], %)
|> lineTo([
-railWideWidth / 2,
railClampable / 2 + railBaseLength
], %)
|> lineTo([
-railTop / 2,
railClampable + railBaseLength
], %)
|> close(%)
|> extrude(in2mm(2), %)`
)
})

const center = { x: 600, y: 250 }
const rectangleSize = 20
await u.waitForAuthSkipAppStart()

// Start a sketch
await page.getByRole('button', { name: 'Start Sketch' }).click()

// Click the top face of this rail
await page.mouse.click(center.x, center.y)
await page.waitForTimeout(1000)

// Draw a rectangle
// top left
await page.mouse.click(center.x - rectangleSize, center.y - rectangleSize)
await page.waitForTimeout(250)
// top right
await page.mouse.click(center.x + rectangleSize, center.y - rectangleSize)
await page.waitForTimeout(250)

// bottom right
await page.mouse.click(center.x + rectangleSize, center.y + rectangleSize)
await page.waitForTimeout(250)

// bottom left
await page.mouse.click(center.x - rectangleSize, center.y + rectangleSize)
await page.waitForTimeout(250)

// top left
await page.mouse.click(center.x - rectangleSize, center.y - rectangleSize)
await page.waitForTimeout(250)

// exit sketch
await page.getByRole('button', { name: 'Exit Sketch' }).click()

// Check execution is done
await u.openDebugPanel()
await u.expectCmdLog('[data-message-type="execution-done"]')
await u.closeDebugPanel()
})
})

test2.describe('Sketch mode should be toleratant to syntax errors', () => {
Expand Down

0 comments on commit bcf2572

Please sign in to comment.