@@ -12,6 +12,7 @@ import {
12
12
ChangeDetectionStrategy ,
13
13
} from '@angular/core' ;
14
14
import { TestBed , ComponentFixture , fakeAsync , flush , tick } from '@angular/core/testing' ;
15
+ import { DOCUMENT } from '@angular/common' ;
15
16
import { DragDropModule } from '../drag-drop-module' ;
16
17
import {
17
18
createMouseEvent ,
@@ -1320,6 +1321,41 @@ describe('CdkDrag', () => {
1320
1321
expect ( preview . parentNode ) . toBeFalsy ( 'Expected preview to be removed from the DOM' ) ;
1321
1322
} ) ) ;
1322
1323
1324
+ it ( 'should create the preview inside the fullscreen element when in fullscreen mode' ,
1325
+ fakeAsync ( ( ) => {
1326
+ // Provide a limited stub of the document since we can't trigger fullscreen
1327
+ // mode in unit tests and there are some issues with doing it in e2e tests.
1328
+ const fakeDocument = {
1329
+ body : document . body ,
1330
+ fullscreenElement : document . createElement ( 'div' ) ,
1331
+ ELEMENT_NODE : Node . ELEMENT_NODE ,
1332
+ querySelectorAll : function ( ) {
1333
+ return document . querySelectorAll . apply ( document , arguments ) ;
1334
+ } ,
1335
+ addEventListener : function ( ) {
1336
+ document . addEventListener . apply ( document , arguments ) ;
1337
+ } ,
1338
+ removeEventListener : function ( ) {
1339
+ document . addEventListener . apply ( document , arguments ) ;
1340
+ }
1341
+ } ;
1342
+ const fixture = createComponent ( DraggableInDropZone , [ {
1343
+ provide : DOCUMENT ,
1344
+ useFactory : ( ) => fakeDocument
1345
+ } ] ) ;
1346
+ fixture . detectChanges ( ) ;
1347
+ const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
1348
+
1349
+ document . body . appendChild ( fakeDocument . fullscreenElement ) ;
1350
+ startDraggingViaMouse ( fixture , item ) ;
1351
+ flush ( ) ;
1352
+
1353
+ const preview = document . querySelector ( '.cdk-drag-preview' ) ! as HTMLElement ;
1354
+
1355
+ expect ( preview . parentNode ) . toBe ( fakeDocument . fullscreenElement ) ;
1356
+ fakeDocument . fullscreenElement . parentNode ! . removeChild ( fakeDocument . fullscreenElement ) ;
1357
+ } ) ) ;
1358
+
1323
1359
it ( 'should be able to constrain the preview position' , fakeAsync ( ( ) => {
1324
1360
const fixture = createComponent ( DraggableInDropZone ) ;
1325
1361
fixture . componentInstance . boundarySelector = '.cdk-drop-list' ;
0 commit comments