Skip to content

Commit 5a3712b

Browse files
authored
Merge pull request #6330 from IgniteUI/dmdimitrov/issue6224-8.2.x
Fixed index of last pinned column & awaiting async methods
2 parents ffd7b45 + 3cd8602 commit 5a3712b

File tree

4 files changed

+66
-40
lines changed

4 files changed

+66
-40
lines changed

projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ describe('Excel Exporter', () => {
7676
fix.detectChanges();
7777

7878
let wrapper = await getExportedData(grid, options);
79-
wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row only should have been exported!');
79+
await wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row only should have been exported!');
8080

8181
options.ignoreFiltering = true;
8282
fix.detectChanges();
8383
wrapper = await getExportedData(grid, options);
84-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All 10 rows should have been exported!');
84+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All 10 rows should have been exported!');
8585
});
8686

8787
it('should honor filter criteria changes.', async () => {
@@ -92,14 +92,14 @@ describe('Excel Exporter', () => {
9292
options.ignoreFiltering = false;
9393

9494
let wrapper = await getExportedData(grid, options);
95-
wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row should have been exported!');
95+
await wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row should have been exported!');
9696

9797
grid.filter('JobTitle', 'Director', IgxStringFilteringOperand.instance().condition('equals'), true);
9898
fix.detectChanges();
9999

100100
expect(grid.rowList.length).toEqual(2, 'Invalid number of rows after filtering!');
101101
wrapper = await getExportedData(grid, options);
102-
wrapper.verifyDataFilesContent(actualData.simpleGridDataDirectors, 'Two rows should have been exported!');
102+
await wrapper.verifyDataFilesContent(actualData.simpleGridDataDirectors, 'Two rows should have been exported!');
103103
});
104104

105105
it('should honor \'ignoreColumnsVisibility\' option.', async () => {
@@ -115,12 +115,12 @@ describe('Excel Exporter', () => {
115115

116116
expect(grid.visibleColumns.length).toEqual(2, 'Invalid number of visible columns!');
117117
let wrapper = await getExportedData(grid, options);
118-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
118+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
119119

120120
options.ignoreColumnsVisibility = true;
121121
fix.detectChanges();
122122
wrapper = await getExportedData(grid, options);
123-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All three columns should have been exported!');
123+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All three columns should have been exported!');
124124
});
125125

126126
it('should honor columns visibility changes.', async () => {
@@ -134,28 +134,28 @@ describe('Excel Exporter', () => {
134134

135135
expect(grid.visibleColumns.length).toEqual(3, 'Invalid number of visible columns!');
136136
let wrapper = await getExportedData(grid, options);
137-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
137+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
138138

139139
grid.columns[0].hidden = true;
140140
fix.detectChanges();
141141

142142
expect(grid.visibleColumns.length).toEqual(2, 'Invalid number of visible columns!');
143143
wrapper = await getExportedData(grid, options);
144-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
144+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
145145

146146
grid.columns[0].hidden = false;
147147
fix.detectChanges();
148148

149149
expect(grid.visibleColumns.length).toEqual(3, 'Invalid number of visible columns!');
150150
wrapper = await getExportedData(grid, options);
151-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
151+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
152152

153153
grid.columns[0].hidden = undefined;
154154
fix.detectChanges();
155155

156156
expect(grid.visibleColumns.length).toEqual(3, 'Invalid number of visible columns!');
157157
wrapper = await getExportedData(grid, options);
158-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
158+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
159159
});
160160

161161
it('should honor columns declaration order.', async () => {
@@ -166,7 +166,7 @@ describe('Excel Exporter', () => {
166166
const grid = fix.componentInstance.grid;
167167

168168
const wrapper = await getExportedData(grid, options);
169-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitleID);
169+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitleID);
170170
});
171171

172172
it('should honor \'ignorePinning\' option.', async () => {
@@ -179,13 +179,13 @@ describe('Excel Exporter', () => {
179179

180180
let wrapper = await getExportedData(grid, options);
181181
wrapper.verifyStructure();
182-
// wrapper.verifyTemplateFilesContent();
183-
wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
182+
// await wrapper.verifyTemplateFilesContent();
183+
await wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
184184

185185
options.ignorePinning = true;
186186
fix.detectChanges();
187187
wrapper = await getExportedData(grid, options);
188-
wrapper.verifyDataFilesContent(actualData.gridNameIDJobTitle, 'No frozen columns should have been exported!');
188+
await wrapper.verifyDataFilesContent(actualData.gridNameIDJobTitle, 'No frozen columns should have been exported!');
189189
});
190190

191191
it('should honor pinned state changes.', async () => {
@@ -194,12 +194,22 @@ describe('Excel Exporter', () => {
194194
const grid = result.grid;
195195

196196
let wrapper = await getExportedData(grid, options);
197-
wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
197+
await wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
198198

199199
grid.columns[1].pinned = false;
200200
fix.detectChanges();
201201
wrapper = await getExportedData(grid, options);
202-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'No frozen columns should have been exported!');
202+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'No frozen columns should have been exported!');
203+
});
204+
205+
it('should honor all pinned columns.', async() => {
206+
const result = await TestMethods.createGridAndPinColumn(2, 0);
207+
const fix = result.fixture;
208+
const grid = result.grid;
209+
210+
const wrapper = await getExportedData(grid, options);
211+
wrapper.verifyStructure();
212+
await wrapper.verifyDataFilesContent(actualData.gridJobTitleIdFrozen, 'Not all pinned columns are frozen in the export!');
203213
});
204214

205215
it('should honor applied sorting.', async () => {
@@ -212,7 +222,7 @@ describe('Excel Exporter', () => {
212222
fix.detectChanges();
213223

214224
const wrapper = await getExportedData(grid, options);
215-
wrapper.verifyDataFilesContent(actualData.simpleGridSortByName);
225+
await wrapper.verifyDataFilesContent(actualData.simpleGridSortByName);
216226

217227
// XXX : ???? What's the point of this?
218228
// grid.clearSort();
@@ -229,20 +239,21 @@ describe('Excel Exporter', () => {
229239
fix.detectChanges();
230240

231241
let wrapper = await getExportedData(grid, options);
232-
wrapper.verifyDataFilesContent(actualData.simpleGridSortByName, 'Ascending sorted data should have been exported.');
242+
await wrapper.verifyDataFilesContent(actualData.simpleGridSortByName, 'Ascending sorted data should have been exported.');
233243

234244
grid.sort({fieldName: 'Name', dir: SortingDirection.Desc, ignoreCase: true, strategy: DefaultSortingStrategy.instance()});
235245
fix.detectChanges();
236246

237247
wrapper = await getExportedData(grid, options);
238-
wrapper.verifyDataFilesContent(actualData.simpleGridSortByNameDesc(true), 'Descending sorted data should have been exported.');
248+
await wrapper.verifyDataFilesContent(
249+
actualData.simpleGridSortByNameDesc(true), 'Descending sorted data should have been exported.');
239250

240251
grid.clearSort();
241252
grid.sort({fieldName: 'ID', dir: SortingDirection.Asc, ignoreCase: true, strategy: DefaultSortingStrategy.instance()});
242253
fix.detectChanges();
243254

244255
// wrapper = await getExportedData(grid, options);
245-
// wrapper.verifyDataFilesContent(actualData.simpleGridSortByNameDesc(false), 'Unsorted data should have been exported.');
256+
// await wrapper.verifyDataFilesContent(actualData.simpleGridSortByNameDesc(false), 'Unsorted data should have been exported.');
246257
});
247258

248259
it('should export all columns with the width specified in options.', async () => {
@@ -323,7 +334,7 @@ describe('Excel Exporter', () => {
323334
expect(cols[0].index).toBe(0);
324335
expect(cols[1].header).toBe('JobTitle');
325336
expect(cols[1].index).toBe(1);
326-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle);
337+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle);
327338
});
328339

329340
it('should not export columns when \'onColumnExport\' is canceled.', async () => {
@@ -340,7 +351,7 @@ describe('Excel Exporter', () => {
340351
const wrapper = await getExportedData(grid, options);
341352
expect(wrapper.hasValues).toBe(false);
342353
wrapper.verifyStructure();
343-
wrapper.verifyTemplateFilesContent();
354+
await wrapper.verifyTemplateFilesContent();
344355
});
345356

346357
it('should fire \'onRowExport\' for each grid row.', async () => {
@@ -378,7 +389,7 @@ describe('Excel Exporter', () => {
378389
const wrapper = await getExportedData(grid, options);
379390
expect(wrapper.hasValues).toBe(false);
380391
wrapper.verifyStructure();
381-
wrapper.verifyTemplateFilesContent();
392+
await wrapper.verifyTemplateFilesContent();
382393
});
383394

384395
it('shouldn\'t affect grid sort expressions', async () => {

projects/igniteui-angular/src/lib/services/excel/excel-exporter.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,76 +28,76 @@ describe('Excel Exporter', () => {
2828
const wrapper = await getExportedData([], options);
2929

3030
wrapper.verifyStructure();
31-
wrapper.verifyTemplateFilesContent();
31+
await wrapper.verifyTemplateFilesContent();
3232
});
3333

3434
it('should export empty objects successfully.', async () => {
3535
const wrapper = await getExportedData(SampleTestData.emptyObjectData(), options);
3636

3737
wrapper.verifyStructure();
38-
wrapper.verifyTemplateFilesContent();
38+
await wrapper.verifyTemplateFilesContent();
3939
});
4040

4141
it('should export string data without headers successfully.', async () => {
4242
options.columnWidth = 50;
4343
const wrapper = await getExportedData(SampleTestData.stringArray(), options);
4444

4545
wrapper.verifyStructure();
46-
wrapper.verifyTemplateFilesContent();
47-
wrapper.verifyDataFilesContent(actualData.noHeadersStringDataContent);
46+
await wrapper.verifyTemplateFilesContent();
47+
await wrapper.verifyDataFilesContent(actualData.noHeadersStringDataContent);
4848
});
4949

5050
it('should export date time data without headers successfully.', async () => {
5151
options.columnWidth = 50;
5252
const wrapper = await getExportedData(SampleTestData.dateArray(), options);
5353

5454
wrapper.verifyStructure();
55-
wrapper.verifyTemplateFilesContent();
56-
wrapper.verifyDataFilesContent(actualData.noHeadersDateTimeContent);
55+
await wrapper.verifyTemplateFilesContent();
56+
await wrapper.verifyDataFilesContent(actualData.noHeadersDateTimeContent);
5757
});
5858

5959
it('should export number data without headers successfully.', async () => {
6060
options.columnWidth = 50;
6161
const wrapper = await getExportedData(SampleTestData.numbersArray(), options);
6262

6363
wrapper.verifyStructure();
64-
// wrapper.verifyTemplateFilesContent();
65-
wrapper.verifyDataFilesContent(actualData.noHeadersNumberDataContent);
64+
// await wrapper.verifyTemplateFilesContent();
65+
await wrapper.verifyDataFilesContent(actualData.noHeadersNumberDataContent);
6666
});
6767

6868
it('should export object data without headers successfully.', async () => {
6969
const wrapper = await getExportedData(SampleTestData.noHeadersObjectArray(), options);
7070

7171
wrapper.verifyStructure();
72-
wrapper.verifyTemplateFilesContent();
73-
wrapper.verifyDataFilesContent(actualData.noHeadersObjectDataContent);
72+
await wrapper.verifyTemplateFilesContent();
73+
await wrapper.verifyDataFilesContent(actualData.noHeadersObjectDataContent);
7474
});
7575

7676
it('should export regular data successfully.', async () => {
7777
options.columnWidth = 50;
7878
const wrapper = await getExportedData(SampleTestData.contactsData(), options);
7979

8080
wrapper.verifyStructure();
81-
wrapper.verifyTemplateFilesContent();
82-
wrapper.verifyDataFilesContent(actualData.contactsDataContent);
81+
await wrapper.verifyTemplateFilesContent();
82+
await wrapper.verifyDataFilesContent(actualData.contactsDataContent);
8383
});
8484

8585
it('should export data with missing values successfully.', async () => {
8686
options.columnWidth = 50;
8787
const wrapper = await getExportedData(SampleTestData.contactsDataPartial(), options);
8888

8989
wrapper.verifyStructure();
90-
wrapper.verifyTemplateFilesContent();
91-
wrapper.verifyDataFilesContent(actualData.contactsPartialDataContent);
90+
await wrapper.verifyTemplateFilesContent();
91+
await wrapper.verifyDataFilesContent(actualData.contactsPartialDataContent);
9292
});
9393

9494
it('should export data with special characters successully.', async () => {
9595
options.columnWidth = 50;
9696
const wrapper = await getExportedData(SampleTestData.contactsFunkyData(), options);
9797

9898
wrapper.verifyStructure();
99-
wrapper.verifyTemplateFilesContent();
100-
wrapper.verifyDataFilesContent(actualData.contactsFunkyDataContent);
99+
await wrapper.verifyTemplateFilesContent();
100+
await wrapper.verifyDataFilesContent(actualData.contactsFunkyDataContent);
101101
});
102102

103103
it('should throw an exception when setting negative width and height.', () => {

projects/igniteui-angular/src/lib/services/excel/test-data.service.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,21 @@ export class FileContentData {
699699
return this.createData();
700700
}
701701

702+
get gridJobTitleIdFrozen() {
703+
this._sharedStringsData = `count="23" uniqueCount="21"><si><t>JobTitle</t></si><si><t>ID</t></si><si><t>Name</t></si><si><t>Vice President</t></si><si><t>Casey Houston</t></si><si><t>Director</t></si><si><t>Gilberto Todd</t></si><si><t>Tanya Bennett</t></si><si><t>Software Developer</t></si><si><t>Jack Simon</t></si><si><t>Senior Software Developer</t></si><si><t>Celia Martinez</t></si><si><t>CEO</t></si><si><t>Erma Walsh</t></si><si><t>Associate Software Developer</t></si><si><t>Debra Morton</t></si><si><t>Software Development Team Lead</t></si><si><t>Erika Wells</t></si><si><t>Leslie Hansen</t></si><si><t>Manager</t></si><si><t>Eduardo Ramirez</t></si>`;
704+
705+
this._tableData = `ref="A1:C11" totalsRowShown="0">
706+
<autoFilter ref="A1:C11"/><tableColumns count="3"><tableColumn id="1" name="JobTitle"/><tableColumn id="2" name="ID"/><tableColumn id="3" name="Name"/></tableColumns>`;
707+
708+
this._worksheetData = `<dimension ref="A1:C11"/>
709+
<sheetViews><sheetView tabSelected="1" workbookViewId="0"><pane xSplit="2" topLeftCell="C1" activePane="topRight" state="frozen"/></sheetView></sheetViews>
710+
<sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
711+
<cols><col min="1" max="1" width="50" customWidth="1"/><col min="2" max="2" width="50" customWidth="1"/><col min="3" max="3" width="50" customWidth="1"/></cols>
712+
<sheetData><row r="1"><c r="A1" t="s"><v>0</v></c><c r="B1" t="s"><v>1</v></c><c r="C1" t="s"><v>2</v></c></row><row r="2"><c r="A2" t="s"><v>3</v></c><c r="B2" s="1"><v>1</v></c><c r="C2" t="s"><v>4</v></c></row><row r="3"><c r="A3" t="s"><v>5</v></c><c r="B3" s="1"><v>2</v></c><c r="C3" t="s"><v>6</v></c></row><row r="4"><c r="A4" t="s"><v>5</v></c><c r="B4" s="1"><v>3</v></c><c r="C4" t="s"><v>7</v></c></row><row r="5"><c r="A5" t="s"><v>8</v></c><c r="B5" s="1"><v>4</v></c><c r="C5" t="s"><v>9</v></c></row><row r="6"><c r="A6" t="s"><v>10</v></c><c r="B6" s="1"><v>5</v></c><c r="C6" t="s"><v>11</v></c></row><row r="7"><c r="A7" t="s"><v>12</v></c><c r="B7" s="1"><v>6</v></c><c r="C7" t="s"><v>13</v></c></row><row r="8"><c r="A8" t="s"><v>14</v></c><c r="B8" s="1"><v>7</v></c><c r="C8" t="s"><v>15</v></c></row><row r="9"><c r="A9" t="s"><v>16</v></c><c r="B9" s="1"><v>8</v></c><c r="C9" t="s"><v>17</v></c></row><row r="10"><c r="A10" t="s"><v>14</v></c><c r="B10" s="1"><v>9</v></c><c r="C10" t="s"><v>18</v></c></row><row r="11"><c r="A11" t="s"><v>19</v></c><c r="B11" s="1"><v>10</v></c><c r="C11" t="s"><v>20</v></c></row></sheetData>`;
713+
714+
return this.createData();
715+
}
716+
702717
get treeGridData() {
703718
this._sharedStringsData =
704719
`count="21" uniqueCount="19"><si><t>ID</t></si><si><t>ParentID</t></si><si><t>Name</t></si><si><t>JobTitle</t></si><si><t>Age</t></si><si><t>Casey Houston</t></si><si><t>Vice President</t></si><si><t>Gilberto Todd</t></si><si><t>Director</t></si><si><t>Tanya Bennett</t></si><si><t>Debra Morton</t></si><si><t>Associate Software Developer</t></si><si><t>Jack Simon</t></si><si><t>Software Developer</t></si><si><t>Erma Walsh</t></si><si><t>CEO</t></si><si><t>Eduardo Ramirez</t></si><si><t>Manager</t></si><si><t>Leslie Hansen</t></si>`;

projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export abstract class IgxBaseExporter {
140140
}
141141

142142
if (column.pinned && exportColumn) {
143-
this._indexOfLastPinnedColumn = index;
143+
this._indexOfLastPinnedColumn++;
144144
}
145145
});
146146

0 commit comments

Comments
 (0)