Fix camera tests again

This commit is contained in:
49lf
2024-12-13 14:07:56 -05:00
parent e9ecb2e2c8
commit d6ea529b79
3 changed files with 23 additions and 25 deletions

View File

@ -604,7 +604,7 @@ extrude001 = extrude(50, sketch001)
} }
expect(middlePixelIsBackgroundColor, { expect(middlePixelIsBackgroundColor, {
message: 'We no longer the default planes', message: 'We should not see the default planes',
}).toBeTruthy() }).toBeTruthy()
}) })

View File

@ -1,14 +1,16 @@
import { test, expect } from './zoo-test' import { test, expect } from './zoo-test'
import { EngineCommand } from 'lang/std/artifactGraph' import { EngineCommand } from 'lang/std/artifactGraph'
import { uuidv4 } from 'lib/utils' import { uuidv4 } from 'lib/utils'
import { getUtils } from './test-utils' import { getUtils, setup, tearDown } from './test-utils'
test.describe('Testing Camera Movement', () => { test.describe('Testing Camera Movement', () => {
test('Can move camera reliably', async ({ page, context, homePage }) => { test('Can move camera reliably', async ({ page, context, homePage }) => {
test.skip(process.platform === 'darwin', 'Can move camera reliably')
const u = await getUtils(page) const u = await getUtils(page)
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
await u.waitForPageLoad()
await u.openAndClearDebugPanel() await u.openAndClearDebugPanel()
await u.closeKclCodePanel() await u.closeKclCodePanel()
@ -185,6 +187,7 @@ test.describe('Testing Camera Movement', () => {
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
await u.waitForPageLoad()
await u.openDebugPanel() await u.openDebugPanel()
await expect( await expect(
@ -336,10 +339,7 @@ test.describe('Testing Camera Movement', () => {
}) })
}) })
test(`Zoom by scroll should not fire while orbiting`, async ({ test(`Zoom by scroll should not fire while orbiting`, async ({ homePage, page }) => {
page,
homePage,
}) => {
/** /**
* Currently we only allow zooming by scroll when no other camera movement is happening, * Currently we only allow zooming by scroll when no other camera movement is happening,
* set within cameraMouseDragGuards in cameraControls.ts, * set within cameraMouseDragGuards in cameraControls.ts,
@ -379,6 +379,7 @@ test.describe('Testing Camera Movement', () => {
await test.step(`Test setup`, async () => { await test.step(`Test setup`, async () => {
await homePage.goToModelingScene() await homePage.goToModelingScene()
await u.waitForPageLoad()
await u.closeKclCodePanel() await u.closeKclCodePanel()
// This test requires the mouse controls to be set to Solidworks // This test requires the mouse controls to be set to Solidworks
await u.openDebugPanel() await u.openDebugPanel()
@ -408,22 +409,21 @@ test.describe('Testing Camera Movement', () => {
await u.waitForCmdReceive('default_camera_get_settings') await u.waitForCmdReceive('default_camera_get_settings')
}) })
await expect.poll(getCameraZValue, {
message: 'Camera should be at expected position after zooming',
})
await callback()
await page.mouse.move(orbitMouseEnd.x, orbitMouseEnd.y, {
steps: 3,
})
})
await test.step(`Verify orbit`, async () => {
await expect await expect
.poll(getCameraZValue, { .poll(getCameraZValue, {
message: 'Camera should be at expected position after orbiting', message: 'Camera should be at expected position after zooming',
}) })
.toEqual(expectedOrbitCamZPosition) .toEqual(expectedZoomCamZPosition)
await page.mouse.up({ button: 'middle' }) })
await test.step(`Test orbiting works`, async () => {
await doOrbitWith()
})
await test.step(`Test scrolling while orbiting doesn't zoom`, async () => {
await doOrbitWith(async () => {
await page.mouse.wheel(0, -100)
})
}) })
// Helper functions // Helper functions
@ -474,14 +474,11 @@ test.describe('Testing Camera Movement', () => {
await page.mouse.up({ button: 'middle' }) await page.mouse.up({ button: 'middle' })
}) })
} }
}) })
test('Right-click opens context menu when not dragged', async ({ test('Right-click opens context menu when not dragged', async ({ homePage, page }) => {
homePage,
page,
}) => {
const u = await getUtils(page) const u = await getUtils(page)
await homePage.goToModelingScene() await homePage.goToModelingScene()
await u.waitForPageLoad() await u.waitForPageLoad()
@ -503,3 +500,4 @@ test.describe('Testing Camera Movement', () => {
}) })
}) })
}) })

View File

@ -35,7 +35,7 @@ test.describe('Testing settings', () => {
// Check that the invalid settings were changed to good defaults // Check that the invalid settings were changed to good defaults
expect(storedSettings.settings?.modeling?.defaultUnit).toBe('in') expect(storedSettings.settings?.modeling?.defaultUnit).toBe('in')
expect(storedSettings.settings?.modeling?.mouseControls).toBe('KittyCAD') expect(storedSettings.settings?.modeling?.mouseControls).toBe('Zoo')
expect(storedSettings.settings?.app?.projectDirectory).toBe('') expect(storedSettings.settings?.app?.projectDirectory).toBe('')
expect(storedSettings.settings?.projects?.defaultProjectName).toBe( expect(storedSettings.settings?.projects?.defaultProjectName).toBe(
'project-$nnn' 'project-$nnn'