@@ -11,6 +11,7 @@ import {
11
11
IgcColumnComponent ,
12
12
IgcPaginatorComponent ,
13
13
IgcGridStateComponent ,
14
+ IgcColumnLayoutComponent ,
14
15
} from './components' ;
15
16
import { defineComponents } from '../utils/register' ;
16
17
@@ -23,6 +24,7 @@ describe('Elements: ', () => {
23
24
IgcHierarchicalGridComponent ,
24
25
IgcPivotGridComponent ,
25
26
IgcColumnComponent ,
27
+ IgcColumnLayoutComponent ,
26
28
IgcPaginatorComponent ,
27
29
IgcGridStateComponent ,
28
30
) ;
@@ -181,5 +183,52 @@ describe('Elements: ', () => {
181
183
await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 2 ) ) ;
182
184
expect ( ( ) => stateComponent . getStateAsString ( ) ) . not . toThrow ( ) ;
183
185
} ) ;
186
+
187
+ it ( `should allow manipulating projected columns through the DOM` , async ( ) => {
188
+ const innerHtml = `
189
+ <igc-grid id="testGrid" primary-key="ProductID">
190
+ <igc-column-layout header="Product ID">
191
+ <igc-column row-start="1" col-start="1" row-end="3" field="ProductID" header="Product ID" width="25%"></igc-column>
192
+ </igc-column-layout>
193
+ <igc-column-layout header="Product Details">
194
+ <igc-column row-start="1" col-start="1" col-end="3" field="ProductName" header="Product Name"></igc-column>
195
+ <igc-column row-start="2" col-start="1" col-end="2" field="CategoryName" header="Category Name" groupable="true"></igc-column>
196
+ <igc-column row-start="2" col-start="2" col-end="3" field="ImageUrl"></igc-column>
197
+ </igc-column-layout>
198
+ <igc-column-layout header="Product Stock">
199
+ <igc-column row-start="1" col-start="1" col-end="3" field="InStock" header="In Stock" width="25%"></igc-column>
200
+ </igc-column-layout>
201
+ </igc-grid>` ;
202
+ testContainer . innerHTML = innerHtml ;
203
+
204
+ // TODO: Better way to wait - potentially expose the queue or observable for update on the strategy
205
+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
206
+
207
+ const grid = document . querySelector < IgcNgElement & InstanceType < typeof IgcGridComponent > > ( '#testGrid' ) ;
208
+ const thirdGroup = document . querySelector < IgcNgElement > ( 'igc-column-layout[header="Product Stock"]' ) ;
209
+ const secondGroup = document . querySelector < IgcNgElement > ( 'igc-column-layout[header="Product Details"]' ) ;
210
+
211
+ expect ( grid . columns . length ) . toEqual ( 8 ) ;
212
+ expect ( grid . getColumnByName ( 'ProductID' ) ) . toBeTruthy ( ) ;
213
+ expect ( grid . getColumnByVisibleIndex ( 1 ) . field ) . toEqual ( 'ProductName' ) ;
214
+
215
+ grid . removeChild ( secondGroup ) ;
216
+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
217
+
218
+ expect ( grid . columns . length ) . toEqual ( 4 ) ;
219
+ expect ( grid . getColumnByName ( 'ProductID' ) ) . toBeTruthy ( ) ;
220
+ expect ( grid . getColumnByVisibleIndex ( 1 ) . field ) . toEqual ( 'InStock' ) ;
221
+
222
+ // TODO: secondGroup can't be re-used
223
+ const newGroup = document . createElement ( 'igc-column-layout' ) ;
224
+ const newColumn = document . createElement ( 'igc-column' ) ;
225
+ newColumn . setAttribute ( 'field' , 'ProductName' ) ;
226
+ newGroup . appendChild ( newColumn ) ;
227
+ grid . insertBefore ( newGroup , thirdGroup ) ;
228
+ await firstValueFrom ( timer ( 10 /* SCHEDULE_DELAY */ * 3 ) ) ;
229
+
230
+ expect ( grid . columns . length ) . toEqual ( 6 ) ;
231
+ expect ( grid . getColumnByVisibleIndex ( 1 ) . field ) . toEqual ( 'ProductName' ) ;
232
+ } ) ;
184
233
} ) ;
185
234
} ) ;
0 commit comments