Skip to content

Conversation

@cindy-wg
Copy link

@cindy-wg cindy-wg commented May 5, 2025

Description

Implemented a PDF export feature next to the existing Excel export button that allows the user to download a PDF report of their harmonisation. The report shows an overall summary and the table of matches. The following files were changed or created:

  • src/components/HarmonyPDFExport.js (new file for the HarmonyPDFExporter class which generates the PDF)
  • src/components/HarmonyPDFExport.test.js (new testing file for the HarmonyPDFExporter class)
  • src/components/App.js (added downloadPDF flow that calls the PDF generation function)
  • src/components/ResultsOptions.js (added Export PDF button that calls the downloadPDF flow)
  • src/img/file-pdf-solid.svg (svg icon for the button)
  • package.json (added dependencies jspdf, jspdf-autotables, data-fns)

Fixes harmonydata/harmony#53

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

For testing, run the following commands in the command line:
npm install
npm test

HarmonyPDFExport.test.js: Jest mocks and unit tests which cover each method of the HarmonyPDFExporter class. These tests are automatically integrated into the test script, so they are run in addition to the existing tests.

  • Test 'generateReport: should render header, summary, matches table and return blob'
  • Test 'addSummarySection: should call autoTable with exactly the summary data'
  • Test 'addMatchesTable: should render matches correctly and attach a footer callback'

Test Configuration

  • Library version: jspdf@3.0.1, jspdf-autotable@5.0.2, date-fns@4.1.0, react@18.3.1
  • OS: macOS Ventura 13.5
  • Toolchain: Node.js v20.18.1, npm v10.8.2

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@netlify
Copy link

netlify bot commented May 5, 2025

👷 Deploy request for harmony-staging pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5c3fe1e

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.

Create PDF export function

4 participants