partial fixes

This commit is contained in:
Kurt Hutten Irev-Dev
2024-12-20 23:24:15 +11:00
parent 0642e49189
commit 6c9d14af93
3 changed files with 41 additions and 31 deletions

View File

@ -9,14 +9,15 @@ import {
sendCustomCmd,
} from '../test-utils'
type mouseParams = {
type MouseParams = {
pixelDiff?: number
shouldDbClick?: boolean
delay?: number
}
type mouseDragToParams = mouseParams & {
type MouseDragToParams = MouseParams & {
fromPoint: { x: number; y: number }
}
type mouseDragFromParams = mouseParams & {
type MouseDragFromParams = MouseParams & {
toPoint: { x: number; y: number }
}
@ -27,12 +28,12 @@ type SceneSerialised = {
}
}
type ClickHandler = (clickParams?: mouseParams) => Promise<void | boolean>
type MoveHandler = (moveParams?: mouseParams) => Promise<void | boolean>
type DblClickHandler = (clickParams?: mouseParams) => Promise<void | boolean>
type DragToHandler = (dragParams: mouseDragToParams) => Promise<void | boolean>
type ClickHandler = (clickParams?: MouseParams) => Promise<void | boolean>
type MoveHandler = (moveParams?: MouseParams) => Promise<void | boolean>
type DblClickHandler = (clickParams?: MouseParams) => Promise<void | boolean>
type DragToHandler = (dragParams: MouseDragToParams) => Promise<void | boolean>
type DragFromHandler = (
dragParams: mouseDragFromParams
dragParams: MouseDragFromParams
) => Promise<void | boolean>
export class SceneFixture {
@ -73,22 +74,26 @@ export class SceneFixture {
{ steps }: { steps: number } = { steps: 20 }
): [ClickHandler, MoveHandler, DblClickHandler] =>
[
(clickParams?: mouseParams) => {
(clickParams?: MouseParams) => {
if (clickParams?.pixelDiff) {
return doAndWaitForImageDiff(
this.page,
() =>
clickParams?.shouldDbClick
? this.page.mouse.dblclick(x, y)
: this.page.mouse.click(x, y),
? this.page.mouse.dblclick(x, y, {
delay: clickParams?.delay || 0,
})
: this.page.mouse.click(x, y, {
delay: clickParams?.delay || 0,
}),
clickParams.pixelDiff
)
}
return clickParams?.shouldDbClick
? this.page.mouse.dblclick(x, y)
: this.page.mouse.click(x, y)
? this.page.mouse.dblclick(x, y, { delay: clickParams?.delay || 0 })
: this.page.mouse.click(x, y, { delay: clickParams?.delay || 0 })
},
(moveParams?: mouseParams) => {
(moveParams?: MouseParams) => {
if (moveParams?.pixelDiff) {
return doAndWaitForImageDiff(
this.page,
@ -98,7 +103,7 @@ export class SceneFixture {
}
return this.page.mouse.move(x, y, { steps })
},
(clickParams?: mouseParams) => {
(clickParams?: MouseParams) => {
if (clickParams?.pixelDiff) {
return doAndWaitForImageDiff(
this.page,
@ -115,7 +120,7 @@ export class SceneFixture {
{ steps }: { steps: number } = { steps: 20 }
): [DragToHandler, DragFromHandler] =>
[
(dragToParams: mouseDragToParams) => {
(dragToParams: MouseDragToParams) => {
if (dragToParams?.pixelDiff) {
return doAndWaitForImageDiff(
this.page,
@ -132,7 +137,7 @@ export class SceneFixture {
targetPosition: { x, y },
})
},
(dragFromParams: mouseDragFromParams) => {
(dragFromParams: MouseDragFromParams) => {
if (dragFromParams?.pixelDiff) {
return doAndWaitForImageDiff(
this.page,

View File

@ -99,6 +99,7 @@ test.describe('Sketch tests', () => {
})
test('Can delete most of a sketch and the line tool will still work', async ({
page,
scene,
homePage,
}) => {
const u = await getUtils(page)
@ -114,6 +115,8 @@ test.describe('Sketch tests', () => {
await homePage.goToModelingScene()
await scene.expectPixelColor(TEST_COLORS.WHITE, { x: 587, y: 270 }, 15)
await expect(async () => {
await page.mouse.click(700, 200)
await page.getByText('tangentialArcTo([8.33, -1.31], %)').click()
@ -137,10 +140,11 @@ test.describe('Sketch tests', () => {
await page.waitForTimeout(100)
await page.getByRole('button', { name: 'line Line', exact: true }).click()
await page.waitForTimeout(100)
await page.waitForTimeout(500)
// click start profileAt handle to continue profile
await page.mouse.click(702, 407)
await page.mouse.click(702, 406, { delay: 500 })
await page.waitForTimeout(100)
await page.mouse.move(800, 150)
await expect(async () => {
// click to add segment
@ -1379,19 +1383,19 @@ test.describe('multi-profile sketching', () => {
await test.step('Create a close profile stopping mid profile to equip the tangential arc, and than back to the line tool', async () => {
await startProfile1()
await editor.expectEditor.toContain(
`profile001 = startProfileAt([4.61, 12.21], sketch001)`
`profile001 = startProfileAt([-2.17, 12.21], sketch001)`
)
await endLineStartTanArc()
await editor.expectEditor.toContain(`|> line([9.02, -0.55], %)`)
await toolbar.tangentialArcBtn.click()
await page.waitForTimeout(100)
await endLineStartTanArc()
await page.mouse.click(745, 359)
await page.waitForTimeout(100)
await endLineStartTanArc({ delay: 544 })
await endArcStartLine()
await editor.expectEditor.toContain(
`|> tangentialArcTo([16.61, 4.14], %)`
)
await editor.expectEditor.toContain(`|> tangentialArcTo([9.83, 4.14], %)`)
await toolbar.lineBtn.click()
await page.waitForTimeout(100)
await endArcStartLine()
@ -1399,16 +1403,18 @@ test.describe('multi-profile sketching', () => {
await page.mouse.click(572, 110)
await editor.expectEditor.toContain(`|> line([-11.73, 5.35], %)`)
await startProfile1()
await editor.expectEditor
.toContain(`|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)`)
await editor.expectEditor.toContain(
`|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)`,
{ shouldNormalise: true }
)
await page.waitForTimeout(100)
})
await test.step('Without unequipping from the last step, make another profile, and one that is not closed', async () => {
await startProfile2()
await editor.expectEditor.toContain(
`profile002 = startProfileAt([19.12, 11.53], sketch001)`
`profile002 = startProfileAt([12.34, 11.53], sketch001)`
)
await profile2Point2()
await editor.expectEditor.toContain(`|> line([9.43, -0.68], %)`)
@ -1421,9 +1427,9 @@ test.describe('multi-profile sketching', () => {
await circle1Center()
await page.waitForTimeout(100)
await circle1Radius()
await circle1Radius({ delay: 500 })
await editor.expectEditor.toContain(
`profile003 = circle({ center = [23.19, 6.98], radius = 2.5 }, sketch001)`
`profile003 = circle({ center = [16.41, 6.98], radius = 2.5 }, sketch001)`
)
await test.step('hover in empty space to wait for overlays to get out of the way', async () => {

View File

@ -21,7 +21,6 @@ import { ContextMenu, ContextMenuItem } from './ContextMenu'
import usePlatform from 'hooks/usePlatform'
import { FileEntry } from 'lib/project'
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
import { normalizeLineEndings } from 'lib/codeEditor'
import { reportRejection } from 'lib/trap'
function getIndentationCSS(level: number) {