Skip to content

test: add tests for Installation README component#1945

Merged
asyncapi-bot merged 6 commits intoasyncapi:masterfrom
SHUBHANSHU602:test-installation-readme
Feb 11, 2026
Merged

test: add tests for Installation README component#1945
asyncapi-bot merged 6 commits intoasyncapi:masterfrom
SHUBHANSHU602:test-installation-readme

Conversation

@SHUBHANSHU602
Copy link
Contributor

@SHUBHANSHU602 SHUBHANSHU602 commented Feb 7, 2026

This PR adds unit test coverage for the README Installation component, which is a public-facing component rendered in generated documentation.

The component contains language-dependent logic (python vs javascript) but previously had no direct tests validating the rendered output.
Screenshot 2026-02-07 200312
Screenshot 2026-02-07 200413

Resolves #1904

Summary by CodeRabbit

  • Tests
    • Added tests for the Installation component: verifies JavaScript and Python renderings with snapshot comparisons, and a default rendering that asserts the presence of the "## Installation" heading, "Install dependencies" text, and the literal string "undefined".

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2026

⚠️ No Changeset found

Latest commit: 7caba63

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@asyncapi-bot
Copy link
Contributor

What reviewer looks at during PR review

The following are ideal points maintainers look for during review. Reviewing these points yourself beforehand can help streamline the review process and reduce time to merge.

  1. PR Title: Use a concise title that follows our Conventional Commits guidelines and clearly summarizes the change using imperative mood (it means spoken or written as if giving a command or instruction, like "add new helper for listing operations")

    Note - In Generator, prepend feat: or fix: in PR title only when PATCH/MINOR release must be triggered.

  2. PR Description: Clearly explain the issue being solved, summarize the changes made, and mention the related issue.

    Note - In Generator, we use Maintainers Work board to track progress. Ensure the PR Description includes Resolves #<issue-number> or Fixes #<issue-number> this will automatically close the linked issue when the PR is merged and helps automate the maintainers workflow.

  3. Documentation: Update the relevant Generator documentation to accurately reflect the changes introduced in the PR, ensuring users and contributors have up-to-date guidance.

  4. Comments and JSDoc: Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions, so others can easily understand and use the code.

  5. DRY Code: Ensure the code follows the Don't Repeat Yourself principle. Look out for duplicate logic that can be reused.

  6. Test Coverage: Ensure the new code is well-tested with meaningful test cases that pass consistently and cover all relevant edge cases.

  7. Commit History: Contributors should avoid force-pushing as much as possible. It makes it harder to track incremental changes and review the latest updates.

  8. Template Design Principles Alignment: While reviewing template-related changes in the packages/ directory, ensure they align with the Assumptions and Principles. If any principle feels outdated or no longer applicable, start a discussion these principles are meant to evolve with the project.

  9. Reduce Scope When Needed: If an issue or PR feels too large or complex, consider splitting it and creating follow-up issues. Smaller, focused PRs are easier to review and merge.

  10. Bot Comments: As reviewers, check that contributors have appropriately addressed comments or suggestions made by automated bots. If there are bot comments the reviewer disagrees with, react to them or mark them as resolved, so the review history remains clear and accurate.

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

Adds a new test suite file for the Installation component containing three tests: snapshot tests for JavaScript and Python installation commands, and a test for undefined language that asserts presence of "## Installation", "Install dependencies", and the string "undefined".

Changes

Cohort / File(s) Summary
Installation Component Tests
packages/components/test/components/Installation.test.js
Adds a new test file with three tests: snapshot tests for language="javascript" and language="python", and a test for language undefined verifying ## Installation, Install dependencies, and the literal string undefined.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add tests for Installation README component' follows Conventional Commits guidelines with the 'test:' prefix, uses imperative mood, and accurately summarizes the main change of adding unit tests for the Installation component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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.

Copy link

@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

🤖 Fix all issues with AI agents
In `@packages/components/test/components/Installation.test.js`:
- Around line 15-18: The test for the Installation component currently snapshots
output when language is undefined but doesn't assert intent; update the test to
explicitly assert expected behavior: in the Installation.test.js modify the test
for Rendering when language is undefined to add either
expect(result).not.toContain('undefined') if undefined should be rejected, or
expect(result).toContain('undefined') if that behavior is intentional, and
optionally adjust the component by adding a safe fallback in installCommands
lookup (e.g., use installCommands[language] ?? 'unknown' inside the Installation
component) so the test and component behavior match; locate references to
Installation, installCommands and the language prop to make the change.
🧹 Nitpick comments (2)
packages/components/test/components/Installation.test.js (2)

5-13: Consider adding at least one inline assertion alongside snapshots.

Snapshot tests are great for regression detection but don't communicate intent. A complementary assertion (e.g., expect(result).toContain('npm install') for JS, expect(result).toContain('pip install') for Python) would make failures self-explanatory and guard against snapshot updates that accidentally accept wrong output.

Example complementary assertions
   test('renders javascript installation command', () => {
     const result = render(<Installation language="javascript" />);
+    expect(result).toContain('npm install');
     expect(result.trim()).toMatchSnapshot();
   });
 
   test('renders python installation command', () => {
     const result = render(<Installation language="python" />);
+    expect(result).toContain('pip install');
     expect(result.trim()).toMatchSnapshot();
   });

4-19: Missing JSDoc comments on test suite.

Per the coding guidelines for **/*.{js,ts,jsx,tsx}, functions should include JSDoc comments. A brief top-level doc block describing what this suite covers would satisfy the guideline. As per coding guidelines, "Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions."

Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

@SHUBHANSHU602 left comment!


test('renders installation section when language is undefined', () => {
const result = render(<Installation />);
expect(result.trim()).toMatchSnapshot();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect(result.trim()).toMatchSnapshot();
expect(actual).toBe('');

Until we don't have proper error handling no need to match snapshot.

@Adi-204 Adi-204 self-assigned this Feb 7, 2026
@Adi-204 Adi-204 moved this to In Progress in Maintainers work Feb 7, 2026
Copy link

@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

🤖 Fix all issues with AI agents
In `@packages/components/test/components/Installation.test.js`:
- Line 19: Update the indentation of the inline comment "// Explicitly document
current behavior" in the Installation.test.js snippet from 2 spaces to 4 spaces
to satisfy the project's ESLint rules; locate the comment in the test file (the
line containing that exact comment) and replace the leading two spaces with four
so the file passes the pipeline.

Copy link
Member

@Adi-204 Adi-204 left a comment

Choose a reason for hiding this comment

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

@SHUBHANSHU602 did you read point 2 Note in the comment - #1945 (comment)

@SHUBHANSHU602
Copy link
Contributor Author

SHUBHANSHU602 commented Feb 9, 2026

@SHUBHANSHU602 did you read point 2 Note in the comment - #1945 (comment)

hey @Adi-204 if you talking about the issue number , I added it

@sonarqubecloud
Copy link

@Adi-204
Copy link
Member

Adi-204 commented Feb 11, 2026

/rtm

@asyncapi-bot asyncapi-bot merged commit 3d9534e into asyncapi:master Feb 11, 2026
14 of 15 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Maintainers work Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Test]:Add missing tests for Installation README components

3 participants