Skip to content

test(pdf-exporter): increase unit test coverage for pdf-exporter.ts#17079

Draft
Copilot wants to merge 7 commits intomasterfrom
copilot/increase-coverage-pdf-exporter-tests
Draft

test(pdf-exporter): increase unit test coverage for pdf-exporter.ts#17079
Copilot wants to merge 7 commits intomasterfrom
copilot/increase-coverage-pdf-exporter-tests

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

pdf-exporter.ts had several untested code branches. This PR adds pure unit tests and grid-based integration tests across new describe blocks targeting those paths.

New coverage areas

Pure unit tests (pdf-exporter.spec.ts)

  • GroupedRecord type — verified rendered as regular data rows (no special-case handling)
  • Summary record fall-throughdrawDataRow path when cellValue has none of label, value, or summaryResult properties; also null cellValue
  • Pagination with multi-level column headers — header redraw on page break when hasMultiColumnHeaders=true (lines 349–362), with and without borders
  • Pivot grid border optionsshowTableBorders=false exercises the else branches inside drawMultiLevelHeaders; also pivot pagination covering the hasMultiRowHeaders redraw path
  • Hierarchical grid edge cases:
    • Early return from drawHierarchicalChildren when all direct children are HeaderRecord
    • Page break before child table header draw
    • Page break during child table row iteration with multi-level headers (exercises the hasMultiColumnHeaders redraw branch at lines 785–793)
  • Pivot row dimension header filling — fills missing headers from RowHeader columns (lines 163–172) and falls back to field names (lines 175–178) when no matching columns exist
  • Tree grid mixed record typesDataRecord records nested inside a tree export receive indentation (via the isTreeGridExport flag)
  • Custom font success path — valid non-empty name+data enters the try block (lines 232–237); variants with and without a bold sub-font cover the conditional at lines 238–246

Grid-based integration tests (pdf-exporter-grid.spec.ts)

Following the same patterns used by the Excel/CSV exporter grid test suites, these tests use real Angular component fixtures to exercise deeper fallback paths in pivot and hierarchical grid handling:

  • Hierarchical grid with multi-column headers — parent MCH (IgxHierarchicalGridMultiColumnHeadersExportComponent) and child-island-only MCH (IgxHierarchicalGridMultiColumnHeaderIslandsExportComponent), both with and without expanded rows; exercises drawHierarchicalChildren with multi-level header redraws
  • Hierarchical grid edge cases — summaries in child grids (IgxHierarchicalGridSummariesExportComponent), empty data (IgxHierarchicalGridEmptyDataExportComponent), and missing child data key (IgxHierarchicalGridMissingChildDataExportComponent, exercises "owner not in _ownersMap" fallback)
  • Tree grid with summaries — fully expanded tree grid (IgxTreeGridSummariesKeyComponent)
  • Pivot grid hierarchical row dimensions — uses SALES_DATA with a 3-level hierarchical row configuration (mirroring the Excel exporter tests), covering the hasMultiRowHeaders=true path, row dimension header building (lines 144–178), and showTableBorders=false else branches in drawMultiLevelHeaders

All tests follow the existing pattern: direct IgxPdfExporterService instantiation, spy on ExportUtilities.saveBlobToFile, assert exportEnded emission.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Add 19 new pure unit tests targeting previously uncovered code paths in pdf-exporter.ts:

- GroupedRecord type export (lines covering isSummaryRecord check)
- Summary records with unrecognized/null cellValue format (drawDataRow fall-through)
- Pagination with multi-level column headers (header redraw on page break)
- Pivot grid with showTableBorders=false (else branches in drawMultiLevelHeaders)
- Pivot grid pagination triggering hasMultiRowHeaders redraw path
- drawHierarchicalChildren early return when all children are HeaderRecord
- Child table header/row page break scenarios
- Pivot grid row dimension headers filling from RowHeader cols and field names
- Tree grid with DataRecord records mixed in for indentation
- Custom font success path (valid name+data, with/without bold variant)"

Co-authored-by: ChronosSF <2188411+ChronosSF@users.noreply.github.com>
Agent-Logs-Url: https://github.com/IgniteUI/igniteui-angular/sessions/dff68fbc-0dd3-4b9b-b4a7-58418072e7c3
Copilot AI changed the title [WIP] Add unit tests for pdf-exporter to increase coverage test(pdf-exporter): increase unit test coverage for pdf-exporter.ts Mar 23, 2026
Copilot AI requested a review from ChronosSF March 23, 2026 13:59
@ChronosSF
Copy link
Member

@copilot, we are not increasing the coverage substantially. Looking at the coveralls report it seems we are missing lines handling pivot and hierarchical grids, especially fallback lines (see from comments). Can you check exporting tests (for excel / csv exporters) testing pivot/hierarchical grids to try and implement more testing scenarios. If you can you can try to get the lines that need covering from here: https://coveralls.io/builds/78400997/source?filename=projects%2Figniteui-angular%2Fgrids%2Fcore%2Fsrc%2Fservices%2Fpdf%2Fpdf-exporter.ts

Copy link
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot, we are not increasing the coverage substantially. Looking at the coveralls report it seems we are missing lines handling pivot and hierarchical grids, especially fallback l...

Added 17 new integration tests in pdf-exporter-grid.spec.ts (commit 876e444) that use real Angular components to cover the missing pivot and hierarchical grid paths:

Hierarchical Grid with Multi-Column Headers — exercises drawHierarchicalChildren with MCH in both parent and child islands, with and without expanded rows (IgxHierarchicalGridMultiColumnHeadersExportComponent, IgxHierarchicalGridMultiColumnHeaderIslandsExportComponent)

Hierarchical Grid Edge Cases — covers SummaryRecord handling in child grids (IgxHierarchicalGridSummariesExportComponent), empty data (IgxHierarchicalGridEmptyDataExportComponent), and missing child data key (IgxHierarchicalGridMissingChildDataExportComponent)

Tree Grid Summaries — expanded tree grid with summaries (IgxTreeGridSummariesKeyComponent)

Pivot Grid Hierarchical Row Dimensions — uses SALES_DATA with 3-level hierarchical rows (same setup as the Excel exporter tests at lines 1573–1644), covering the hasMultiRowHeaders=true path, row dimension header building (lines 144–178), and the showTableBorders=false else branches in drawMultiLevelHeaders

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • coveralls.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants