@@ -298,6 +298,45 @@ export const Create = () => {
298
298
} ) ;
299
299
} ) ;
300
300
} ) ;
301
+
302
+ QUnit . module ( 'Drag and Drop' , ( ) => {
303
+ // This module is about simulating the creation of elements by the dnd mechanism, which uses the `create`
304
+ // command indirectly. This is done by the `createElementFromModel` method.
305
+ QUnit . test ( 'Widget: Inner Section into Column' , ( assert ) => {
306
+ const eSection = ElementsHelper . createSection ( 1 ) ,
307
+ eColumn = eSection . children [ 0 ] ,
308
+ eInnerSection = ( ( ) => {
309
+ try {
310
+ return eColumn . view . createElementFromModel ( {
311
+ elType : 'section' ,
312
+ isInner : true ,
313
+ } ) ;
314
+ } catch ( e ) {
315
+ return false ;
316
+ }
317
+ } ) ( ) ;
318
+
319
+ const isInnerSectionCreated = ! ! eColumn . children . find ( ( widget ) => eInnerSection . id === widget . id ) ;
320
+
321
+ assert . equal ( isInnerSectionCreated , true , 'inner section were created.' ) ;
322
+ assert . equal ( eInnerSection . children ?. length , DEFAULT_INNER_SECTION_COLUMNS ,
323
+ `'${ DEFAULT_INNER_SECTION_COLUMNS } ' columns were created in the inner section.` ) ;
324
+ } ) ;
325
+
326
+ QUnit . test ( 'Widget: Inner Section into Preview' , ( assert ) => {
327
+ const eInnerSection = elementor . getPreviewContainer ( ) . view . createElementFromModel ( {
328
+ elType : 'section' ,
329
+ isInner : true ,
330
+ } ) ,
331
+ ePreviewChildren = elementor . getPreviewContainer ( ) . children ,
332
+ isInnerSectionCreated = ! ! ePreviewChildren [ ePreviewChildren . length - 1 ] . children [ 0 ] . children
333
+ . find ( ( widget ) => eInnerSection . id === widget . id ) ;
334
+
335
+ assert . equal ( isInnerSectionCreated , true , 'inner section were created.' ) ;
336
+ assert . equal ( eInnerSection . children . length , DEFAULT_INNER_SECTION_COLUMNS ,
337
+ `'${ DEFAULT_INNER_SECTION_COLUMNS } ' columns were created in the inner section.` ) ;
338
+ } ) ;
339
+ } ) ;
301
340
} ) ;
302
341
} ;
303
342
0 commit comments