Skip to content

Conversation

@princerajpoot20
Copy link
Member

@princerajpoot20 princerajpoot20 commented Oct 28, 2025

Approach

  • Introduced a new buildToolsManual function, which is attached to the build script. This function combines the manual tools and automated tools.
  • With this change, any updates made to the manual file will now be visible in the temporary deployment preview provided by Netlify.
    This happens because the buildToolsManual function is triggered during the build process, and the new combined tools file reflects those changes.

Dev Testing Evidence

  • Changed a line in the manual file.
Screenshot 2025-11-03 at 10 01 33 PM
  • Ran the build command.
  • The changes were successfully reflected in the combined file, i.e., tools.json.
Screenshot 2025-11-03 at 10 02 38 PM
  • The changes are successfully reflected in the combined file. Below are the screenshots of the website to verify the changes.
Screenshot 2025-11-05 at 6 12 17 PM Screenshot 2025-11-05 at 6 07 30 PM

Related issue(s)
Resolves #2124

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Added a dedicated manual tools build step in the start workflow, exposed a manual build entry point, and introduced path constants for automated/manual/tools/tags.
  • Bug Fixes
    • Unified error handling and logging when consolidating automated and manual tool data to reduce failures.
  • Tests
    • Added tests for manual-build scenarios, consolidation integration, and related error cases.

@netlify
Copy link

netlify bot commented Oct 28, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d044328
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/690e2f7e65e9730008166267
😎 Deploy Preview https://deploy-preview-4511--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 project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Adds two functions to scripts/build-tools.ts — combineAutomatedAndManualTools and buildToolsManual — and updates exports. scripts/index.ts now calls buildToolsManual with explicit paths during the start workflow. Tests in tests/build-tools.test.ts added/updated to cover manual build and error cases.

Changes

Cohort / File(s) Summary
Tool build helpers
scripts/build-tools.ts
Adds combineAutomatedAndManualTools(automatedTools, manualTools, toolsPath, tagsPath) to wrap combineTools() with standardized error handling/logging; adds buildToolsManual(automatedToolsPath, manualToolsPath, toolsPath, tagsPath) which checks input existence, reads automated + manual data, delegates to the combine wrapper, writes outputs; updates export to export { buildTools, buildToolsManual }.
Workflow entry / orchestration
scripts/index.ts
Imports buildToolsManual; defines automatedToolsPath, manualToolsPath, toolsPath, tagsPath; adds a start workflow step to call buildToolsManual(...) to build tools data during orchestration.
Tests
tests/build-tools.test.ts
Imports buildToolsManual alongside buildTools; adds tests for successful manual build, error propagation when combine fails, and missing automated/manual file error cases; adjusts console.error mock.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Workflow as Start Workflow
    participant Index as scripts/index.ts
    participant BuildTools as scripts/build-tools.ts
    participant Combine as combineTools()

    Workflow->>Index: start()
    Index->>BuildTools: buildToolsManual(automatedPath, manualPath, toolsPath, tagsPath)
    BuildTools->>BuildTools: verify input files exist
    alt inputs present
        BuildTools->>BuildTools: read automated & manual data
        BuildTools->>Combine: combineAutomatedAndManualTools(automated, manual, toolsPath, tagsPath)
        Combine->>Combine: run combineTools + capture/log errors
        alt combine success
            BuildTools->>BuildTools: write tools and tags outputs
            BuildTools-->>Index: success
        else combine error
            BuildTools-->>Index: propagate error
        end
    else missing input
        BuildTools-->>Index: error (missing file)
    end
    Index->>Workflow: continue
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus:
    • correctness of error handling/logging in combineAutomatedAndManualTools
    • file-existence checks and I/O behavior in buildToolsManual
    • tests for failure modes and mocks

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • sambhavgupta0705
  • derberg
  • anshgoyalevil
  • akshatnema

Poem

🐰
I hopped through scripts with careful paws,
Merged manual maps with automated laws.
Logs in order, checks in tune,
Tools rebuilt beneath the moon.
— a rabbit, nibbling joy 🥕

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enabling tools view regeneration at build time through the new buildToolsManual function.
Linked Issues check ✅ Passed The implementation meets the requirements from issue #2124: buildToolsManual combines manual and automated tools without running the full rebuild script, enabling PR preview deployments to reflect manual tool changes.
Out of Scope Changes check ✅ Passed All changes are within scope: buildToolsManual function, integration into build workflow, and test coverage directly address issue #2124 without unrelated modifications.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@aeworxet aeworxet moved this to In Progress in Bounty Program Oct 28, 2025
@asyncapi-bot asyncapi-bot added the bounty AsyncAPI Bounty program related label label Oct 28, 2025
@aeworxet
Copy link
Contributor

@asyncapi/bounty_team

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Nov 3, 2025

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 42
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

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

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (445e7c1) to head (d044328).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #4511   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines          780       799   +19     
  Branches       144       146    +2     
=========================================
+ Hits           780       799   +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/build-tools.ts (1)

62-65: Enhance JSDoc to clarify usage.

The JSDoc could be more detailed to explain when to use this function versus buildTools, and that it requires a pre-existing automated tools file.

Consider expanding the documentation:

 /**
- * Builds tools manually by combining existing automated tools with manual tools.
- * This function is used to ensure that it reflects changes in tools-manual.json.
+ * Builds tools by combining pre-existing automated tools with manual tools.
+ * 
+ * This function is designed for regular builds where the automated tools file
+ * has already been generated by the GitHub workflow. Unlike buildTools, this
+ * does NOT fetch data from the GitHub API, making it suitable for frequent
+ * builds without exhausting API rate limits.
+ * 
+ * @param automatedToolsPath - Path to the pre-existing automated tools JSON file
+ * @param manualToolsPath - Path to the manual tools JSON file  
+ * @param toolsPath - Output path for the combined tools JSON file
+ * @param tagsPath - Output path for the tags JSON file
+ * @throws {Error} If required files are missing or combination fails
  */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9611f42 and 3f0a84d.

📒 Files selected for processing (2)
  • scripts/build-tools.ts (3 hunks)
  • scripts/index.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: asyncapi-bot
Repo: asyncapi/website PR: 0
File: :0-0
Timestamp: 2025-02-18T12:07:42.211Z
Learning: The following PR commands are supported in the asyncapi/website repository:
- `/please-take-a-look` or `/ptal`: Requests attention from reviewers who haven't reviewed the PR
- `/ready-to-merge` or `/rtm`: Triggers automerge when all conditions are met
- `/do-not-merge` or `/dnm`: Blocks automerge even if all conditions are met
- `/autoupdate` or `/au`: Adds autoupdate label to keep PR in sync with target branch
- `/update` or `/u`: One-time update of PR with latest changes from target branch
📚 Learning: 2024-11-01T12:49:32.805Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3136
File: scripts/tools/combine-tools.js:122-125
Timestamp: 2024-11-01T12:49:32.805Z
Learning: In `scripts/tools/combine-tools.js`, the existing URL parsing logic for `repoUrl` without additional error handling is acceptable and does not require changes.

Applied to files:

  • scripts/build-tools.ts
📚 Learning: 2024-11-01T09:35:23.912Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3101
File: scripts/build-rss.js:4-6
Timestamp: 2024-11-01T09:35:23.912Z
Learning: Converting `getAllPosts()` to asynchronous in `scripts/build-rss.js` causes the existing build system to fail.

Applied to files:

  • scripts/index.ts
📚 Learning: 2024-11-10T18:16:22.273Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3284
File: scripts/build-post-list.js:49-53
Timestamp: 2024-11-10T18:16:22.273Z
Learning: In `scripts/build-post-list.js`, the `walkDirectories` function depends on sequential execution because it mutates `resultObj`. Parallelizing the loop with `Promise.all` causes tests to fail.

Applied to files:

  • scripts/index.ts
📚 Learning: 2025-06-20T14:47:22.389Z
Learnt from: sagarkori143
Repo: asyncapi/website PR: 0
File: :0-0
Timestamp: 2025-06-20T14:47:22.389Z
Learning: The AsyncAPI website modularization PR uses Promise.allSettled for parallel execution of build tasks, which provides better performance and fault isolation compared to sequential execution.

Applied to files:

  • scripts/index.ts
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test NodeJS PR - macos-13
  • GitHub Check: Test NodeJS PR - windows-latest
🔇 Additional comments (6)
scripts/index.ts (3)

10-10: LGTM!

The import is correct and the function is properly utilized in the workflow.


14-17: LGTM!

The path constants are correctly defined and will be properly resolved relative to the script directory.


43-46: No issues found — code is correct.

The verification confirms that tools-automated.json exists in the repository (35706 bytes) and is tracked by git. The buildToolsManual function properly handles file reads with try-catch error handling, logging errors and re-throwing with descriptive messages. The implementation is sound and the file dependency is satisfied.

scripts/build-tools.ts (3)

12-32: LGTM!

The wrapper function provides consistent error handling and logging for tool combination operations. The approach of logging before re-throwing maintains proper error propagation while aiding debugging.


56-56: LGTM!

Using the wrapper function here ensures consistent error handling across both build paths (full rebuild vs. manual-only rebuild).


95-95: LGTM!

The export statement correctly exposes both build functions for use in other modules.

@princerajpoot20
Copy link
Member Author

Update: The implementation part is done. Will work on the coverage part next.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/build-tools.test.ts (1)

138-146: Remove redundant file write operation.

Line 141 writes to automatedToolsPath, but this file is already created and populated in the beforeAll hook (line 43). This write operation is unnecessary for testing the missing manual file scenario.

Apply this diff to simplify the test:

  it('should handle missing manual tools file error', async () => {
    const invalidManualPath = resolve(testDir, 'nonexistent-manual.json');

-   fs.writeFileSync(automatedToolsPath, JSON.stringify(mockConvertedData)); 
-
    await expect(
      buildToolsManual(automatedToolsPath, invalidManualPath, toolsPath, tagsPath)
    ).rejects.toThrow('Manual tools file not found');
  });
scripts/build-tools.ts (1)

62-89: Enhance JSDoc for consistency with buildTools documentation.

The JSDoc for buildToolsManual is minimal compared to buildTools (lines 34-47). For consistency and better maintainability, consider adding @param and @throws tags.

Apply this diff to enhance the documentation:

 /**
  * Builds tools manually by combining existing automated tools with manual tools.
  * This function is used to ensure that it reflects changes in tools-manual.json.
+ *
+ * @param automatedToolsPath - The file path from which the automated tools data is read.
+ * @param manualToolsPath - The file path from which the manual tools data is read.
+ * @param toolsPath - The file path where the combined tools data will be written.
+ * @param tagsPath - The file path where the tags data will be written.
+ * @throws {Error} If the automated or manual tools files are not found, or if an error occurs during the build process.
  */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f0a84d and 58405a7.

📒 Files selected for processing (2)
  • scripts/build-tools.ts (3 hunks)
  • tests/build-tools.test.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: asyncapi-bot
Repo: asyncapi/website PR: 0
File: :0-0
Timestamp: 2025-02-18T12:07:42.211Z
Learning: The following PR commands are supported in the asyncapi/website repository:
- `/please-take-a-look` or `/ptal`: Requests attention from reviewers who haven't reviewed the PR
- `/ready-to-merge` or `/rtm`: Triggers automerge when all conditions are met
- `/do-not-merge` or `/dnm`: Blocks automerge even if all conditions are met
- `/autoupdate` or `/au`: Adds autoupdate label to keep PR in sync with target branch
- `/update` or `/u`: One-time update of PR with latest changes from target branch
Learnt from: akshatnema
Repo: asyncapi/website PR: 3136
File: scripts/tools/combine-tools.js:122-125
Timestamp: 2024-11-01T12:49:32.805Z
Learning: In `scripts/tools/combine-tools.js`, the existing URL parsing logic for `repoUrl` without additional error handling is acceptable and does not require changes.
📚 Learning: 2024-11-01T12:49:32.805Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3136
File: scripts/tools/combine-tools.js:122-125
Timestamp: 2024-11-01T12:49:32.805Z
Learning: In `scripts/tools/combine-tools.js`, the existing URL parsing logic for `repoUrl` without additional error handling is acceptable and does not require changes.

