@@ -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 ,
@@ -1248,6 +1249,41 @@ describe('CdkDrag', () => {
1248
1249
expect ( preview . parentNode ) . toBeFalsy ( 'Expected preview to be removed from the DOM' ) ;
1249
1250
} ) ) ;
1250
1251
1252
+ it ( 'should create the preview inside the fullscreen element when in fullscreen mode' ,
1253
+ fakeAsync ( ( ) => {
1254
+ // Provide a limited stub of the document since we can't trigger fullscreen
1255
+ // mode in unit tests and there are some issues with doing it in e2e tests.
1256
+ const fakeDocument = {
1257
+ body : document . body ,
1258
+ fullscreenElement : document . createElement ( 'div' ) ,
1259
+ ELEMENT_NODE : Node . ELEMENT_NODE ,
1260
+ querySelectorAll : function ( ) {
1261
+ return document . querySelectorAll . apply ( document , arguments ) ;
1262
+ } ,
1263
+ addEventListener : function ( ) {
1264
+ document . addEventListener . apply ( document , arguments ) ;
1265
+ } ,
1266
+ removeEventListener : function ( ) {
1267
+ document . addEventListener . apply ( document , arguments ) ;
1268
+ }
1269
+ } ;
1270
+ const fixture = createComponent ( DraggableInDropZone , [ {
1271
+ provide : DOCUMENT ,
1272
+ useFactory : ( ) => fakeDocument
1273
+ } ] ) ;
1274
+ fixture . detectChanges ( ) ;
1275
+ const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
1276
+
1277
+ document . body . appendChild ( fakeDocument . fullscreenElement ) ;
1278
+ startDraggingViaMouse ( fixture , item ) ;
1279
+ flush ( ) ;
1280
+
1281
+ const preview = document . querySelector ( '.cdk-drag-preview' ) ! as HTMLElement ;
1282
+
1283
+ expect ( preview . parentNode ) . toBe ( fakeDocument . fullscreenElement ) ;
1284
+ fakeDocument . fullscreenElement . parentNode ! . removeChild ( fakeDocument . fullscreenElement ) ;
1285
+ } ) ) ;
1286
+
1251
1287
it ( 'should be able to constrain the preview position' , fakeAsync ( ( ) => {
1252
1288
const fixture = createComponent ( DraggableInDropZone ) ;
1253
1289
fixture . componentInstance . boundarySelector = '.cdk-drop-list' ;
0 commit comments