Open
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
|
ronnyTodgers
requested changes
Dec 9, 2024
Collaborator
ronnyTodgers
left a comment
There was a problem hiding this comment.
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
-jspsdf@2.5.2
-jspdf-autotable@3.8.4
-react-ga4@2.1.0
-react@18.3.1
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