Applied to files:

  • scripts/build-tools.ts
📚 Learning: 2024-11-29T19:42:31.175Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: scripts/tools/tools-object.js:93-98
Timestamp: 2024-11-29T19:42:31.175Z
Learning: In `scripts/tools/tools-object.js`, when validation fails in the `convertTools` function, errors should be thrown or rejected instead of only logging them, to ensure proper error propagation and handling.

Applied to files:

  • scripts/build-tools.ts
  • tests/build-tools.test.ts
📚 Learning: 2025-04-20T16:05:16.482Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3950
File: scripts/utils/check-locales.ts:122-129
Timestamp: 2025-04-20T16:05:16.482Z
Learning: In the AsyncAPI website project, Next.js throws errors at runtime when locale files are missing, making additional validation for missing files unnecessary in the check-locales script.

Applied to files:

  • scripts/build-tools.ts
📚 Learning: 2024-11-01T09:55:20.531Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3101
File: tests/build-rss.test.js:25-27
Timestamp: 2024-11-01T09:55:20.531Z
Learning: In `tests/build-rss.test.js`, replacing `jest.resetModules()` with `jest.resetAllMocks()` in the `afterEach()` block causes errors. It is necessary to use `jest.resetModules()` to reset the module registry between tests in this file.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-12-02T05:52:49.547Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: tests/helper/toolsObjectData.js:1-18
Timestamp: 2024-12-02T05:52:49.547Z
Learning: In `tests/helper/toolsObjectData.js`, using the hard-coded repository ID directly in the URL is acceptable when creating mock data for tests, as we are not asserting anything at `REPO_ID`.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2025-01-19T04:51:41.255Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3557
File: tests/fixtures/markdown/check-edit-links-data.js:3-11
Timestamp: 2025-01-19T04:51:41.255Z
Learning: In the AsyncAPI website repository, the test data in `tests/fixtures/markdown/check-edit-links-data.js` intentionally includes inconsistent paths (with and without 'docs' prefix) to verify the script's ability to normalize and handle ambiguous path structures.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-10T18:16:22.273Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3284
File: scripts/build-post-list.js:49-53
Timestamp: 2024-11-10T18:16:22.273Z
Learning: In `scripts/build-post-list.js`, the `walkDirectories` function depends on sequential execution because it mutates `resultObj`. Parallelizing the loop with `Promise.all` causes tests to fail.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-29T17:36:09.783Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3378
File: tests/markdown/check-markdown.test.js:133-138
Timestamp: 2024-11-29T17:36:09.783Z
Learning: When testing the 'main' function in 'check-markdown.test.js', it's acceptable to simply ensure it doesn't throw any errors, as the functions it calls are already tested elsewhere.

Applied to files:

  • tests/build-tools.test.ts
🧬 Code graph analysis (1)
scripts/build-tools.ts (3)
tests/fixtures/buildToolsData.ts (1)
  • manualTools (79-79)
scripts/tools/combine-tools.ts (1)
  • combineTools (230-230)
scripts/helpers/logger.ts (1)
  • logger (18-18)
🔇 Additional comments (9)
tests/build-tools.test.ts (5)

6-6: LGTM!

The import correctly adds buildToolsManual to support the new test cases below.


94-104: LGTM!

This test validates the happy path for buildToolsManual, ensuring it correctly combines existing automated and manual tool files into the expected output structure.


106-120: LGTM!

This test confirms that errors from combineTools are properly caught, wrapped with context, and propagated through the new combineAutomatedAndManualTools wrapper.


122-128: LGTM!

This test validates that buildToolsManual properly handles invalid directory paths and provides a clear error message.


130-136: LGTM!

