Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion e2e/playwright/storageStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export const TEST_SETTINGS_CORRUPTED = {
},
} satisfies Partial<SaveSettingsPayload>

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 }, %)
Expand Down
12 changes: 6 additions & 6 deletions e2e/playwright/testing-gizmo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
},
Expand Down
59 changes: 36 additions & 23 deletions e2e/playwright/testing-perspective-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is being skipped on PRs, so the changes you made to it won't have run on CI. You might consider removing this line if you've made the test more reliable and would like it to run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm down to try it! I was just concerned with removing all references to this toggle from the code base, so I saw this as making a future attempt to turn that test back on a little less confusing. I don't think that I've made the test more reliable but I can see.

const u = await getUtils(page)

Expand All @@ -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)
}
Expand All @@ -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 })
Expand All @@ -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
Expand All @@ -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')
})
})
})
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -154,7 +153,6 @@ export function App() {
<LowerRightControls coreDumpManager={coreDumpManager}>
<UnitsMenu />
<Gizmo />
<CameraProjectionToggle />
</LowerRightControls>
</div>
)
Expand Down
Loading