Sitelet https://github.com/Chere3/Synapse/pull/6
Skip to content

Tests - #6

Draft
Chere3 wants to merge 13 commits into
devfrom
tests
Draft

Chere3 wants to merge 13 commits into
devfrom
tests

Conversation

@Chere3

@Chere3 Chere3 commented Apr 16, 2025

Copy link
Copy Markdown
Owner

This pull request introduces several changes to add testing capabilities, improve test coverage, and enhance the OCR utility functions. The most important changes include the addition of a GitHub Actions workflow for running tests and uploading coverage, modifications to the package.json to include testing scripts and dependencies, and the implementation of comprehensive tests for the OCR utility functions.

Testing and Coverage Enhancements:

  • .github/workflows/coverage.yml: Added a new GitHub Actions workflow to run tests and upload coverage results to Codecov. This includes steps for checking out the code, setting up Node, installing dependencies, running tests, and uploading the coverage results.

  • package.json: Updated to include new test scripts (test, test:watch, test:ci) and added several testing-related dependencies such as jest, @testing-library/react, and @types/jest. [1] [2]

  • jest.setup.js: Added setup for Jest, including mocking of TextEncoder, TextDecoder, and several DOM methods to facilitate testing in a Node.js environment.

OCR Utility Improvements:

  • utils/ocr.ts: Exported the convertPdfToImages function and improved error handling in the extractTextFromFile function to ensure that only instances of Error are thrown. [1] [2]

  • utils/ocr.test.ts: Implemented comprehensive tests for the OCR utility functions, including mocking of dependencies like tesseract.js and pdfjs-dist, and adding tests for various scenarios such as PDF to image conversion, text extraction from PDF and image files, and error handling.

@vercel

vercel Bot commented Apr 16, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
synapse ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 27, 2025 0:55am

@netlify

netlify Bot commented Apr 16, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for synapse-1 ready!

Name Link
🔨 Latest commit 843b764
🔍 Latest deploy log https://app.netlify.com/sites/synapse-1/deploys/680d804937a56d0008757ff2
😎 Deploy Preview https://deploy-preview-6--synapse-1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Chere3 Chere3 added this to Synapse Apr 16, 2025
@github-project-automation github-project-automation Bot moved this to Todo in Synapse Apr 16, 2025
@Chere3 Chere3 added the enhancement New feature or request label Apr 16, 2025
@Chere3 Chere3 self-assigned this Apr 16, 2025
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@Chere3
Chere3 requested a review from Copilot April 16, 2025 21:12

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.

Copilot reviewed 9 out of 13 changed files in this pull request and generated no comments.

Files not reviewed (4)
  • .direnv/flake-inputs/zd0x43g1jcav0xy0k6q9pdhy3bvif77n-source: Language not supported
  • .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa: Language not supported
  • flake.nix: Language not supported
  • package.json: Language not supported
Comments suppressed due to low confidence (1)

utils/ocr.test.ts:87

  • Deleting global.window in this test may affect subsequent tests. Consider saving the original global.window value before deletion and restoring it in an afterEach block.
delete (global as any).window

@Chere3
Chere3 marked this pull request as draft April 16, 2025 21:12
@Chere3 Chere3 moved this from Todo to In Progress in Synapse Apr 26, 2025
- Changed the test environment in jest.config.js to use 'jest-environment-jsdom'.
- Added a new script for test coverage in package.json.
- Updated pnpm-lock.yaml to include new dependencies for testing and coverage.
- Modified GitHub Actions workflow to streamline coverage reporting and use pnpm for dependency management.
Chere3 added 2 commits April 26, 2025 18:45
- Added a step in the GitHub Actions workflow to upload test coverage reports to Codecov.
- Configured the Codecov action to use the coverage/lcov.info file and included necessary parameters for token and flags.
…rage

- Modified the coverage.yml workflow to trigger on pushes and pull requests to the 'dev' branch instead of 'main'.
- Renamed the coverage job to build and updated the runner to ubuntu-22.04.
- Enhanced the workflow by using actions/checkout@v4 and actions/setup-node@v4.
- Added a step to install pnpm version 10 for dependency management.
- Streamlined the Node.js version configuration using a matrix strategy.
- Changed the packageManager field in package.json to allow for a range of pnpm versions.
- Enhanced the coverage.yml workflow by adding a token, flags, and a fail condition for the Codecov upload step.
- Updated the packageManager field in package.json to specify the exact pnpm version.
- Modified the coverage.yml workflow to install pnpm version 10.9.0 for consistency.

This branch was successfully deployed

1 active deployment
Preview — 843b7648 Deployed Apr 27, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants