-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pdf export Functionality #38
base: master
Are you sure you want to change the base?
Conversation
…ns to allow pdf buttons
…ue to firebase related dependency
…tsOption to output pdf following the format of excels and created tests in ResultsOptions.test and testPdfExport.test and got full code coverage
👷 Deploy request for harmony-staging pending review.Visit the deploys page to approve it
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to specifically import 'jspdf-autotable' to enable the autotable.
But more importantly this proceedure totally ignores layout on the final PDF - so if there are long question strings you get a table with only the first column visible and the remaining columns off the page.
Works very well for short questions like the CES_D, not at all for long questions like the SCARED - can you make the layout more adaptable?
@vickyc2266 Can you tell me where you're facing the issue and why you have kept it open until now? |
Description
Changes attempts to create the PDF export function with this pull request. Updated package.json to include pdfkit dependencies along with other dependency version updates. Updated src/components/App.js to to include downloadPDF that follows the downloadExcel format for collecting inputs but outputs differently with a summary table and a match table into one document. Also updated src/components/ResultsOptions to include an ExportPDF Button. Updated the directory of setUpTests from utils to directly under src for the sake of testing. Also included testing files ResultsOptions.test and texPdfExport.
Fixes # (issue)
Resolves #53
Type of change
Please delete options that are not relevant.
Testing
To run tests, run in command line:
-npm install
-npm test
(with the assumption that all dependencies are locally updated)
ResultsOptions.test (Tests the UI interaction between user and component)
(Created a group of mock props that's supposed to represent various methods and data that ResultsOptions depends on)
testPdfExport.test (Tests the outputted format of document)
(beforeEach sets up new mockPDF instances for each test cases and afterEach clears all mock calls on data to prevent cross-test interference)
Test Configuration
This test configuration uses Jest as the primary testing framework with React Testing Library to simulate user interactions. Mocking tools like jspdf allow us to test PDF generation functionality without creating actual files, ensuring the methods like autoTable and text are called correctly. The environment is isolated through beforeEach and afterEach hooks, resetting state between tests. Additional dependencies like react-ga4 are mocked to validate analytics tracking. The tests achieve comprehensive coverage for both normal operation and edge cases, ensuring the ResultsOptions component and PDF generation logic behave as expected.
Library version:
[email protected]
[email protected]
[email protected]
[email protected]
OS:macOS Sequoia 15.0.1
Toolchain:
-Node.js 22.12.0
-npm: 10.9.0
-Webpack: 5.1.4
-TypeScript: 5.5.4
Checklist