website
website copied to clipboard
feat: add tests for tool-object script
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.
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...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
β‘οΈ 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/
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.jsfile 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 thescripts/tools/tools-object.jsfile. - #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
convertToolsfunction.
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?
πͺ§ 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
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.
@akshatnema Applied the suggestions
@akshatnema applied suggestions
@coderabbitai resolve
:white_check_mark: Actions performed
Comments resolved.
@coderabbitai full review
:white_check_mark: Actions performed
Full review triggered.
@akshatnema applied 3 nitpick comments from coderabbit
/rtm
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 π
@akshatnema can you re run the workflow?