@@ -6,20 +6,22 @@ import { By } from '@angular/platform-browser';
6
6
import { UIInteractions , wait } from '../../test-utils/ui-interactions.spec' ;
7
7
import { IgxGridModule } from './index' ;
8
8
import { IgxGridComponent } from './grid.component' ;
9
- import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
10
9
import { IgxGridRowComponent } from './grid-row.component' ;
10
+ import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
11
11
import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
12
+ import { IgxGridExpandableCellComponent } from './expandable-cell.component' ;
12
13
13
14
const COLLAPSED_ICON_NAME = 'chevron_right' ;
14
15
const EXPANDED_ICON_NAME = 'expand_more' ;
15
16
const DEBOUNCETIME = 30 ;
16
17
17
- describe ( 'IgxGrid Master Detail' , ( ) => {
18
+ describe ( 'IgxGrid Master Detail #grid ' , ( ) => {
18
19
let fix : ComponentFixture < any > ;
19
20
let grid : IgxGridComponent ;
20
21
22
+ configureTestSuite ( ) ;
23
+
21
24
describe ( 'Basic' , ( ) => {
22
- configureTestSuite ( ) ;
23
25
beforeEach ( async ( ( ) => {
24
26
TestBed . configureTestingModule ( {
25
27
declarations : [
@@ -132,7 +134,6 @@ describe('IgxGrid Master Detail', () => {
132
134
} ) ;
133
135
134
136
describe ( 'Keyboard Navigation ' , ( ) => {
135
- configureTestSuite ( ) ;
136
137
beforeEach ( async ( ( ) => {
137
138
TestBed . configureTestingModule ( {
138
139
declarations : [
@@ -232,7 +233,6 @@ describe('IgxGrid Master Detail', () => {
232
233
} ) ;
233
234
234
235
describe ( 'Integration' , ( ) => {
235
- configureTestSuite ( ) ;
236
236
beforeEach ( async ( ( ) => {
237
237
TestBed . configureTestingModule ( {
238
238
declarations : [
@@ -277,12 +277,70 @@ describe('IgxGrid Master Detail', () => {
277
277
expect ( checkbox . nativeElement . attributes [ 'aria-checked' ] . value ) . toEqual ( 'true' ) ;
278
278
} ) ;
279
279
} ) ;
280
+
281
+ describe ( 'Hiding' , ( ) => {
282
+ it ( 'Should set the expand/collapse icon to the new first visible column when hiding the first column.' , ( ) => {
283
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
284
+ grid = fix . componentInstance . grid ;
285
+ fix . detectChanges ( ) ;
286
+ grid . columnList . first . hidden = true ;
287
+ fix . detectChanges ( ) ;
288
+ expect ( grid . rowList . first . cells . first instanceof IgxGridExpandableCellComponent ) . toBeTruthy ( ) ;
289
+ } ) ;
290
+ } ) ;
291
+
292
+ describe ( 'Pinning' , ( ) => {
293
+ it ( 'Should keep/move the expand/collapse icon to the correct column when pinning the first column or another one.' , ( ) => {
294
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
295
+ grid = fix . componentInstance . grid ;
296
+ fix . detectChanges ( ) ;
297
+ grid . columnList . last . pin ( ) ;
298
+ fix . detectChanges ( ) ;
299
+ expect ( grid . rowList . first . cells . first instanceof IgxGridExpandableCellComponent ) . toBeTruthy ( ) ;
300
+ grid . pinnedColumns [ 0 ] . unpin ( ) ;
301
+ fix . detectChanges ( ) ;
302
+ expect ( grid . rowList . first . cells . first instanceof IgxGridExpandableCellComponent ) . toBeTruthy ( ) ;
303
+ } ) ;
304
+
305
+ it ( 'Should render detail view correctly when expanding a master row and there are pinned columns.' , ( ) => {
306
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
307
+ grid = fix . componentInstance . grid ;
308
+ fix . detectChanges ( ) ;
309
+ grid . columnList . last . pin ( ) ;
310
+ grid . expand ( fix . componentInstance . data [ 0 ] . ID ) ;
311
+ fix . detectChanges ( ) ;
312
+ const firstRowDetail = GridFunctions . getMasterRowDetail ( grid . rowList . first ) ;
313
+
314
+ expect ( firstRowDetail . querySelector ( '.addressArea' ) . innerText ) . toEqual ( 'Obere Str. 57' ) ;
315
+ expect ( firstRowDetail . querySelector ( '.igx-grid__hierarchical-indent' ) ) . toBeDefined ( ) ;
316
+ } ) ;
317
+ } ) ;
318
+
319
+ describe ( 'Column Moving' , ( ) => {
320
+ it ( 'Should keep the expand/collapse icon in the first column, even when moving a column in first place.' , ( ) => {
321
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
322
+ grid = fix . componentInstance . grid ;
323
+ fix . detectChanges ( ) ;
324
+ grid . moveColumn ( grid . columnList . last , grid . columnList . first ) ;
325
+ fix . detectChanges ( ) ;
326
+ expect ( grid . rowList . first . cells . first instanceof IgxGridExpandableCellComponent ) . toBeTruthy ( ) ;
327
+ } ) ;
328
+ it ( 'Should keep the expand/collapse icon in the first column, even when moving a column out of first place.' , ( ) => {
329
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
330
+ grid = fix . componentInstance . grid ;
331
+ fix . detectChanges ( ) ;
332
+ grid . moveColumn ( grid . columnList . first , grid . columnList . last ) ;
333
+ fix . detectChanges ( ) ;
334
+ expect ( grid . rowList . first . cells . first instanceof IgxGridExpandableCellComponent ) . toBeTruthy ( ) ;
335
+ } ) ;
336
+ } ) ;
280
337
} ) ;
281
338
} ) ;
282
339
283
340
@Component ( {
284
341
template : `
285
- <igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'" [paging]="paging" [perPage]="perPage" [rowSelectable]="rowSelectable">
342
+ <igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'"
343
+ [paging]="paging" [perPage]="perPage" [rowSelectable]="rowSelectable">
286
344
<igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType'
287
345
[hidden]='c.hidden' [sortable]="c.sortable" [movable]='c.movable' [groupable]='c.groupable' [editable]="c.editable"
288
346
[hasSummary]="c.hasSummary" [pinned]='c.pinned'>
@@ -314,13 +372,15 @@ export class DefaultGridMasterDetailComponent {
314
372
public perPage = 15 ;
315
373
public rowSelectable = false ;
316
374
317
- public onCheckboxClicked = ( ) => { } ;
318
-
319
375
@ViewChild ( IgxGridComponent , { read : IgxGridComponent , static : true } )
320
376
public grid : IgxGridComponent ;
321
377
322
378
public checkboxChanged : EventEmitter < any > ;
323
379
380
+ public onCheckboxClicked ( ) {
381
+
382
+ }
383
+
324
384
public checkboxClicked ( event , context ) {
325
385
this . checkboxChanged . emit ( { event : event , context : context } ) ;
326
386
}
0 commit comments