diff --git a/e2e/playwright/storageStates.ts b/e2e/playwright/storageStates.ts index dd9fe5918..06b6f0eae 100644 --- a/e2e/playwright/storageStates.ts +++ b/e2e/playwright/storageStates.ts @@ -80,7 +80,8 @@ export const TEST_SETTINGS_CORRUPTED = { }, } satisfies Partial -export const TEST_CODE_GIZMO = `part001 = startSketchOn(XZ) +export const TEST_CODE_GIZMO = `@settings(defaultLengthUnit = in) +part001 = startSketchOn(XZ) |> startProfileAt([20, 0], %) |> line(end = [7.13, 4 + 0]) |> angledLine({ angle: 3 + 0, length: 3.14 + 0 }, %) diff --git a/e2e/playwright/testing-gizmo.spec.ts b/e2e/playwright/testing-gizmo.spec.ts index 62422f8fe..e6ad1e919 100644 --- a/e2e/playwright/testing-gizmo.spec.ts +++ b/e2e/playwright/testing-gizmo.spec.ts @@ -8,37 +8,37 @@ test.describe('Testing Gizmo', { tag: ['@skipWin'] }, () => { const cases = [ { testDescription: 'top view', - clickPosition: { x: 951, y: 347 }, + clickPosition: { x: 951, y: 385 }, expectedCameraPosition: { x: 800, y: -152, z: 4886.02 }, expectedCameraTarget: { x: 800, y: -152, z: 26 }, }, { testDescription: 'bottom view', - clickPosition: { x: 951, y: 391 }, + clickPosition: { x: 951, y: 429 }, expectedCameraPosition: { x: 800, y: -152, z: -4834.02 }, expectedCameraTarget: { x: 800, y: -152, z: 26 }, }, { testDescription: 'right view', - clickPosition: { x: 929, y: 379 }, + clickPosition: { x: 929, y: 417 }, expectedCameraPosition: { x: 5660.02, y: -152, z: 26 }, expectedCameraTarget: { x: 800, y: -152, z: 26 }, }, { testDescription: 'left view', - clickPosition: { x: 974, y: 359 }, + clickPosition: { x: 974, y: 397 }, expectedCameraPosition: { x: -4060.02, y: -152, z: 26 }, expectedCameraTarget: { x: 800, y: -152, z: 26 }, }, { testDescription: 'back view', - clickPosition: { x: 967, y: 383 }, + clickPosition: { x: 967, y: 421 }, expectedCameraPosition: { x: 800, y: 4708.02, z: 26 }, expectedCameraTarget: { x: 800, y: -152, z: 26 }, }, { testDescription: 'front view', - clickPosition: { x: 935, y: 355 }, + clickPosition: { x: 935, y: 393 }, expectedCameraPosition: { x: 800, y: -5012.02, z: 26 }, expectedCameraTarget: { x: 800, y: -152, z: 26 }, }, diff --git a/e2e/playwright/testing-perspective-toggle.spec.ts b/e2e/playwright/testing-perspective-toggle.spec.ts index eb1306e98..7b70d3f4f 100644 --- a/e2e/playwright/testing-perspective-toggle.spec.ts +++ b/e2e/playwright/testing-perspective-toggle.spec.ts @@ -2,7 +2,11 @@ import { getUtils, orRunWhenFullSuiteEnabled } from '@e2e/playwright/test-utils' import { expect, test } from '@e2e/playwright/zoo-test' test.describe('Test toggling perspective', () => { - test('via command palette and toggle', async ({ page, homePage }) => { + test('via command palette and toggle', async ({ + page, + homePage, + toolbar, + }) => { test.fixme(orRunWhenFullSuiteEnabled()) const u = await getUtils(page) @@ -14,7 +18,7 @@ test.describe('Test toggling perspective', () => { y: screenHeight * 0.2, } const backgroundColor: [number, number, number] = [29, 29, 29] - const xzPlaneColor: [number, number, number] = [82, 55, 96] + const xzPlaneColor: [number, number, number] = [72, 55, 96] const locationToHaveColor = async (color: [number, number, number]) => { return u.getGreatestPixDiff(checkedScreenLocation, color) } @@ -26,9 +30,29 @@ test.describe('Test toggling perspective', () => { const commandToast = page.getByText( `Set camera projection to "orthographic"` ) - const projectionToggle = page.getByRole('switch', { - name: 'Camera projection: ', - }) + + const checkSettingValue = async () => { + const settingsButton = page.getByRole('link', { + name: 'Settings', + exact: false, + }) + + let settingValue: string | null = null + + await test.step(`Check the setting value`, async () => { + await settingsButton.click() + const userTab = page.getByRole('radio', { name: 'User' }) + await userTab.click() + await expect(userTab).toBeChecked() + const setting = page.locator('#cameraProjection').first() + await expect(setting).toBeAttached() + await setting.scrollIntoViewIfNeeded() + settingValue = await setting.getByRole('combobox').inputValue() + await page.getByTestId('settings-close-button').click() + }) + + return settingValue + } await test.step('Setup', async () => { await page.setBodyDimensions({ width: screenWidth, height: screenHeight }) @@ -39,8 +63,8 @@ test.describe('Test toggling perspective', () => { timeout: 5000, message: 'This spot should have the background color', }) - .toBeLessThan(15) - await expect(projectionToggle).toHaveAttribute('aria-checked', 'true') + .toBeLessThan(30) + expect(await checkSettingValue()).toBe('perspective') }) // Extremely wild note: flicking between ortho and persp actually changes @@ -59,33 +83,22 @@ test.describe('Test toggling perspective', () => { timeout: 5000, message: 'This spot should have the XZ plane color', }) - .toBeLessThan(15) - await expect(projectionToggle).toHaveAttribute('aria-checked', 'false') + .toBeLessThan(30) + expect(await checkSettingValue()).toBe('orthographic') }) await test.step(`Refresh the page and ensure the stream is loaded in ortho`, async () => { await page.reload() - await page.waitForTimeout(1000) + await expect(toolbar.startSketchBtn).toBeEnabled({ timeout: 15_000 }) await u.closeKclCodePanel() await expect .poll(async () => locationToHaveColor(xzPlaneColor), { timeout: 5000, message: 'This spot should have the XZ plane color', }) - .toBeLessThan(15) + .toBeLessThan(30) await expect(commandToast).not.toBeVisible() - await expect(projectionToggle).toHaveAttribute('aria-checked', 'false') - }) - - await test.step(`Switch to perspective via toggle`, async () => { - await projectionToggle.click() - await expect(projectionToggle).toHaveAttribute('aria-checked', 'true') - await expect - .poll(async () => locationToHaveColor(backgroundColor), { - timeout: 5000, - message: 'This spot should have the background color', - }) - .toBeLessThan(15) + expect(await checkSettingValue()).toBe('orthographic') }) }) }) diff --git a/src/App.tsx b/src/App.tsx index 4786ed4c5..8c4b4acac 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,7 +9,6 @@ import { } from 'react-router-dom' import { AppHeader } from '@src/components/AppHeader' -import { CameraProjectionToggle } from '@src/components/CameraProjectionToggle' import { useEngineCommands } from '@src/components/EngineCommands' import Gizmo from '@src/components/Gizmo' import { LowerRightControls } from '@src/components/LowerRightControls' @@ -154,7 +153,6 @@ export function App() { - )