website icon indicating copy to clipboard operation
website copied to clipboard

feat: add tests for tool-object script

Open vishvamsinh28 opened this issue 1 year ago β€’ 4 comments

This PR adds tests for tools-object.js script

Summary by CodeRabbit

  • New Features
    • Enhanced error handling for tool management functions, improving robustness.
    • Introduced comprehensive mock data for testing various tool scenarios.
  • Bug Fixes
    • Improved error logging and handling for invalid tool files and network issues.
  • Tests
    • Added extensive unit tests for tool object creation, data conversion, category assignment, and error handling.

vishvamsinh28 avatar Sep 30 '24 08:09 vishvamsinh28

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
Latest commit 9427070488543d208f85de90fd3c5f2fb2d0c64e
Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67547c0e3f1c89000876dfa8
Deploy Preview https://deploy-preview-3265--asyncapi-website.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.

netlify[bot] avatar Sep 30 '24 08:09 netlify[bot]

⚑️ Lighthouse report for the changes in this PR:

Category Score
πŸ”΄ Performance 37
🟒 Accessibility 98
🟒 Best practices 92
🟒 SEO 100
πŸ”΄ PWA 33

Lighthouse ran on https://deploy-preview-3265--asyncapi-website.netlify.app/

asyncapi-bot avatar Sep 30 '24 08:09 asyncapi-bot

Walkthrough

The pull request introduces enhancements to the scripts/tools/tools-object.js file, focusing on error handling and code formatting for the createToolObject and convertTools functions. It restructures the error management within convertTools, implementing a try-catch block to capture and log errors. Additionally, a comprehensive test suite is added in tests/tools/tools-object.test.js to validate the functionalities of these functions, including error handling scenarios. A new helper file, tests/helper/toolsObjectData.js, is also created to provide mock data structures for testing purposes.

Changes

File Path Change Summary
scripts/tools/tools-object.js Enhanced error handling in convertTools, standardized parameter formatting in createToolObject, and reformatted export statement for consistency.
tests/tools/tools-object.test.js Introduced a comprehensive suite of unit tests for convertTools and createToolObject, validating functionalities and error handling with Jest and Axios mocks.
tests/helper/toolsObjectData.js Added utility functions for generating mock data structures related to tools, including repository data and tool file content.

Possibly related PRs

  • #3297: This PR modifies the scripts/build-tools.js file to enhance file writing operations, which is directly related to the changes made in the main PR that also focuses on improving error handling and file operations in the scripts/tools/tools-object.js file.
  • #3422: This PR addresses file not found issues in the tests for both the build-tools and newsroom video scripts, which aligns with the main PR's focus on error handling and file operations in the convertTools function.

Suggested labels

ready-to-merge

Suggested reviewers

  • derberg
  • akshatnema
  • magicmatatjahu
  • sambhavgupta0705
  • Mayaleeeee
  • devilkiller-ag
  • anshgoyalevil
  • asyncapi-bot-eve

🐰 In the code, we hop and play,
With tools and tests, we pave the way.
Errors caught, like carrots in a patch,
Mock data ready, no need to scratch.
So let’s rejoice, with a joyful cheer,
For smoother coding, the end is near! πŸ₯•


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Oct 04 '24 05:10 coderabbitai[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 70.18%. Comparing base (170e72f) to head (9427070). Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3265      +/-   ##
==========================================
+ Coverage   67.77%   70.18%   +2.40%     
==========================================
  Files          21       21              
  Lines         664      664              
==========================================
+ Hits          450      466      +16     
+ Misses        214      198      -16     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 16 '24 13:10 codecov[bot]

@akshatnema Applied the suggestions

vishvamsinh28 avatar Nov 28 '24 16:11 vishvamsinh28

@akshatnema applied suggestions

vishvamsinh28 avatar Nov 29 '24 17:11 vishvamsinh28

@coderabbitai resolve

akshatnema avatar Dec 02 '24 05:12 akshatnema

:white_check_mark: Actions performed

Comments resolved.

coderabbitai[bot] avatar Dec 02 '24 05:12 coderabbitai[bot]

@coderabbitai full review

akshatnema avatar Dec 02 '24 05:12 akshatnema

:white_check_mark: Actions performed

Full review triggered.

coderabbitai[bot] avatar Dec 02 '24 05:12 coderabbitai[bot]

@akshatnema applied 3 nitpick comments from coderabbit

vishvamsinh28 avatar Dec 02 '24 06:12 vishvamsinh28

/rtm

akshatnema avatar Dec 07 '24 16:12 akshatnema

Hello, @akshatnema! πŸ‘‹πŸΌ This PR is not up to date with the base branch and can't be merged. Please update your branch manually with the latest version of the base branch. PRO-TIP: To request an update from the upstream branch, simply comment /u or /update and our bot will handle the update operation promptly.

       The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. Also the update will not work if your fork is located in an organization, not under your personal profile.
       Thanks πŸ˜„

asyncapi-bot avatar Dec 07 '24 16:12 asyncapi-bot

@akshatnema can you re run the workflow?

vishvamsinh28 avatar Dec 07 '24 16:12 vishvamsinh28