|
1 | 1 | import * as EP from '../../../../core/shared/element-path'
|
2 | 2 | import { offsetPoint, windowPoint } from '../../../../core/shared/math-utils'
|
3 |
| -import { selectComponentsForTest } from '../../../../utils/utils.test-utils' |
| 3 | +import { selectComponentsForTest, wait } from '../../../../utils/utils.test-utils' |
4 | 4 | import CanvasActions from '../../canvas-actions'
|
5 | 5 | import { GridCellTestId } from '../../controls/grid-controls-for-strategies'
|
6 | 6 | import { mouseDownAtPoint, mouseMoveToPoint, mouseUpAtPoint } from '../../event-helpers.test-utils'
|
@@ -28,6 +28,34 @@ describe('grid element change location strategy', () => {
|
28 | 28 | })
|
29 | 29 | })
|
30 | 30 |
|
| 31 | + it('does not alter the grid template', async () => { |
| 32 | + const editor = await renderTestEditorWithCode( |
| 33 | + ProjectCodeFractionalTemplate, |
| 34 | + 'await-first-dom-report', |
| 35 | + ) |
| 36 | + |
| 37 | + const testId = 'aaa' |
| 38 | + const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } = await runGridMoveTest( |
| 39 | + editor, |
| 40 | + { |
| 41 | + scale: 1, |
| 42 | + gridPath: 'sb/scene/grid', |
| 43 | + testId: testId, |
| 44 | + }, |
| 45 | + ) |
| 46 | + |
| 47 | + expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({ |
| 48 | + gridColumnEnd: '7', |
| 49 | + gridColumnStart: '3', |
| 50 | + gridRowEnd: '4', |
| 51 | + gridRowStart: '2', |
| 52 | + }) |
| 53 | + |
| 54 | + const grid = await editor.renderedDOM.findByTestId('grid') |
| 55 | + expect(grid.style.gridTemplateColumns).toEqual('1fr 1fr 2fr 2fr 1fr 1fr') |
| 56 | + expect(grid.style.gridTemplateRows).toEqual('1fr 1fr 2fr 1fr') |
| 57 | + }) |
| 58 | + |
31 | 59 | describe('component items', () => {
|
32 | 60 | it('can change the location of components on a grid when component takes style prop', async () => {
|
33 | 61 | const editor = await renderTestEditorWithCode(
|
@@ -881,6 +909,87 @@ export var storyboard = (
|
881 | 909 | )
|
882 | 910 | `
|
883 | 911 |
|
| 912 | +const ProjectCodeFractionalTemplate = `import * as React from 'react' |
| 913 | +import { Scene, Storyboard, Placeholder } from 'utopia-api' |
| 914 | +
|
| 915 | +export var storyboard = ( |
| 916 | + <Storyboard data-uid='sb'> |
| 917 | + <Scene |
| 918 | + id='playground-scene' |
| 919 | + commentId='playground-scene' |
| 920 | + style={{ |
| 921 | + width: 847, |
| 922 | + height: 895, |
| 923 | + position: 'absolute', |
| 924 | + left: 46, |
| 925 | + top: 131, |
| 926 | + }} |
| 927 | + data-label='Playground' |
| 928 | + data-uid='scene' |
| 929 | + > |
| 930 | + <div |
| 931 | + style={{ |
| 932 | + display: 'grid', |
| 933 | + gridTemplateRows: '1fr 1fr 2fr 1fr', |
| 934 | + gridTemplateColumns: |
| 935 | + '1fr 1fr 2fr 2fr 1fr 1fr', |
| 936 | + gridGap: 16, |
| 937 | + height: 482, |
| 938 | + width: 786, |
| 939 | + position: 'absolute', |
| 940 | + left: 31, |
| 941 | + top: 0, |
| 942 | + }} |
| 943 | + data-uid='grid' |
| 944 | + data-testid='grid' |
| 945 | + > |
| 946 | + <div |
| 947 | + style={{ |
| 948 | + minHeight: 0, |
| 949 | + backgroundColor: '#f3785f', |
| 950 | + gridColumnEnd: 5, |
| 951 | + gridColumnStart: 1, |
| 952 | + gridRowEnd: 3, |
| 953 | + gridRowStart: 1, |
| 954 | + }} |
| 955 | + data-uid='aaa' |
| 956 | + data-testid='aaa' |
| 957 | + /> |
| 958 | + <div |
| 959 | + style={{ |
| 960 | + minHeight: 0, |
| 961 | + backgroundColor: '#23565b', |
| 962 | + }} |
| 963 | + data-uid='bbb' |
| 964 | + data-testid='bbb' |
| 965 | + /> |
| 966 | + <Placeholder |
| 967 | + style={{ |
| 968 | + minHeight: 0, |
| 969 | + gridColumnEnd: 5, |
| 970 | + gridRowEnd: 4, |
| 971 | + gridColumnStart: 1, |
| 972 | + gridRowStart: 3, |
| 973 | + backgroundColor: '#0074ff', |
| 974 | + }} |
| 975 | + data-uid='ccc' |
| 976 | + /> |
| 977 | + <Placeholder |
| 978 | + style={{ |
| 979 | + minHeight: 0, |
| 980 | + gridColumnEnd: 9, |
| 981 | + gridRowEnd: 4, |
| 982 | + gridColumnStart: 5, |
| 983 | + gridRowStart: 3, |
| 984 | + }} |
| 985 | + data-uid='ddd' |
| 986 | + /> |
| 987 | + </div> |
| 988 | + </Scene> |
| 989 | + </Storyboard> |
| 990 | +) |
| 991 | +` |
| 992 | + |
884 | 993 | const makeProjectCodeWithItemComponent = (
|
885 | 994 | itemComponentCode: string,
|
886 | 995 | ) => `import * as React from 'react'
|
|
0 commit comments