1
1
import * as EP from '../../../../core/shared/element-path'
2
- import {
3
- getRectCenter ,
4
- localRectangle ,
5
- offsetPoint ,
6
- windowPoint ,
7
- } from '../../../../core/shared/math-utils'
2
+ import { offsetPoint , windowPoint } from '../../../../core/shared/math-utils'
8
3
import { selectComponentsForTest } from '../../../../utils/utils.test-utils'
9
4
import CanvasActions from '../../canvas-actions'
10
5
import { GridCellTestId } from '../../controls/grid-controls-for-strategies'
11
6
import { mouseDownAtPoint , mouseMoveToPoint , mouseUpAtPoint } from '../../event-helpers.test-utils'
12
7
import { renderTestEditorWithCode } from '../../ui-jsx.test-utils'
13
- import { gridCellTargetId } from './grid-cell-bounds'
14
8
import { runGridMoveTest } from './grid.test-utils'
15
9
16
10
describe ( 'grid element change location strategy' , ( ) => {
@@ -22,7 +16,7 @@ describe('grid element change location strategy', () => {
22
16
editor ,
23
17
{
24
18
scale : 1 ,
25
- pathString : ` sb/scene/grid/ ${ testId } ` ,
19
+ gridPath : ' sb/scene/grid' ,
26
20
testId : testId ,
27
21
} ,
28
22
)
@@ -52,7 +46,7 @@ describe('grid element change location strategy', () => {
52
46
editor ,
53
47
{
54
48
scale : 1 ,
55
- pathString : ` sb/scene/grid/ ${ testId } ` ,
49
+ gridPath : ' sb/scene/grid' ,
56
50
testId : testId ,
57
51
} ,
58
52
)
@@ -79,7 +73,7 @@ describe('grid element change location strategy', () => {
79
73
editor ,
80
74
{
81
75
scale : 1 ,
82
- pathString : ` sb/scene/grid/ ${ testId } ` ,
76
+ gridPath : ' sb/scene/grid' ,
83
77
testId : testId ,
84
78
} ,
85
79
( ed ) => {
@@ -109,7 +103,7 @@ describe('grid element change location strategy', () => {
109
103
editor ,
110
104
{
111
105
scale : 1 ,
112
- pathString : ` sb/scene/grid/${ testId } ` ,
106
+ gridPath : ' sb/scene/grid/' ,
113
107
testId : testId ,
114
108
} ,
115
109
)
@@ -131,7 +125,7 @@ describe('grid element change location strategy', () => {
131
125
editor ,
132
126
{
133
127
scale : 1 ,
134
- pathString : ` sb/scene/grid/ ${ testId } ` ,
128
+ gridPath : ' sb/scene/grid' ,
135
129
testId : testId ,
136
130
targetCell : { row : 2 , column : 1 } ,
137
131
draggedCell : { row : 2 , column : 2 } ,
@@ -153,7 +147,7 @@ describe('grid element change location strategy', () => {
153
147
editor ,
154
148
{
155
149
scale : 1 ,
156
- pathString : ` sb/scene/grid/ ${ testId } ` ,
150
+ gridPath : ' sb/scene/grid' ,
157
151
testId : testId ,
158
152
tab : true ,
159
153
} ,
@@ -178,7 +172,7 @@ describe('grid element change location strategy', () => {
178
172
editor ,
179
173
{
180
174
scale : 1 ,
181
- pathString : ` sb/scene/grid/ ${ testId } ` ,
175
+ gridPath : ' sb/scene/grid' ,
182
176
testId : testId ,
183
177
targetCell : { row : 3 , column : 1 } ,
184
178
} ,
@@ -200,7 +194,7 @@ describe('grid element change location strategy', () => {
200
194
editor ,
201
195
{
202
196
scale : 0.5 ,
203
- pathString : ` sb/scene/grid/ ${ testId } ` ,
197
+ gridPath : ' sb/scene/grid' ,
204
198
testId : testId ,
205
199
} ,
206
200
)
@@ -220,7 +214,7 @@ describe('grid element change location strategy', () => {
220
214
editor ,
221
215
{
222
216
scale : 2 ,
223
- pathString : ` sb/scene/grid/ ${ testId } ` ,
217
+ gridPath : ' sb/scene/grid' ,
224
218
testId : testId ,
225
219
} ,
226
220
)
@@ -243,7 +237,7 @@ describe('grid element change location strategy', () => {
243
237
editor ,
244
238
{
245
239
scale : 1 ,
246
- pathString : ` sb/scene/grid/ ${ testId } ` ,
240
+ gridPath : ' sb/scene/grid' ,
247
241
testId : testId ,
248
242
} ,
249
243
)
@@ -267,7 +261,7 @@ describe('grid element change location strategy', () => {
267
261
editor ,
268
262
{
269
263
scale : 1 ,
270
- pathString : ` sb/scene/grid/ ${ testId } ` ,
264
+ gridPath : ' sb/scene/grid' ,
271
265
testId : testId ,
272
266
} ,
273
267
)
@@ -291,7 +285,7 @@ describe('grid element change location strategy', () => {
291
285
editor ,
292
286
{
293
287
scale : 1 ,
294
- pathString : ` sb/scene/grid/ ${ testId } ` ,
288
+ gridPath : ' sb/scene/grid' ,
295
289
testId : testId ,
296
290
targetCell : { row : 3 , column : 2 } ,
297
291
} ,
@@ -316,7 +310,7 @@ describe('grid element change location strategy', () => {
316
310
editor ,
317
311
{
318
312
scale : 1 ,
319
- pathString : ` sb/scene/grid/ ${ testId } ` ,
313
+ gridPath : ' sb/scene/grid' ,
320
314
testId : testId ,
321
315
} ,
322
316
)
@@ -340,7 +334,7 @@ describe('grid element change location strategy', () => {
340
334
editor ,
341
335
{
342
336
scale : 1 ,
343
- pathString : ` sb/scene/grid/ ${ testId } ` ,
337
+ gridPath : ' sb/scene/grid' ,
344
338
testId : testId ,
345
339
} ,
346
340
)
@@ -366,8 +360,6 @@ export var storyboard = (
366
360
data-testid='grid'
367
361
style={{
368
362
position: 'absolute',
369
- left: -94,
370
- top: 698,
371
363
display: 'grid',
372
364
gap: 10,
373
365
width: 600,
@@ -428,33 +420,11 @@ export var storyboard = (
428
420
)
429
421
430
422
const testId = 'grid-inside-grid'
431
- const elementPathToDrag = EP . fromString ( `sb/grid/${ testId } ` )
432
-
433
- await selectComponentsForTest ( editor , [ elementPathToDrag ] )
434
-
435
- const sourceGridCell = editor . renderedDOM . getByTestId ( GridCellTestId ( elementPathToDrag ) )
436
- const targetGridCell = editor . renderedDOM . getByTestId (
437
- gridCellTargetId ( EP . fromString ( 'sb/grid' ) , 2 , 3 ) ,
438
- )
439
-
440
- const sourceRect = sourceGridCell . getBoundingClientRect ( )
441
- const targetRect = targetGridCell . getBoundingClientRect ( )
442
-
443
- const dragFrom = {
444
- x : sourceRect . x + 10 ,
445
- y : sourceRect . y + 10 ,
446
- }
447
- const dragTo = getRectCenter (
448
- localRectangle ( {
449
- x : targetRect . x ,
450
- y : targetRect . y ,
451
- width : targetRect . width ,
452
- height : targetRect . height ,
453
- } ) ,
454
- )
455
- await mouseDownAtPoint ( sourceGridCell , dragFrom )
456
- await mouseMoveToPoint ( sourceGridCell , dragTo )
457
- await mouseUpAtPoint ( sourceGridCell , dragTo )
423
+ await runGridMoveTest ( editor , {
424
+ scale : 1 ,
425
+ gridPath : 'sb/grid' ,
426
+ testId : testId ,
427
+ } )
458
428
459
429
const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } =
460
430
editor . renderedDOM . getByTestId ( testId ) . style
0 commit comments