Fix a ton of syntax changes and deflake 2 more tests (pain)

This commit is contained in:
49lf
2024-12-03 20:03:54 -05:00
parent d9c081611f
commit 449cbb868f
8 changed files with 164 additions and 117 deletions

View File

@ -92,6 +92,9 @@ export class AuthenticatedTronApp {
this.electronApp = electronApp this.electronApp = electronApp
this.dir = dir this.dir = dir
// Easier to access throughout utils
this.page.dir = dir
// Setup localStorage, addCookies, reload // Setup localStorage, addCookies, reload
await setup(this.context, this.page, this.testInfo) await setup(this.context, this.page, this.testInfo)

View File

@ -3,10 +3,10 @@
// It also tests our test wrappers are working. // It also tests our test wrappers are working.
// Additionally this serves as a nice minimal example. // Additionally this serves as a nice minimal example.
import { test as testZoo, expect } from './fixtures/fixtureSetup' import { test, expect } from './zoo-test'
testZoo.describe('Open the application', () => { test.describe('Open the application', () => {
testZoo('see the project view', async ({ tronApp: { page, context } }) => { test('see the project view', async ({ page, context }) => {
await expect(page.getByTestId('home-section')).toBeVisible() await expect(page.getByTestId('home-section')).toBeVisible()
}) })
}) })

View File

@ -4,6 +4,7 @@ import { SceneFixture } from './fixtures/sceneFixture'
import { ToolbarFixture } from './fixtures/toolbarFixture' import { ToolbarFixture } from './fixtures/toolbarFixture'
import fs from 'node:fs/promises' import fs from 'node:fs/promises'
import path from 'node:path' import path from 'node:path'
import { getUtils } from './test-utils'
// test file is for testing point an click code gen functionality that's not sketch mode related // test file is for testing point an click code gen functionality that's not sketch mode related
@ -38,7 +39,7 @@ test('verify extruding circle works', async ({
await test.step('check code model connection works and that button is still enable once circle is selected ', async () => { await test.step('check code model connection works and that button is still enable once circle is selected ', async () => {
await moveToCircle() await moveToCircle()
const circleSnippet = const circleSnippet =
'circle({ center: [318.33, 168.1], radius: 182.8 }, %)' 'circle({ center = [318.33, 168.1], radius = 182.8 }, %)'
await editor.expectState({ await editor.expectState({
activeLines: ["constsketch002=startSketchOn('XZ')"], activeLines: ["constsketch002=startSketchOn('XZ')"],
highlightedCode: circleSnippet, highlightedCode: circleSnippet,
@ -213,7 +214,7 @@ test.describe('verify sketch on chamfer works', () => {
]}, %)`, ]}, %)`,
afterChamferSelectSnippet: 'sketch002 = startSketchOn(extrude001, seg03)', afterChamferSelectSnippet: 'sketch002 = startSketchOn(extrude001, seg03)',
afterRectangle1stClickSnippet: 'startProfileAt([160.39, 254.59], %)', afterRectangle1stClickSnippet: 'startProfileAt([205.96, 254.59], %)',
afterRectangle2ndClickSnippet: `angledLine([0, 11.39], %, $rectangleSegmentA002) afterRectangle2ndClickSnippet: `angledLine([0, 11.39], %, $rectangleSegmentA002)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA002) - 90, segAng(rectangleSegmentA002) - 90,
@ -244,7 +245,7 @@ test.describe('verify sketch on chamfer works', () => {
}, %)`, }, %)`,
afterChamferSelectSnippet: 'sketch003 = startSketchOn(extrude001, seg04)', afterChamferSelectSnippet: 'sketch003 = startSketchOn(extrude001, seg04)',
afterRectangle1stClickSnippet: 'startProfileAt([-255.89, 255.28], %)', afterRectangle1stClickSnippet: 'startProfileAt([-209.64, 255.28], %)',
afterRectangle2ndClickSnippet: `angledLine([0, 11.56], %, $rectangleSegmentA003) afterRectangle2ndClickSnippet: `angledLine([0, 11.56], %, $rectangleSegmentA003)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA003) - 90, segAng(rectangleSegmentA003) - 90,
@ -269,7 +270,7 @@ test.describe('verify sketch on chamfer works', () => {
] ]
}, %)`, }, %)`,
afterChamferSelectSnippet: 'sketch003 = startSketchOn(extrude001, seg04)', afterChamferSelectSnippet: 'sketch003 = startSketchOn(extrude001, seg04)',
afterRectangle1stClickSnippet: 'startProfileAt([37.95, 322.96], %)', afterRectangle1stClickSnippet: 'startProfileAt([75.8, 317.2], %)',
afterRectangle2ndClickSnippet: `angledLine([0, 11.56], %, $rectangleSegmentA003) afterRectangle2ndClickSnippet: `angledLine([0, 11.56], %, $rectangleSegmentA003)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA003) - 90, segAng(rectangleSegmentA003) - 90,
@ -292,7 +293,7 @@ test.describe('verify sketch on chamfer works', () => {
tags = [getNextAdjacentEdge(yo)] tags = [getNextAdjacentEdge(yo)]
}, %)`, }, %)`,
afterChamferSelectSnippet: 'sketch005 = startSketchOn(extrude001, seg06)', afterChamferSelectSnippet: 'sketch005 = startSketchOn(extrude001, seg06)',
afterRectangle1stClickSnippet: 'startProfileAt([-59.83, 19.69], %)', afterRectangle1stClickSnippet: 'startProfileAt([-23.43, 19.69], %)',
afterRectangle2ndClickSnippet: `angledLine([0, 9.1], %, $rectangleSegmentA005) afterRectangle2ndClickSnippet: `angledLine([0, 9.1], %, $rectangleSegmentA005)
|> angledLine([ |> angledLine([
@ -338,7 +339,7 @@ test.describe('verify sketch on chamfer works', () => {
tags = [getNextAdjacentEdge(yo)] tags = [getNextAdjacentEdge(yo)]
}, %, $seg06) }, %, $seg06)
sketch005 = startSketchOn(extrude001, seg06) sketch005 = startSketchOn(extrude001, seg06)
|> startProfileAt([-59.83,19.69], %) |> startProfileAt([-23.43,19.69], %)
|> angledLine([0, 9.1], %, $rectangleSegmentA005) |> angledLine([0, 9.1], %, $rectangleSegmentA005)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA005) - 90, segAng(rectangleSegmentA005) - 90,
@ -351,7 +352,7 @@ test.describe('verify sketch on chamfer works', () => {
|> lineTo([profileStartX(%), profileStartY(%)], %) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%) |> close(%)
sketch004 = startSketchOn(extrude001, seg05) sketch004 = startSketchOn(extrude001, seg05)
|> startProfileAt([37.95,322.96], %) |> startProfileAt([82.57,322.96], %)
|> angledLine([0, 11.16], %, $rectangleSegmentA004) |> angledLine([0, 11.16], %, $rectangleSegmentA004)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA004) - 90, segAng(rectangleSegmentA004) - 90,
@ -364,7 +365,7 @@ test.describe('verify sketch on chamfer works', () => {
|> lineTo([profileStartX(%), profileStartY(%)], %) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%) |> close(%)
sketch003 = startSketchOn(extrude001, seg04) sketch003 = startSketchOn(extrude001, seg04)
|> startProfileAt([-255.89,255.28], %) |> startProfileAt([-209.64,255.28], %)
|> angledLine([0, 11.56], %, $rectangleSegmentA003) |> angledLine([0, 11.56], %, $rectangleSegmentA003)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA003) - 90, segAng(rectangleSegmentA003) - 90,
@ -377,7 +378,7 @@ test.describe('verify sketch on chamfer works', () => {
|> lineTo([profileStartX(%), profileStartY(%)], %) |> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%) |> close(%)
sketch002 = startSketchOn(extrude001, seg03) sketch002 = startSketchOn(extrude001, seg03)
|> startProfileAt([160.39,254.59], %) |> startProfileAt([205.96,254.59], %)
|> angledLine([0, 11.39], %, $rectangleSegmentA002) |> angledLine([0, 11.39], %, $rectangleSegmentA002)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA002) - 90, segAng(rectangleSegmentA002) - 90,
@ -417,6 +418,8 @@ test.describe('verify sketch on chamfer works', () => {
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
const sketchOnAChamfer = _sketchOnAChamfer(page, editor, toolbar, scene)
await sketchOnAChamfer({ await sketchOnAChamfer({
clickCoords: { x: 570, y: 220 }, clickCoords: { x: 570, y: 220 },
cameraPos: { x: 16020, y: -2000, z: 10500 }, cameraPos: { x: 16020, y: -2000, z: 10500 },
@ -430,7 +433,7 @@ test.describe('verify sketch on chamfer works', () => {
]}, extrude001)`, ]}, extrude001)`,
beforeChamferSnippetEnd: '}, extrude001)', beforeChamferSnippetEnd: '}, extrude001)',
afterChamferSelectSnippet: 'sketch002 = startSketchOn(extrude001, seg03)', afterChamferSelectSnippet: 'sketch002 = startSketchOn(extrude001, seg03)',
afterRectangle1stClickSnippet: 'startProfileAt([160.39, 254.59], %)', afterRectangle1stClickSnippet: 'startProfileAt([205.96, 254.59], %)',
afterRectangle2ndClickSnippet: `angledLine([0, 11.39], %, $rectangleSegmentA002) afterRectangle2ndClickSnippet: `angledLine([0, 11.39], %, $rectangleSegmentA002)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA002) - 90, segAng(rectangleSegmentA002) - 90,
@ -471,7 +474,7 @@ chamf = chamfer({
] ]
}, %) }, %)
sketch002 = startSketchOn(extrude001, seg03) sketch002 = startSketchOn(extrude001, seg03)
|> startProfileAt([160.39, 254.59], %) |> startProfileAt([205.96, 254.59], %)
|> angledLine([0, 11.39], %, $rectangleSegmentA002) |> angledLine([0, 11.39], %, $rectangleSegmentA002)
|> angledLine([ |> angledLine([
segAng(rectangleSegmentA002) - 90, segAng(rectangleSegmentA002) - 90,
@ -595,11 +598,15 @@ test(`Verify axis, origin, and horizontal snapping`, async ({
}) })
test(`Verify user can double-click to edit a sketch`, async ({ test(`Verify user can double-click to edit a sketch`, async ({
app, context,
page,
homePage,
editor, editor,
toolbar, toolbar,
scene, scene,
}) => { }) => {
const u = await getUtils(page)
const initialCode = `closedSketch = startSketchOn('XZ') const initialCode = `closedSketch = startSketchOn('XZ')
|> circle({ center = [8, 5], radius = 2 }, %) |> circle({ center = [8, 5], radius = 2 }, %)
openSketch = startSketchOn('XY') openSketch = startSketchOn('XY')
@ -608,15 +615,30 @@ openSketch = startSketchOn('XY')
|> xLine(5, %) |> xLine(5, %)
|> tangentialArcTo([10, 0], %) |> tangentialArcTo([10, 0], %)
` `
await app.initialise(initialCode) const viewPortSize = { width: 1200, height: 500 }
await page.setBodyDimensions(viewPortSize)
await context.addInitScript((code) => {
localStorage.setItem('persistCode', code)
}, initialCode)
await homePage.goToModelingScene()
await u.waitForPageLoad()
await page.waitForTimeout(1000)
const pointOnSketchArea = {
x: viewPortSize.width * 0.7,
y: viewPortSize.height * 0.7,
}
const pointInsideCircle = { const pointInsideCircle = {
x: app.viewPortSize.width * 0.63, x: viewPortSize.width * 0.55,
y: app.viewPortSize.height * 0.5, y: viewPortSize.height * 0.5,
} }
const pointOnPathAfterSketching = { const pointOnPathAfterSketching = {
x: app.viewPortSize.width * 0.58, x: viewPortSize.width * 0.65,
y: app.viewPortSize.height * 0.5, y: viewPortSize.height * 0.5,
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_clickOpenPath, moveToOpenPath, dblClickOpenPath] = const [_clickOpenPath, moveToOpenPath, dblClickOpenPath] =
@ -649,41 +671,54 @@ openSketch = startSketchOn('XY')
diagnostics: [], diagnostics: [],
}) })
}) })
await page.waitForTimeout(1000)
await exitSketch() await exitSketch()
await page.waitForTimeout(1000)
// Drag the sketch line out of the axis view which blocks the click
await page.dragAndDrop('#stream', '#stream', {
sourcePosition: { x: viewPortSize.width * 0.7, y: viewPortSize.height* 0.5 },
targetPosition: { x: viewPortSize.width * 0.7, y: viewPortSize.height* 0.4 },
})
await page.waitForTimeout(500)
await test.step(`Double-click on the open sketch`, async () => { await test.step(`Double-click on the open sketch`, async () => {
await moveToOpenPath() await moveToOpenPath()
await scene.expectPixelColor([250, 250, 250], pointOnPathAfterSketching, 15) await scene.expectPixelColor([250, 250, 250], pointOnPathAfterSketching, 15)
// There is a full execution after exiting sketch that clears the scene. // There is a full execution after exiting sketch that clears the scene.
await app.page.waitForTimeout(500) await page.waitForTimeout(500)
await dblClickOpenPath() await dblClickOpenPath()
await expect(toolbar.startSketchBtn).not.toBeVisible() await expect(toolbar.startSketchBtn).not.toBeVisible()
await expect(toolbar.exitSketchBtn).toBeVisible() await expect(toolbar.exitSketchBtn).toBeVisible()
// Wait for enter sketch mode to complete // Wait for enter sketch mode to complete
await app.page.waitForTimeout(500) await page.waitForTimeout(500)
await editor.expectState({ await editor.expectState({
activeLines: [`|>xLine(5,%)`], activeLines: [`|>tangentialArcTo([10,0],%)`],
highlightedCode: 'xLine(5,%)', highlightedCode: 'tangentialArcTo([10,0],%)',
diagnostics: [], diagnostics: [],
}) })
}) })
}) })
test(`Offset plane point-and-click`, async ({ test(`Offset plane point-and-click`, async ({
app, context,
page,
homePage,
scene, scene,
editor, editor,
toolbar, toolbar,
cmdBar, cmdBar,
}) => { }) => {
await app.initialise()
// One dumb hardcoded screen pixel value // One dumb hardcoded screen pixel value
const testPoint = { x: 700, y: 150 } const testPoint = { x: 700, y: 150 }
const [clickOnXzPlane] = scene.makeMouseHelpers(testPoint.x, testPoint.y) const [clickOnXzPlane] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
const expectedOutput = `plane001 = offsetPlane('XZ', 5)` const expectedOutput = `plane001 = offsetPlane('XZ', 5)`
await homePage.goToModelingScene()
await test.step(`Look for the blue of the XZ plane`, async () => { await test.step(`Look for the blue of the XZ plane`, async () => {
await scene.expectPixelColor([50, 51, 96], testPoint, 15) await scene.expectPixelColor([50, 51, 96], testPoint, 15)
}) })

View File

@ -7,8 +7,6 @@ import {
getMovementUtils, getMovementUtils,
getUtils, getUtils,
PERSIST_MODELING_CONTEXT, PERSIST_MODELING_CONTEXT,
setup,
tearDown,
} from './test-utils' } from './test-utils'
import { uuidv4, roundOff } from 'lib/utils' import { uuidv4, roundOff } from 'lib/utils'
@ -40,9 +38,9 @@ test.describe('Sketch tests', () => {
screwHole = startSketchOn('XY') screwHole = startSketchOn('XY')
${startProfileAt1} ${startProfileAt1}
|> arc({ |> arc({
radius: screwRadius, radius = screwRadius,
angle_start: 0, angle_start = 0,
angle_end: 360 angle_end = 360
}, %) }, %)
part001 = startSketchOn('XY') part001 = startSketchOn('XY')
@ -61,9 +59,9 @@ test.describe('Sketch tests', () => {
|> xLine(-width / 4 + wireRadius, %) |> xLine(-width / 4 + wireRadius, %)
|> yLine(wireOffset, %) |> yLine(wireOffset, %)
|> arc({ |> arc({
radius: wireRadius, radius = wireRadius,
angle_start: 0, angle_start = 0,
angle_end: 180 angle_end = 180
}, %) }, %)
|> yLine(-wireOffset, %) |> yLine(-wireOffset, %)
|> xLine(-width / 4, %) |> xLine(-width / 4, %)
@ -347,6 +345,7 @@ test.describe('Sketch tests', () => {
test('Can edit a circle center and radius by dragging its handles', async ({ test('Can edit a circle center and radius by dragging its handles', async ({
page, page,
editor,
homePage, homePage,
}) => { }) => {
const u = await getUtils(page) const u = await getUtils(page)
@ -354,7 +353,7 @@ test.describe('Sketch tests', () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`sketch001 = startSketchOn('XZ') `sketch001 = startSketchOn('XZ')
|> circle({ center: [4.61, -5.01], radius: 8 }, %)` |> circle({ center = [4.61, -5.01], radius = 8 }, %)`
) )
}) })
@ -398,6 +397,7 @@ test.describe('Sketch tests', () => {
).toBeVisible() ).toBeVisible()
await page.getByRole('button', { name: 'Edit Sketch' }).click() await page.getByRole('button', { name: 'Edit Sketch' }).click()
await page.waitForTimeout(400) await page.waitForTimeout(400)
let prevContent = await page.locator('.cm-content').innerText() let prevContent = await page.locator('.cm-content').innerText()
await expect(page.getByTestId('segment-overlay')).toHaveCount(1) await expect(page.getByTestId('segment-overlay')).toHaveCount(1)
@ -408,7 +408,9 @@ test.describe('Sketch tests', () => {
targetPosition: { x: startPX[0] + dragPX, y: startPX[1] - dragPX }, targetPosition: { x: startPX[0] + dragPX, y: startPX[1] - dragPX },
}) })
await page.waitForTimeout(100) await page.waitForTimeout(100)
await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
await editor.expectEditor.not.toContain(prevContent)
prevContent = await page.locator('.cm-content').innerText() prevContent = await page.locator('.cm-content').innerText()
}) })
@ -421,15 +423,13 @@ test.describe('Sketch tests', () => {
sourcePosition: { x: lineEnd.x - 5, y: lineEnd.y }, sourcePosition: { x: lineEnd.x - 5, y: lineEnd.y },
targetPosition: { x: lineEnd.x + dragPX * 2, y: lineEnd.y + dragPX }, targetPosition: { x: lineEnd.x + dragPX * 2, y: lineEnd.y + dragPX },
}) })
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await editor.expectEditor.not.toContain(prevContent)
prevContent = await page.locator('.cm-content').innerText() prevContent = await page.locator('.cm-content').innerText()
}) })
// expect the code to have changed // expect the code to have changed
await expect(page.locator('.cm-content')) await editor.expectEditor.toContain(`sketch001 = startSketchOn('XZ')
.toHaveText(`sketch001 = startSketchOn('XZ') |> circle({ center = [7.26, -2.37], radius = 11.44 }, %)`, { shouldNormalise: true })
|> circle({ center: [7.26, -2.37], radius: 11.44 }, %)
`)
}) })
test('Can edit a sketch that has been extruded in the same pipe', async ({ test('Can edit a sketch that has been extruded in the same pipe', async ({
page, page,
@ -547,7 +547,7 @@ test.describe('Sketch tests', () => {
|> line([12.73, -0.09], %) |> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %) |> tangentialArcTo([24.95, -5.38], %)
|> close(%) |> close(%)
|> revolve({ axis: "X",}, %)` |> revolve({ axis = "X",}, %)`
) )
}) })
@ -633,7 +633,7 @@ test.describe('Sketch tests', () => {
|> tangentialArcTo([24.95, -5.38], %) |> tangentialArcTo([24.95, -5.38], %)
|> line([1.97, 2.06], %) |> line([1.97, 2.06], %)
|> close(%) |> close(%)
|> revolve({ axis: "X" }, %)`) |> revolve({ axis = "X" }, %)`)
}) })
test('Can add multiple sketches', async ({ page, homePage }) => { test('Can add multiple sketches', async ({ page, homePage }) => {
const u = await getUtils(page) const u = await getUtils(page)
@ -1064,11 +1064,11 @@ test.describe('Sketch tests', () => {
fn lug = (origin, length, diameter, plane) => { fn lug = (origin, length, diameter, plane) => {
lugSketch = startSketchOn(plane) lugSketch = startSketchOn(plane)
|> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %) |> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %)
|> angledLineOfYLength({ angle: 60, length: lugHeadLength }, %) |> angledLineOfYLength({ angle = 60, length = lugHeadLength }, %)
|> xLineTo(0 + .001, %) |> xLineTo(0 + .001, %)
|> yLineTo(0, %) |> yLineTo(0, %)
|> close(%) |> close(%)
|> revolve({ axis: "Y" }, %) |> revolve({ axis = "Y" }, %)
return lugSketch return lugSketch
} }

View File

@ -707,13 +707,13 @@ export const makeTemplate: (
const PLAYWRIGHT_DOWNLOAD_DIR = 'downloads-during-playwright' const PLAYWRIGHT_DOWNLOAD_DIR = 'downloads-during-playwright'
export const getPlaywrightDownloadDir = (page: Page) => { export const getPlaywrightDownloadDir = (page: Page) => {
return path.resolve(page.TEST_SETTINGS_FILE_KEY, PLAYWRIGHT_DOWNLOAD_DIR) return path.resolve(page.dir, PLAYWRIGHT_DOWNLOAD_DIR)
} }
const moveDownloadedFileTo = async (page: Page, toLocation: string) => { const moveDownloadedFileTo = async (page: Page, toLocation: string) => {
await fsp.mkdir(path.dirname(toLocation), { recursive: true }) await fsp.mkdir(path.dirname(toLocation), { recursive: true })
const downloadDir = getPlaywrightDownloadDir() const downloadDir = getPlaywrightDownloadDir(page)
// Expect there to be at least one file // Expect there to be at least one file
expect expect

View File

@ -306,20 +306,20 @@ test.describe('Testing selections', () => {
|> line([thickness, 0], %) |> line([thickness, 0], %)
|> line([0, -1], %) |> line([0, -1], %)
|> angledLineToX({ |> angledLineToX({
angle: 60, angle = 60,
to: pipeSmallDia + thickness to = pipeSmallDia + thickness
}, %) }, %)
|> line([0, -pipeLength], %) |> line([0, -pipeLength], %)
|> angledLineToX({ |> angledLineToX({
angle: -60, angle = -60,
to: pipeLargeDia + thickness to = pipeLargeDia + thickness
}, %) }, %)
|> line([0, -1], %) |> line([0, -1], %)
|> line([-thickness, 0], %) |> line([-thickness, 0], %)
|> line([0, 1], %) |> line([0, 1], %)
|> angledLineToX({ angle: 120, to: pipeSmallDia }, %) |> angledLineToX({ angle = 120, to = pipeSmallDia }, %)
|> line([0, pipeLength], %) |> line([0, pipeLength], %)
|> angledLineToX({ angle: 60, to: pipeLargeDia }, %) |> angledLineToX({ angle = 60, to = pipeLargeDia }, %)
|> close(%) |> close(%)
rev = revolve({ axis: 'y' }, part009) rev = revolve({ axis: 'y' }, part009)
` `
@ -387,27 +387,27 @@ test.describe('Testing selections', () => {
`extrude001 = extrude(50, sketch001)` `extrude001 = extrude(50, sketch001)`
) )
await expect(u.codeLocator).toContainText(`sketch005 = startSketchOn({ await expect(u.codeLocator).toContainText(`sketch005 = startSketchOn({
plane: { plane = {
origin: { x: 0, y: -50, z: 0 }, origin = { x = 0, y = -50, z = 0 },
x_axis: { x: 1, y: 0, z: 0 }, x_axis = { x = 1, y = 0, z = 0 },
y_axis: { x: 0, y: 0, z: 1 }, y_axis = { x = 0, y = 0, z = 1 },
z_axis: { x: 0, y: -1, z: 0 } z_axis = { x = 0, y = -1, z = 0 }
} }
})`) })`)
await expect(u.codeLocator).toContainText(`sketch003 = startSketchOn({ await expect(u.codeLocator).toContainText(`sketch003 = startSketchOn({
plane: { plane = {
origin: { x: 116.53, y: 0, z: 163.25 }, origin = { x = 116.53, y = 0, z = 163.25 },
x_axis: { x: -0.81, y: 0, z: 0.58 }, x_axis = { x = -0.81, y = 0, z = 0.58 },
y_axis: { x: 0, y: -1, z: 0 }, y_axis = { x = 0, y = -1, z = 0 },
z_axis: { x: 0.58, y: 0, z: 0.81 } z_axis = { x = 0.58, y = 0, z = 0.81 }
} }
})`) })`)
await expect(u.codeLocator).toContainText(`sketch002 = startSketchOn({ await expect(u.codeLocator).toContainText(`sketch002 = startSketchOn({
plane: { plane = {
origin: { x: -91.74, y: 0, z: 80.89 }, origin = { x = -91.74, y = 0, z = 80.89 },
x_axis: { x: -0.66, y: 0, z: -0.75 }, x_axis = { x = -0.66, y = 0, z = -0.75 },
y_axis: { x: 0, y: -1, z: 0 }, y_axis = { x = 0, y = -1, z = 0 },
z_axis: { x: -0.75, y: 0, z: 0.66 } z_axis = { x = -0.75, y = 0, z = 0.66 }
} }
})`) })`)
@ -499,19 +499,19 @@ test.describe('Testing selections', () => {
`part001 = startSketchOn('XZ') `part001 = startSketchOn('XZ')
|> startProfileAt([20, 0], %) |> startProfileAt([20, 0], %)
|> line([7.13, 4 + 0], %) |> line([7.13, 4 + 0], %)
|> angledLine({ angle: 3 + 0, length: 3.14 + 0 }, %) |> angledLine({ angle = 3 + 0, length = 3.14 + 0 }, %)
|> lineTo([20.14 + 0, -0.14 + 0], %) |> lineTo([20.14 + 0, -0.14 + 0], %)
|> xLineTo(29 + 0, %) |> xLineTo(29 + 0, %)
|> yLine(-3.14 + 0, %, $a) |> yLine(-3.14 + 0, %, $a)
|> xLine(1.63, %) |> xLine(1.63, %)
|> angledLineOfXLength({ angle: 3 + 0, length: 3.14 }, %) |> angledLineOfXLength({ angle = 3 + 0, length = 3.14 }, %)
|> angledLineOfYLength({ angle: 30, length: 3 + 0 }, %) |> angledLineOfYLength({ angle = 30, length = 3 + 0 }, %)
|> angledLineToX({ angle: 22.14 + 0, to: 12 }, %) |> angledLineToX({ angle = 22.14 + 0, to = 12 }, %)
|> angledLineToY({ angle: 30, to: 11.14 }, %) |> angledLineToY({ angle = 30, to = 11.14 }, %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle: 3.14, angle = 3.14,
intersectTag: a, intersectTag = a,
offset: 0 offset = 0
}, %) }, %)
|> tangentialArcTo([13.14 + 0, 13.14], %) |> tangentialArcTo([13.14 + 0, 13.14], %)
|> close(%) |> close(%)
@ -735,8 +735,8 @@ test.describe('Testing selections', () => {
|> close(%) |> close(%)
extrude001 = extrude(100, sketch001) extrude001 = extrude(100, sketch001)
|> chamfer({ |> chamfer({
length: 30, length = 30,
tags: [ tags = [
seg01, seg01,
getNextAdjacentEdge(yo), getNextAdjacentEdge(yo),
getNextAdjacentEdge(seg02), getNextAdjacentEdge(seg02),
@ -831,9 +831,11 @@ test.describe('Testing selections', () => {
}) })
test("Extrude button should be disabled if there's no extrudable geometry when nothing is selected", async ({ test("Extrude button should be disabled if there's no extrudable geometry when nothing is selected", async ({
page, page,
editor,
homePage, homePage,
}) => { }) => {
const u = await getUtils(page) const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -854,17 +856,20 @@ test.describe('Testing selections', () => {
` `
) )
}) })
await page.setBodyDimensions({ width: 1000, height: 500 })
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
await u.waitForPageLoad()
// wait for execution done // wait for execution done
await u.openDebugPanel() await u.openDebugPanel()
await u.expectCmdLog('[data-message-type="execution-done"]') await u.expectCmdLog('[data-message-type="execution-done"]')
await u.closeDebugPanel() await u.closeDebugPanel()
const selectUnExtrudable = () => const selectUnExtrudable = async () => {
page.getByText(`line([4.99, -0.46], %, $seg01)`).click() await editor.scrollToText(`line([4.99, -0.46], %, $seg01)`)
await page.getByText(`line([4.99, -0.46], %, $seg01)`).click()
}
const clickEmpty = () => page.mouse.click(700, 460) const clickEmpty = () => page.mouse.click(700, 460)
await selectUnExtrudable() await selectUnExtrudable()
// expect extrude button to be disabled // expect extrude button to be disabled
@ -874,6 +879,7 @@ test.describe('Testing selections', () => {
// expect active line to contain nothing // expect active line to contain nothing
await expect(page.locator('.cm-activeLine')).toHaveText('') await expect(page.locator('.cm-activeLine')).toHaveText('')
// and extrude to still be disabled // and extrude to still be disabled
await expect(page.getByRole('button', { name: 'Extrude' })).toBeDisabled() await expect(page.getByRole('button', { name: 'Extrude' })).toBeDisabled()

View File

@ -53,27 +53,27 @@ part001 = startSketchOn('-XZ')
|> yLine(baseHeight, %) |> yLine(baseHeight, %)
|> xLine(baseLen, %) |> xLine(baseLen, %)
|> angledLineToY({ |> angledLineToY({
angle: topAng, angle = topAng,
to: totalHeightHalf, to = totalHeightHalf,
}, %, $seg04) }, %, $seg04)
|> xLineTo(totalLen, %, $seg03) |> xLineTo(totalLen, %, $seg03)
|> yLine(-armThick, %, $seg01) |> yLine(-armThick, %, $seg01)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle: HALF_TURN, angle = HALF_TURN,
offset: -armThick, offset = -armThick,
intersectTag: seg04 intersectTag = seg04
}, %) }, %)
|> angledLineToY([segAng(seg04) + 180, ZERO], %) |> angledLineToY([segAng(seg04) + 180, ZERO], %)
|> angledLineToY({ |> angledLineToY({
angle: -bottomAng, angle = -bottomAng,
to: -totalHeightHalf - armThick, to = -totalHeightHalf - armThick,
}, %, $seg02) }, %, $seg02)
|> xLineTo(segEndX(seg03) + 0, %) |> xLineTo(segEndX(seg03) + 0, %)
|> yLine(-segLen(seg01), %) |> yLine(-segLen(seg01), %)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle: HALF_TURN, angle = HALF_TURN,
offset: -armThick, offset = -armThick,
intersectTag: seg02 intersectTag = seg02
}, %) }, %)
|> angledLineToY([segAng(seg02) + 180, -baseHeight], %) |> angledLineToY([segAng(seg02) + 180, -baseHeight], %)
|> xLineTo(ZERO, %) |> xLineTo(ZERO, %)

View File

@ -61,35 +61,38 @@ export function test(desc, objOrFn, fnMaybe) {
await tronApp.page.reload() await tronApp.page.reload()
} }
if (tronApp instanceof AuthenticatedTronApp) { // Create a consistent way to resize the page across electron and web.
// Create a consistent way to resize the page across electron and web. // (lee) I had to do everyhting in the book to make electron change its
// (lee) I had to do everyhting in the book to make electron change its // damn window size. I succeded in making it consistently and reliably
// damn window size. I succeded in making it consistently and reliably // do it after a whole afternoon.
// do it after a whole afternoon. tronApp.page.setBodyDimensions = async function (dims: {
tronApp.page.setBodyDimensions = async function (dims: { width: number
width: number height: number
height: number }) {
}) { await tronApp.page.setViewportSize(dims)
await tronApp.electronApp.evaluateHandle(async ({ app }, dims) => {
await app.resizeWindow(dims.width, dims.height)
}, dims)
await tronApp.page.setViewportSize(dims) if (!(tronApp instanceof AuthenticatedTronApp)) {
return tronApp.page.evaluate(async (dims) => { return
await window.electron.resizeWindow(dims.width, dims.height)
window.document.body.style.width = dims.width + 'px'
window.document.body.style.height = dims.height + 'px'
window.document.documentElement.style.width = dims.width + 'px'
window.document.documentElement.style.height = dims.height + 'px'
}, dims)
} }
// We need to expose this in order for some tests that require folder await tronApp.electronApp.evaluateHandle(async ({ app }, dims) => {
// creation. Before they used to do this by their own electronSetup({...}) await app.resizeWindow(dims.width, dims.height)
// calls. }, dims)
tronApp.context.folderSetupFn = function (fn) {
return fn(tronApp.dir).then(() => ({ dir: tronApp.dir })) return tronApp.page.evaluate(async (dims) => {
} await window.electron.resizeWindow(dims.width, dims.height)
window.document.body.style.width = dims.width + 'px'
window.document.body.style.height = dims.height + 'px'
window.document.documentElement.style.width = dims.width + 'px'
window.document.documentElement.style.height = dims.height + 'px'
}, dims)
}
// We need to expose this in order for some tests that require folder
// creation. Before they used to do this by their own electronSetup({...})
// calls.
tronApp.context.folderSetupFn = function (fn) {
return fn(tronApp.dir).then(() => ({ dir: tronApp.dir }))
} }
await fn( await fn(