Skip to content

feat(pdf exporter): improved test coverage, hardened tests, and feature enhancements - #17639

Open
kdinev wants to merge 26 commits into
masterfrom
pdf-exporter-tests
Open

kdinev wants to merge 26 commits into
masterfrom
pdf-exporter-tests

Conversation

@kdinev

@kdinev kdinev commented Sep 17, 2026

Copy link
Copy Markdown
Member

Description

Improving test coverage and hardening the test verifications, by adding more tests and more deeper assertions.

Before:
image
image

After:
image
image

Enhancements:

Added background to the summary rows, so they don't blend with the data rows and are more distinguishable as footers.
Before:
image
After:
image

Added background to the row dimension headers on pivot export, so they are also distinguishable from the pure data rows.
Before:
image
After:
image

Added merging to the pivot dimension headers on pivot export, similar to the multi-column headers.
Before:
image
After:
image

Bug fix:

Failed custom font loading resulted in failed export. Now it falls back to helvetica. Also, custom font was set on root level and could break on parallel exports and was also being preserved for subsequent exports. Now the export instance carries its font with it.

Motivation / Context

Initial motivation was to harden the tests and to increase coverage. Through the tests development, I noticed areas for improvements, which are delighters but make a lot of difference.

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version: 22
  • Browser(s): Chrome/Edge
  • OS: Windows

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copilot AI lite review requested due to automatic review settings September 17, 2026 13:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

One or more issues must be addressed before approval.

Pull request overview

Adds extensive PDF exporter coverage and hardens column-group layout resolution against missing keys and recursive cycles.

Changes:

  • Adds PDF content, pagination, font, layout, and edge-case assertions.
  • Refactors tests to export prepared records directly.
  • Prevents recursive layout resolution for malformed column groups.
File summaries
File Description
projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts Updated as part of this pull request.
projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.spec.ts Updated as part of this pull request.
Review details
  • Files reviewed: 1/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 3/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter-utils.spec.ts Outdated
Comment thread projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.spec.ts Outdated
kdinev and others added 2 commits September 18, 2026 07:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts:977

  • A raw dimension value is considered resolved only when it is not undefined, and the fallback is entered whenever cellValue === null. Consequently, a pivot record whose dimension is explicitly null is replaced by a positional/header-derived value instead of rendering as an empty dimension cell. Track whether the raw record owns the dimension key and skip the fallback whenever it does, regardless of the stored value.
            const dimensionKey = rowDimensionFields[index];
            if (isPivotGrid && dimensionKey && record.rawData?.[dimensionKey] !== undefined) {
                cellValue = record.rawData[dimensionKey];
            }

            // Otherwise: get the value from row dimension columns' header property
            // The row dimension columns are created with header = actual dimension value to display
            if (cellValue === null && isPivotGrid && allColumns) {
  • Files reviewed: 3/4 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment thread projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts Outdated
Comment thread projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts Outdated
Comment thread projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter-utils.spec.ts Outdated
kdinev and others added 3 commits September 18, 2026 08:48
Removed unnecessary comments regarding sample test data and jsPDF behavior.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: kdinev <1472513+kdinev@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts:1125

  • The GRID_LEVEL_COL guard was removed here under the assumption that columns is always pre-filtered, but leafColumns is also synthesized from Object.keys(firstDataElement.data) when the owner has no usable columns (lines 206-219), and the base exporter can put GRID_LEVEL_COL into that data. In that fallback case this loop now exports the internal level field as a visible header/value (and drawTableHeaders receives the same unfiltered list), changing the PDF layout. Filter GRID_LEVEL_COL when synthesizing the fallback columns, or retain the guard in both header and row rendering paths.
        // Draw data columns - GRID_LEVEL_COL is already out of the list by now
        columns.forEach((col, index) => {
            const xPosition = xStart + rowDimensionOffset + (index * columnWidth);
            let cellValue = record.data[col.field];
  • Files reviewed: 3/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical and moderate issues can produce incorrect pivot row labels.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts:1153

  • When a pivot record's raw dimension value is explicitly null, line 1147 assigns null, but this condition immediately treats that as unresolved and falls through to the row-header/record-data heuristics. That can replace a genuinely blank dimension with a caption or another matching value, producing an incorrect exported row label. Track whether the raw-data key exists separately and skip these fallbacks whenever it exists, including when its value is null.
        if (cellValue === null && isPivotGrid && allColumns) {
  • Files reviewed: 4/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts Outdated
@kdinev

kdinev commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

@igdmdimitrov This PR is ready for review. I added more context in the description.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Pagination can omit pivot row-dimension headers on subsequent pages.

Review details

Suppressed comments (1)

projects/igniteui-angular/grids/core/src/services/pdf/pdf-exporter.ts:374

  • When a pivot has row-dimension headers but no multi-column/multi-row data headers, the initial page uses drawMultiLevelHeaders (the condition above), but subsequent pages enter this drawTableHeaders branch. That method receives leafColumns, which no longer contains PivotRowHeader columns, so it draws no row-dimension header text on page 2 and lays the data headers out with an offset for a missing cell. The new pagination test for pivot row-dimension headers will therefore fail (or produce inconsistent pages). Reuse the same multi-level header path on page breaks whenever the initial header path is selected, or pass the complete column list to the simple-header path.
                        this.drawTableHeaders(pdf, leafColumns, rowDimensionHeaders, margin, yPosition, columnWidth, headerHeight, usableWidth, options, fontNames);
  • Files reviewed: 4/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@kdinev kdinev changed the title Pdf exporter tests feat(pdf exporter): improved test coverage, hardened tests, and feature enhancements Sep 18, 2026
@kdinev kdinev added the ❌ status: awaiting-test PRs awaiting manual verification label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants