Remove deprecated syntax (#6561)

* Remove deprecated syntax

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* fix one test

* fix sketch on revolved face test

* fix test: empty-scene default-planes act as expected

* fix up more tests

* another fix

* remove another const

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
This commit is contained in:
Nick Cameron
2025-04-30 13:12:40 +12:00
committed by GitHub
parent 29b8a442c2
commit 0ea0d1703e
127 changed files with 2092 additions and 2359 deletions

View File

@ -1,6 +1,9 @@
import type { Page } from '@playwright/test'
import type { HomePageFixture } from '@e2e/playwright/fixtures/homePageFixture'
import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
import type { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
import type { EditorFixture } from '@e2e/playwright/fixtures/editorFixture'
import {
PERSIST_MODELING_CONTEXT,
TEST_COLORS,
@ -13,14 +16,21 @@ test.setTimeout(120000)
async function doBasicSketch(
page: Page,
homePage: HomePageFixture,
openPanes: string[]
openPanes: string[],
fixtures: {
homePage: HomePageFixture
cmdBar: CmdBarFixture
scene: SceneFixture
editor: EditorFixture
}
) {
const { cmdBar, scene, homePage, editor } = fixtures
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1200, height: 500 })
const PUR = 400 / 37.5 //pixeltoUnitRatio
await homePage.goToModelingScene()
await scene.settled(cmdBar)
await u.waitForPageLoad()
await page.waitForTimeout(1000)
await u.openDebugPanel()
@ -51,7 +61,13 @@ async function doBasicSketch(
}
await u.closeDebugPanel()
await page.waitForTimeout(1000) // TODO detect animation ending, or disable animation
// wait for line button to have aria-pressed as proxy for sketch mode
await expect
.poll(async () => page.getByTestId('line').getAttribute('aria-pressed'), {
timeout: 10_000,
})
.toBe('true')
await page.waitForTimeout(200)
const startXPx = 600
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
@ -144,22 +160,35 @@ async function doBasicSketch(
// Open the code pane.
await u.openKclCodePanel()
await expect(
u.codeLocator
).toHaveText(`@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfile(sketch001, at = ${
commonPoints.startAt
})
await editor.expectEditor.toContain(
`@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfile(sketch001, at = ${
commonPoints.startAt
})
|> xLine(length = ${commonPoints.num1}, tag = $seg01)
|> yLine(length = ${commonPoints.num1 + 0.01})
|> xLine(length = -segLen(seg01))`)
|> xLine(length = -segLen(seg01))`,
{ shouldNormalise: true }
)
}
test.describe('Basic sketch', () => {
test('code pane open at start', async ({ page, homePage }) => {
await doBasicSketch(page, homePage, ['code'])
test('code pane open at start', async ({
page,
homePage,
cmdBar,
scene,
editor,
}) => {
await doBasicSketch(page, ['code'], { cmdBar, scene, homePage, editor })
})
test('code pane closed at start', async ({ page, homePage }) => {
test('code pane closed at start', async ({
page,
homePage,
cmdBar,
scene,
editor,
}) => {
// Load the app with the code panes
await page.addInitScript(async (persistModelingContext) => {
localStorage.setItem(
@ -167,6 +196,6 @@ test.describe('Basic sketch', () => {
JSON.stringify({ openPanes: [] })
)
}, PERSIST_MODELING_CONTEXT)
await doBasicSketch(page, homePage, [])
await doBasicSketch(page, [], { cmdBar, scene, homePage, editor })
})
})

View File

@ -151,7 +151,7 @@ sketch001 = startSketchOn(XY)
await page.keyboard.press('End')
await page.keyboard.press('Enter')
await page.keyboard.press('Enter')
await page.keyboard.type('const x = 1')
await page.keyboard.type('x = 1')
await page.keyboard.press('Enter')
await u.openDebugPanel()
@ -828,7 +828,7 @@ a1 = startSketchOn(offsetPlane(XY, offset = 10))
height = 0.500
dia = 4
fn squareHole = (l, w) => {
fn squareHole(l, w) {
squareHoleSketch = startSketchOn(XY)
|> startProfile(at = [-width / 2, -length / 2])
|> line(endAbsolute = [width / 2, -length / 2])
@ -870,7 +870,7 @@ a1 = startSketchOn(offsetPlane(XY, offset = 10))
await page.keyboard.press('ArrowDown')
await page.keyboard.press('Enter')
await page.keyboard.type(`extrusion = startSketchOn(XY)
|> circle(center: [0, 0], radius: dia/2)
|> circle(center = [0, 0], radius = dia/2)
|> subtract2d(tool = squareHole(length, width, height))
|> extrude(length = height)`)

View File

@ -228,9 +228,11 @@ export class SceneFixture {
}
connectionEstablished = async () => {
const timeout = 30000
await expect(this.networkToggleConnected).toBeVisible({ timeout })
await expect(this.engineConnectionsSpinner).not.toBeVisible()
const timeout = 30_000
await Promise.all([
expect(this.networkToggleConnected).toBeVisible({ timeout }),
expect(this.engineConnectionsSpinner).not.toBeVisible({ timeout }),
])
}
settled = async (cmdBar: CmdBarFixture) => {

View File

@ -1449,7 +1449,7 @@ test(
'@settings(defaultLengthUnit = in)'
)
await page.locator('.cm-content').fill(`sketch001 = startSketchOn('XZ')
await page.locator('.cm-content').fill(`sketch001 = startSketchOn(XZ)
|> startProfile(at = [-87.4, 282.92])
|> line(end = [324.07, 27.199], tag = $seg01)
|> line(end = [118.328, -291.754])

View File

@ -327,14 +327,15 @@ extrude002 = extrude(profile002, length = 150)
)
const websocketPromise = page.waitForEvent('websocket')
await page.setBodyDimensions({ width: 500, height: 500 })
await toolbar.closePane('code')
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
const websocket = await websocketPromise
await scene.connectionEstablished()
await scene.settled(cmdBar)
await toolbar.closePane('code')
await page.setBodyDimensions({ width: 500, height: 500 })
// expect pixel color to be background color
const offModelBefore = { x: 446, y: 250 }

View File

@ -1085,6 +1085,9 @@ profile001 = startProfile(sketch001, at = [${roundOff(scale * 69.6)}, ${roundOff
test('empty-scene default-planes act as expected', async ({
page,
homePage,
scene,
cmdBar,
editor,
}) => {
/**
* Tests the following things
@ -1099,6 +1102,7 @@ profile001 = startProfile(sketch001, at = [${roundOff(scale * 69.6)}, ${roundOff
const u = await getUtils(page)
await homePage.goToModelingScene()
await scene.settled(cmdBar)
await u.openDebugPanel()
await u.expectCmdLog('[data-message-type="execution-done"]')
@ -1154,25 +1158,36 @@ profile001 = startProfile(sketch001, at = [${roundOff(scale * 69.6)}, ${roundOff
.toBeLessThan(8)
await page.mouse.click(XYPlanePoint.x, XYPlanePoint.y)
await page.waitForTimeout(600)
// wait for line button to have aria-pressed as proxy for sketch mode
await expect
.poll(async () => page.getByTestId('line').getAttribute('aria-pressed'), {
timeout: 10_000,
})
.toBe('true')
await page.waitForTimeout(200)
await page.mouse.click(XYPlanePoint.x, XYPlanePoint.y)
await page.waitForTimeout(200)
await page.mouse.click(XYPlanePoint.x + 50, XYPlanePoint.y + 50)
await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn(XZ)
|> startProfile(at = [11.8, 9.09])
|> line(end = [3.39, -3.39])
`)
await editor.expectEditor.toContain(
`sketch001 = startSketchOn(XZ)
profile001 = startProfile(sketch001, at = [299.72, 230.82])
|> line(end = [86.12, -86.13])
`,
{ shouldNormalise: true }
)
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`sketch001 = startSketchOn(XZ)
|> startProfile(at = [11.8, 9.09])
|> line(end = [3.39, -3.39])
profile001 = startProfile(sketch001, at = [299.72, 230.82])
|> line(end = [86.12, -86.13])
`
)
})
await scene.settled(cmdBar)
await u.openDebugPanel()
await u.expectCmdLog('[data-message-type="execution-done"]')
@ -1195,7 +1210,7 @@ profile001 = startProfile(sketch001, at = [${roundOff(scale * 69.6)}, ${roundOff
lugDiameter = 0.5
lugLength = 2
fn lug = (origin, length, diameter, plane) => {
fn lug(origin, length, diameter, plane) {
lugSketch = startSketchOn(plane)
|> startProfile(at = [origin[0] + lugDiameter / 2, origin[1]])
|> angledLine(angle = 60, lengthY = lugHeadLength)

View File

@ -1126,7 +1126,7 @@ test.describe('Electron constraint tests', () => {
await fsp.writeFile(
path.join(bracketDir, 'main.kcl'),
`@settings(defaultLengthUnit = in)
const part001 = startSketchOn(XY)
part001 = startSketchOn(XY)
|> startProfile(at = [4.83, 12.56])
|> line(end = [15.1, 2.48])
|> line(end = [3.15, -9.85], tag = $seg01)

View File

@ -257,13 +257,13 @@ test.describe(`Testing gizmo, fixture-based`, () => {
localStorage.setItem(
'persistCode',
`@settings(defaultLengthUnit = in)
const sketch002 = startSketchOn(XZ)
sketch002 = startSketchOn(XZ)
|> startProfile(at = [-108.83, -57.48])
|> angledLine(angle = 0, length = 105.13, tag = $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 77.9)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001))
|> close()
const sketch001 = startSketchOn(XZ)
sketch001 = startSketchOn(XZ)
|> circle(center = [818.33, 168.1], radius = 182.8)
|> extrude(length = 50)
`

View File

@ -1130,7 +1130,7 @@ part001 = startSketchOn(XZ)
|> line(end = [-20.38, -10.12])
|> line(end = [-15.79, 17.08])
fn yohey = (pos) => {
fn yohey(pos) {
sketch004 = startSketchOn(XZ)
${extrudeAndEditBlockedInFunction}
|> line(end = [27.55, -1.65])