This test confirms the file existence check for automatedToolsPath works correctly and throws a descriptive error when the file is missing.

scripts/build-tools.ts (4)

12-32: LGTM!

The combineAutomatedAndManualTools wrapper provides consistent error handling and logging for the combine operation. The JSDoc is clear and the implementation properly wraps errors with context.


56-56: LGTM!

Good refactor to use the new combineAutomatedAndManualTools wrapper for consistency.


73-84: LGTM!

The file existence checks provide clear error messages when required input files are missing, addressing the feedback from previous reviews. The implementation correctly reads and combines the tool data.


104-104: LGTM!

The export correctly exposes buildToolsManual alongside buildTools for use in the build pipeline.

@princerajpoot20
Copy link
Member Author

Hey @sambhavgupta0705, the PR is ready for review.

@princerajpoot20 princerajpoot20 changed the title feat: enable tools view regeneration on a build time feat: enable tools view regeneration at build time Nov 4, 2025
@sambhavgupta0705
Copy link
Member

@princerajpoot20 have a look at nitpick comments once
see if you can include them

@sambhavgupta0705
Copy link
Member

@princerajpoot20 can you please also add the UI preview of your local host

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/build-tools.test.ts (2)

94-104: Consider deeper assertions for the manual build test.

The test validates that categories exist but doesn't verify the actual content or structure of the combined tools. Consider asserting specific properties like tool counts, descriptions, or merged data to ensure the manual build properly combines both sources.

Example enhancement:

 expect(combinedToolsContent).toHaveProperty('Category1');
 expect(combinedToolsContent).toHaveProperty('Category2');
+expect(combinedToolsContent.Category1.description).toEqual(mockConvertedData.Category1.description);
+expect(combinedToolsContent.Category1.toolsList).toBeDefined();

106-120: Consider improving mock cleanup reliability.

The spy restoration at line 119 only executes if the test passes. If the assertion fails, the spy remains mocked for subsequent tests. While jest.clearAllMocks() in beforeEach may mitigate this, consider moving the restore to an afterEach block or using a try-finally pattern for more robust cleanup.

Alternative pattern:

 it('should handle combineTools error', async () => {
   mockedAxios.get.mockResolvedValue({ data: mockExtractData });

   const combineSpy = jest
     .spyOn(require('../scripts/tools/combine-tools'), 'combineTools')
     .mockRejectedValueOnce(new Error('Combine error'));

-  await expect(
-    buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath)
-  ).rejects.toThrow(
-    'An error occurred while building tools: An error occurred while combining tools: Combine error'
-  );
-
-  combineSpy.mockRestore();
+  try {
+    await expect(
+      buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath)
+    ).rejects.toThrow(
+      'An error occurred while building tools: An error occurred while combining tools: Combine error'
+    );
+  } finally {
+    combineSpy.mockRestore();
+  }
 });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58405a7 and f929fa5.

