Pass camera-movement.spec tests

This commit is contained in:
49lf
2024-11-28 12:54:09 -05:00
parent aefece4dae
commit 04edc3a332

View File

@ -1,23 +1,14 @@
import { test, expect } from '@playwright/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, setup, tearDown } from './test-utils' import { getUtils, } from './test-utils'
test.beforeEach(async ({ context, page }, testInfo) => {
await setup(context, page, testInfo)
})
test.afterEach(async ({ page }, testInfo) => {
await tearDown(page, testInfo)
})
test.describe('Testing Camera Movement', () => { test.describe('Testing Camera Movement', () => {
test('Can move camera reliably', async ({ page, context }) => { 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.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
await u.openAndClearDebugPanel() await u.openAndClearDebugPanel()
await u.closeKclCodePanel() await u.closeKclCodePanel()
@ -178,21 +169,17 @@ test.describe('Testing Camera Movement', () => {
await bakeInRetries(async () => { await bakeInRetries(async () => {
await page.mouse.move(700, 400) await page.mouse.move(700, 400)
await page.mouse.wheel(0, -100) await page.mouse.wheel(0, -100)
}, [0, -85, -85]) }, [0, -85, -85]) })
})
test('Zoom should be consistent when exiting or entering sketches', async ({ test('Zoom should be consistent when exiting or entering sketches', async ({ page, homePage }) => { // start new sketch pan and zoom before exiting, when exiting the sketch should stay in the same place
page,
}) => {
// start new sketch pan and zoom before exiting, when exiting the sketch should stay in the same place
// than zoom and pan outside of sketch mode and enter again and it should not change from where it is // than zoom and pan outside of sketch mode and enter again and it should not change from where it is
// than again for sketching // than again for sketching
test.skip(process.platform !== 'darwin', 'Zoom should be consistent') test.skip(process.platform !== 'darwin', 'Zoom should be consistent')
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
await u.openDebugPanel() await u.openDebugPanel()
await expect( await expect(
@ -341,11 +328,9 @@ test.describe('Testing Camera Movement', () => {
await page.mouse.move(855, y) await page.mouse.move(855, y)
await expect(page.getByTestId('hover-highlight').first()).toBeVisible({ await expect(page.getByTestId('hover-highlight').first()).toBeVisible({
timeout: 10_000, timeout: 10_000,
}) }) })
})
test(`Zoom by scroll should not fire while orbiting`, async ({ page }) => { test(`Zoom by scroll should not fire while orbiting`, async ({ 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,
* until the engine supports unifying multiple camera movements. * until the engine supports unifying multiple camera movements.
@ -383,7 +368,7 @@ test.describe('Testing Camera Movement', () => {
const expectedOrbitCamZPosition = 64.0 const expectedOrbitCamZPosition = 64.0
await test.step(`Test setup`, async () => { await test.step(`Test setup`, async () => {
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
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()
@ -469,6 +454,17 @@ test.describe('Testing Camera Movement', () => {
}) })
}) })
await test.step(`Verify orbit`, async () => {
await expect
.poll(getCameraZValue, {
message: 'Camera should be at expected position after orbiting',
})
await callback()
await page.mouse.move(orbitMouseEnd.x, orbitMouseEnd.y, {
steps: 3,
})
})
await test.step(`Verify orbit`, async () => { await test.step(`Verify orbit`, async () => {
await expect await expect
.poll(getCameraZValue, { .poll(getCameraZValue, {
@ -480,9 +476,10 @@ test.describe('Testing Camera Movement', () => {
} }
}) })
test('Right-click opens context menu when not dragged', async ({ page }) => { test('Right-click opens context menu when not dragged', async ({ homePage, page }) => {
const u = await getUtils(page) const u = await getUtils(page)
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
await u.waitForPageLoad()
await test.step(`The menu should not show if we drag the mouse`, async () => { await test.step(`The menu should not show if we drag the mouse`, async () => {
await page.mouse.move(900, 200) await page.mouse.move(900, 200)