Skip to content
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

changed the local host URL #39

Closed
wants to merge 1 commit into from

Conversation

vickyc2266
Copy link

Description

Please include a summary of the change and which issue is fixed. Please also include relevant context. List any dependencies that are required for this change.

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.

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

Testing

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

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)

  • Test 'renders PDF export button' tests to ensure that the PDF Export button is present and renders correctly.
  • Test 'calls downloadPDF and tracks event when clicking export button' tests the ReactGA.event is called and downloadPDF function is invoked.
  • Test 'shows error toast when PDF export fails' tests that an error message is outputted to gracefully handle errors.

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 'should generate a PDF with match data' tests that the pdf is generated with correct structure and data
  • Test 'handles PDF generation errors' tests the handling of errors during PDF generating

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.

Test Configuration

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

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

Copy link

netlify bot commented Dec 8, 2024

👷 Deploy request for harmony-staging pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a9ee542

@vickyc2266 vickyc2266 closed this Dec 8, 2024
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.

1 participant