📒 Files selected for processing (2)
  • scripts/build-tools.ts (3 hunks)
  • tests/build-tools.test.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/build-tools.ts
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: asyncapi-bot
Repo: asyncapi/website PR: 0
File: :0-0
Timestamp: 2025-02-18T12:07:42.211Z
Learning: The following PR commands are supported in the asyncapi/website repository:
- `/please-take-a-look` or `/ptal`: Requests attention from reviewers who haven't reviewed the PR
- `/ready-to-merge` or `/rtm`: Triggers automerge when all conditions are met
- `/do-not-merge` or `/dnm`: Blocks automerge even if all conditions are met
- `/autoupdate` or `/au`: Adds autoupdate label to keep PR in sync with target branch
- `/update` or `/u`: One-time update of PR with latest changes from target branch
📚 Learning: 2024-11-01T09:55:20.531Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3101
File: tests/build-rss.test.js:25-27
Timestamp: 2024-11-01T09:55:20.531Z
Learning: In `tests/build-rss.test.js`, replacing `jest.resetModules()` with `jest.resetAllMocks()` in the `afterEach()` block causes errors. It is necessary to use `jest.resetModules()` to reset the module registry between tests in this file.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-12-02T05:52:49.547Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: tests/helper/toolsObjectData.js:1-18
Timestamp: 2024-12-02T05:52:49.547Z
Learning: In `tests/helper/toolsObjectData.js`, using the hard-coded repository ID directly in the URL is acceptable when creating mock data for tests, as we are not asserting anything at `REPO_ID`.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2025-01-19T04:51:41.255Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3557
File: tests/fixtures/markdown/check-edit-links-data.js:3-11
Timestamp: 2025-01-19T04:51:41.255Z
Learning: In the AsyncAPI website repository, the test data in `tests/fixtures/markdown/check-edit-links-data.js` intentionally includes inconsistent paths (with and without 'docs' prefix) to verify the script's ability to normalize and handle ambiguous path structures.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-10T18:16:22.273Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3284
File: scripts/build-post-list.js:49-53
Timestamp: 2024-11-10T18:16:22.273Z
Learning: In `scripts/build-post-list.js`, the `walkDirectories` function depends on sequential execution because it mutates `resultObj`. Parallelizing the loop with `Promise.all` causes tests to fail.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-29T19:42:31.175Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: scripts/tools/tools-object.js:93-98
Timestamp: 2024-11-29T19:42:31.175Z
Learning: In `scripts/tools/tools-object.js`, when validation fails in the `convertTools` function, errors should be thrown or rejected instead of only logging them, to ensure proper error propagation and handling.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-29T17:36:09.783Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3378
File: tests/markdown/check-markdown.test.js:133-138
Timestamp: 2024-11-29T17:36:09.783Z
Learning: When testing the 'main' function in 'check-markdown.test.js', it's acceptable to simply ensure it doesn't throw any errors, as the functions it calls are already tested elsewhere.

Applied to files:

  • tests/build-tools.test.ts
🧬 Code graph analysis (1)
tests/build-tools.test.ts (2)
tests/fixtures/buildToolsData.ts (3)
  • mockConvertedData (79-79)
  • manualTools (79-79)
  • mockExtractData (79-79)
scripts/build-tools.ts (2)
  • buildToolsManual (110-110)
  • buildTools (110-110)
🔇 Additional comments (1)
tests/build-tools.test.ts (1)

122-144: Excellent error handling coverage for buildToolsManual.

The three error tests comprehensively cover different failure scenarios:

  • General filesystem errors (non-existent parent directory)
  • Specific validation failure for missing automated tools
  • Specific validation failure for missing manual tools

This ensures the new function properly validates inputs and provides clear error messages.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/build-tools.test.ts (1)

94-150: Consider adding tests for additional edge cases.

While the current test coverage is solid, you might want to add tests for these scenarios to catch potential issues early:

  • Invalid JSON in automated or manual tools files (malformed data)
  • Empty objects or arrays in tool files
  • Corrupted file content

These would help ensure robust error handling across more failure modes.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f929fa5 and 30a39f4.

📒 Files selected for processing (1)
  • tests/build-tools.test.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: asyncapi-bot
