Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Pointer Lock For Scrubbing #6239

Merged
merged 7 commits into from
Aug 21, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ import * as EP from '../../../../../core/shared/element-path'
import { selectComponentsForTest } from '../../../../../utils/utils.test-utils'
import { RegisteredCanvasStrategies } from '../../../../canvas/canvas-strategies/canvas-strategies'
import { act, fireEvent } from '@testing-library/react'
import { mouseClickAtPoint } from '../../../../canvas/event-helpers.test-utils'
import {
mouseClickAtPoint,
mouseDownAtPoint,
mouseDragFromPointToPoint,
mouseMoveToPoint,
pressKey,
} from '../../../../canvas/event-helpers.test-utils'
import { getDomRectCenter } from '../../../../../core/shared/dom-utils'
import { getFixedHugDropdownId } from '../../../fill-hug-fixed-control'

Expand Down Expand Up @@ -144,6 +150,77 @@ describe('Frame updating layout section', () => {
}

describe('Left control', () => {
it(
'scrubbing the left control label',
makeTestCase({
baseProject: `<div
style={{
height: '100%',
width: '100%',
contain: 'layout',
}}
data-uid={'root-div'}
>
<Rectangle
style={{
backgroundColor: '#FF69B4AB',
position: 'absolute',
left: 90,
top: 100,
width: 200,
height: 300,
}}
data-uid={'rectangle-1'}
/>
</div>`,
actionChange: async (renderResult) => {
// Select the rectangle.
await selectComponentsForTest(renderResult, [
EP.fromString(
`${BakedInStoryboardUID}/${TestSceneUID}/${TestAppUID}:root-div/rectangle-1`,
),
])

const scrubLabel = await renderResult.renderedDOM.findByTestId(
`frame-left-number-input-label-div`,
)
const scrubLabelBounds = scrubLabel.getBoundingClientRect()
const scrubLabelCenter = getDomRectCenter(scrubLabelBounds)
const scrubLabelEndPoint = { x: scrubLabelCenter.x + 100, y: scrubLabelCenter.y }
await mouseDragFromPointToPoint(scrubLabel, scrubLabelCenter, scrubLabelEndPoint)
},
expectedFrames: {
[`${BakedInStoryboardUID}/${TestSceneUID}/${TestAppUID}:root-div/rectangle-1`]:
localRectangle({
x: 140,
y: 100,
width: 200,
height: 300,
}),
},
expectedProject: `<div
style={{
height: '100%',
width: '100%',
contain: 'layout',
}}
>
<Rectangle
style={{
backgroundColor: '#FF69B4AB',
position: 'absolute',
left: 140,
top: 100,
width: 200,
height: 300,
}}
/>
</div>`,
expectedFixedHugDropdownWidthValue: 'Fixed',
expectedFixedHugDropdownHeightValue: 'Fixed',
}),
)

it(
'with a single element selected when setting value directly',
makeTestCase({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ Array [
"//div//Symbol(react.memo)(NumberInput)",
"//div//Symbol(react.forward_ref)(Styled(div))",
"/div//Symbol(react.forward_ref)(Styled(div))/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/img",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div:data-testid='radius-one-mouse-down-handler'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -438,6 +440,8 @@ Array [
"//div//Symbol(react.memo)(NumberInput)",
"//div//Symbol(react.forward_ref)(Styled(div))",
"/div//Symbol(react.forward_ref)(Styled(div))/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/img",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div:data-testid='padding-V-mouse-down-handler'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand All @@ -446,6 +450,8 @@ Array [
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/Symbol(react.forward_ref)(EmotionCssPropInternal)/Symbol(react.memo)(Symbol(react.forward_ref)())",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/Symbol(react.memo)(Symbol(react.forward_ref)())/Symbol(react.forward_ref)()/Symbol(react.forward_ref)(Styled(input)):data-testid='padding-V'",
"/Symbol(react.memo)(Symbol(react.forward_ref)())/Symbol(react.forward_ref)()/Symbol(react.forward_ref)(Styled(input))/input:data-testid='padding-V'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/img",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div:data-testid='padding-H-mouse-down-handler'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -551,7 +557,9 @@ Array [
"/div/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/img",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div:data-testid='frame-left-number-input-label-div'",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand All @@ -573,7 +581,9 @@ Array [
"/div/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/img",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div:data-testid='frame-top-number-input-label-div'",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -1035,6 +1045,8 @@ Array [
"//div//Symbol(react.memo)(NumberInput)",
"//div//Symbol(react.forward_ref)(Styled(div))",
"/div//Symbol(react.forward_ref)(Styled(div))/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/img",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div:data-testid='radius-one-mouse-down-handler'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -1062,6 +1074,8 @@ Array [
"//div//Symbol(react.memo)(NumberInput)",
"//div//Symbol(react.forward_ref)(Styled(div))",
"/div//Symbol(react.forward_ref)(Styled(div))/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/img",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div:data-testid='padding-V-mouse-down-handler'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand All @@ -1070,6 +1084,8 @@ Array [
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/Symbol(react.forward_ref)(EmotionCssPropInternal)/Symbol(react.memo)(Symbol(react.forward_ref)())",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/Symbol(react.memo)(Symbol(react.forward_ref)())/Symbol(react.forward_ref)()/Symbol(react.forward_ref)(Styled(input)):data-testid='padding-V'",
"/Symbol(react.memo)(Symbol(react.forward_ref)())/Symbol(react.forward_ref)()/Symbol(react.forward_ref)(Styled(input))/input:data-testid='padding-V'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/img",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/div:data-testid='padding-H-mouse-down-handler'",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/Symbol(react.forward_ref)(Styled(div))/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand All @@ -1093,7 +1109,9 @@ Array [
"/div/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/img",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div:data-testid='frame-left-number-input-label-div'",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand All @@ -1115,7 +1133,9 @@ Array [
"/div/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/FrameUpdatingLayoutControl/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/img",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div:data-testid='frame-top-number-input-label-div'",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div/NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -1415,6 +1435,8 @@ Array [
"/OpacityRow/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div//Symbol(react.memo)(NumberInput)",
"/div//NumberInput/img",
"/div//NumberInput/div",
"/div//NumberInput/div:data-testid='opacity-mouse-down-handler'",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -1986,6 +2008,8 @@ Array [
"/OpacityRow/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div//Symbol(react.memo)(NumberInput)",
"/div//NumberInput/img",
"/div//NumberInput/div",
"/div//NumberInput/div:data-testid='opacity-mouse-down-handler'",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -2509,6 +2533,8 @@ Array [
"/OpacityRow/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div//Symbol(react.memo)(NumberInput)",
"/div//NumberInput/img",
"/div//NumberInput/div",
"/div//NumberInput/div:data-testid='opacity-mouse-down-handler'",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down Expand Up @@ -2910,6 +2936,8 @@ Array [
"/OpacityRow/UtopiaSpiedFunctionComponent(InspectorContextMenuWrapper)/Symbol(react.forward_ref)(EmotionCssPropInternal)/div",
"/Symbol(react.forward_ref)(EmotionCssPropInternal)/div/UtopiaSpiedFunctionComponent(MenuProvider)/div",
"/UtopiaSpiedFunctionComponent(MenuProvider)/div//Symbol(react.memo)(NumberInput)",
"/div//NumberInput/img",
"/div//NumberInput/div",
"/div//NumberInput/div:data-testid='opacity-mouse-down-handler'",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
"/div//NumberInput/Symbol(react.forward_ref)(EmotionCssPropInternal)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('React Render Count Tests -', () => {

const renderCountAfter = renderResult.getNumberOfRenders()
// if this breaks, GREAT NEWS but update the test please :)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`749`)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`753`)
expect(renderResult.getRenderInfo()).toMatchSnapshot()
})

Expand Down Expand Up @@ -127,7 +127,7 @@ describe('React Render Count Tests -', () => {

const renderCountAfter = renderResult.getNumberOfRenders()
// if this breaks, GREAT NEWS but update the test please :)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`1097`)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`1101`)
expect(renderResult.getRenderInfo()).toMatchSnapshot()
})

Expand Down Expand Up @@ -183,7 +183,7 @@ describe('React Render Count Tests -', () => {

const renderCountAfter = renderResult.getNumberOfRenders()
// if this breaks, GREAT NEWS but update the test please :)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`531`)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`541`)
expect(renderResult.getRenderInfo()).toMatchSnapshot()
})

Expand Down Expand Up @@ -249,7 +249,7 @@ describe('React Render Count Tests -', () => {

const renderCountAfter = renderResult.getNumberOfRenders()
// if this breaks, GREAT NEWS but update the test please :)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`704`)
expect(renderCountAfter - renderCountBefore).toMatchInlineSnapshot(`714`)
expect(renderResult.getRenderInfo()).toMatchSnapshot()
})
})
Loading
Loading