Repo: asyncapi/website PR: 0
File: :0-0
Timestamp: 2025-02-18T12:07:42.211Z
Learning: The following PR commands are supported in the asyncapi/website repository:
- `/please-take-a-look` or `/ptal`: Requests attention from reviewers who haven't reviewed the PR
- `/ready-to-merge` or `/rtm`: Triggers automerge when all conditions are met
- `/do-not-merge` or `/dnm`: Blocks automerge even if all conditions are met
- `/autoupdate` or `/au`: Adds autoupdate label to keep PR in sync with target branch
- `/update` or `/u`: One-time update of PR with latest changes from target branch
Learnt from: akshatnema
Repo: asyncapi/website PR: 3136
File: scripts/tools/combine-tools.js:122-125
Timestamp: 2024-11-01T12:49:32.805Z
Learning: In `scripts/tools/combine-tools.js`, the existing URL parsing logic for `repoUrl` without additional error handling is acceptable and does not require changes.
📚 Learning: 2024-11-01T09:55:20.531Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3101
File: tests/build-rss.test.js:25-27
Timestamp: 2024-11-01T09:55:20.531Z
Learning: In `tests/build-rss.test.js`, replacing `jest.resetModules()` with `jest.resetAllMocks()` in the `afterEach()` block causes errors. It is necessary to use `jest.resetModules()` to reset the module registry between tests in this file.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-12-02T05:52:49.547Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: tests/helper/toolsObjectData.js:1-18
Timestamp: 2024-12-02T05:52:49.547Z
Learning: In `tests/helper/toolsObjectData.js`, using the hard-coded repository ID directly in the URL is acceptable when creating mock data for tests, as we are not asserting anything at `REPO_ID`.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2025-01-19T04:51:41.255Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3557
File: tests/fixtures/markdown/check-edit-links-data.js:3-11
Timestamp: 2025-01-19T04:51:41.255Z
Learning: In the AsyncAPI website repository, the test data in `tests/fixtures/markdown/check-edit-links-data.js` intentionally includes inconsistent paths (with and without 'docs' prefix) to verify the script's ability to normalize and handle ambiguous path structures.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-10T18:16:22.273Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3284
File: scripts/build-post-list.js:49-53
Timestamp: 2024-11-10T18:16:22.273Z
Learning: In `scripts/build-post-list.js`, the `walkDirectories` function depends on sequential execution because it mutates `resultObj`. Parallelizing the loop with `Promise.all` causes tests to fail.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-29T17:36:09.783Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3378
File: tests/markdown/check-markdown.test.js:133-138
Timestamp: 2024-11-29T17:36:09.783Z
Learning: When testing the 'main' function in 'check-markdown.test.js', it's acceptable to simply ensure it doesn't throw any errors, as the functions it calls are already tested elsewhere.

Applied to files:

  • tests/build-tools.test.ts
📚 Learning: 2024-11-29T19:42:31.175Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: scripts/tools/tools-object.js:93-98
Timestamp: 2024-11-29T19:42:31.175Z
Learning: In `scripts/tools/tools-object.js`, when validation fails in the `convertTools` function, errors should be thrown or rejected instead of only logging them, to ensure proper error propagation and handling.

Applied to files:

  • tests/build-tools.test.ts
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - macos-13
🔇 Additional comments (3)
tests/build-tools.test.ts (3)

94-108: LGTM! Well-structured test for the manual build flow.

The test properly validates the happy path for buildToolsManual, with clear setup, execution, and assertions covering the combined output structure.


128-150: No issues found—error messages correctly implemented.

All three error message assertions in the test file match the implementation:

  • Line 133 assertion matches line 93 of scripts/build-tools.ts
  • Line 141 assertion matches line 81 of scripts/build-tools.ts
  • Line 149 assertion matches line 85 of scripts/build-tools.ts

Jest's .toThrow() performs partial string matching, so the tests will pass correctly as written.


110-126: The spy implementation has a module resolution issue that requires verification.

The test uses jest.spyOn(require('../scripts/tools/combine-tools'), 'combineTools') to mock combineTools, but buildTools.ts imports it statically with ES6: import { combineTools } from './tools/combine-tools' at the top of the file. Without jest.mock('../scripts/tools/combine-tools') or jest.resetModules(), the spy on the dynamically required module won't intercept the call made by the statically imported module reference.

The error message format is correct and matches the expected wrapping behavior. However, verify that:

  1. The spy is actually intercepting the combineTools call, or
  2. Add jest.mock('../scripts/tools/combine-tools') at the top of the test file and adjust the spy accordingly, or
  3. Use jest.resetModules() in beforeEach() to ensure fresh module loading for each test

@princerajpoot20
Copy link
Member Author

@sambhavgupta0705 Done

Copy link
Member

@sambhavgupta0705 sambhavgupta0705 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sambhavgupta0705 sambhavgupta0705 merged commit cecd342 into asyncapi:master Nov 9, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Completed in Bounty Program Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bounty AsyncAPI Bounty program related label

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

Support tools view regeneration on a PR level for manual tools

4 participants