Skip to content

test: add ConnectorFields component tests#2103

Open
techmannih wants to merge 2 commits into
asyncapi:masterfrom
techmannih:test/add-connector-fields-tests
Open

test: add ConnectorFields component tests#2103
techmannih wants to merge 2 commits into
asyncapi:masterfrom
techmannih:test/add-connector-fields-tests

Conversation

@techmannih
Copy link
Copy Markdown

@techmannih techmannih commented May 25, 2026

Description

Adds component test coverage for the Java Quarkus WebSocket template ConnectorFields component.

The new tests verify that the component renders the injected WebSocketConnector field in all cases and only renders the @ConfigProperty base URI field when query parameters are present.

Closes #2014

Validation

  • npm test from packages/templates/clients/websocket/java/quarkus

Summary by CodeRabbit

  • Tests
    • Added an integration test suite for the ConnectorFields React component that validates rendering across four query-parameter scenarios (null, omitted/undefined, empty array, and a populated derived array). The suite precomputes query parameters once and uses snapshot comparisons to ensure consistent output across these cases.

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 25, 2026

⚠️ No Changeset found

Latest commit: fe77fad

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a6ad7568-441b-47df-8793-ffd7049934e5

📥 Commits

Reviewing files that changed from the base of the PR and between 4b53ff5 and fe77fad.

📒 Files selected for processing (1)
  • packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js

📝 Walkthrough

Walkthrough

Adds an integration test suite for the ConnectorFields component that parses an AsyncAPI websocket fixture, derives channel query parameters, and snapshot-tests rendering for four scenarios: null, omitted/undefined, empty array, and a populated derived array.

Changes

ConnectorFields Component Test

Layer / File(s) Summary
Parse fixture and derive query parameters
packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js
Instantiate AsyncAPI Parser, load websocket fixture, extract document.channels, and derive queryParamsArray via generator helper (array or null).
Snapshot tests for ConnectorFields rendering
packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js
Four snapshot tests render ConnectorFields with queryParamsArray={null}, omitted/undefined, an empty array, and a populated derived array (the populated case asserts array is non-empty before snapshot).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add ConnectorFields component tests' follows Conventional Commits guidelines, uses imperative mood, and directly summarizes the main change in the pull request.
Linked Issues check ✅ Passed The code changes fully address all objectives from #2014: adds tests for WebSocketConnector @Inject field generation and conditional @ConfigProperty rendering based on query parameters presence.
Out of Scope Changes check ✅ Passed All changes are focused on adding component tests for ConnectorFields, directly addressing issue #2014 requirements without introducing unrelated modifications.
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 unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@asyncapi-bot
Copy link
Copy Markdown
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.

@techmannih techmannih marked this pull request as ready for review May 25, 2026 03:29
@techmannih techmannih changed the title Add ConnectorFields component tests test: add ConnectorFields component tests May 25, 2026
Copy link
Copy Markdown

@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)
packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js (1)

15-60: ⚡ Quick win

Add JSDoc for test/beforeAll function callbacks to match repository JS documentation rules.

The callbacks introduced on Line 15 and Lines 24/34/43/53 are functions without JSDoc. Please document params/returns/error behavior consistently for this JS file.

As per coding guidelines, "**/*.{js,ts,jsx,tsx}: Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js`
around lines 15 - 60, Add JSDoc comments for the asynchronous beforeAll callback
and each test callback in ConnectorFields.test.js: document the parameters (none
for these callbacks), the return type (Promise<void> for the async beforeAll,
void for sync tests), and any error behavior thrown by parsing/rendering (e.g.,
may throw if parsing fails); place the JSDoc immediately above the
beforeAll(...) block and each test('...', () => {...}) callback to satisfy the
repository's JS documentation rules and make it clear what each callback returns
and what errors it may propagate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js`:
- Around line 53-60: Add an explicit precondition assertion that the fixture
actually contains data before exercising the "with base URI" branch: before
rendering ConnectorFields in the test (the test function named 'renders
connector field with base URI config when queryParamsArray has data from
fixture'), assert that queryParamsArray is non-empty (e.g., check
queryParamsArray.length > 0 or expect(queryParamsArray).not.toHaveLength(0)) so
the test will fail if the fixture changes and will reliably exercise the
base-URI conditional.

---

Nitpick comments:
In
`@packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js`:
- Around line 15-60: Add JSDoc comments for the asynchronous beforeAll callback
and each test callback in ConnectorFields.test.js: document the parameters (none
for these callbacks), the return type (Promise<void> for the async beforeAll,
void for sync tests), and any error behavior thrown by parsing/rendering (e.g.,
may throw if parsing fails); place the JSDoc immediately above the
beforeAll(...) block and each test('...', () => {...}) callback to satisfy the
repository's JS documentation rules and make it clear what each callback returns
and what errors it may propagate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8b8bc5f9-1f8f-4d2e-b7d1-77999f32cd0b

📥 Commits

Reviewing files that changed from the base of the PR and between 917a555 and 4b53ff5.

⛔ Files ignored due to path filters (1)
  • packages/templates/clients/websocket/java/quarkus/test/components/__snapshots__/ConnectorFields.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • packages/templates/clients/websocket/java/quarkus/test/components/ConnectorFields.test.js

@sonarqubecloud
Copy link
Copy Markdown

@techmannih
Copy link
Copy Markdown
Author

@Adi-204 can you check this pr now

Comment on lines +20 to +21
const queryParams = getQueryParams(channels);
queryParamsArray = queryParams ? Array.from(queryParams.entries()) : null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@techmannih beforeAll parses the file and computes queryParamsArray for all 4 tests, but the first 3 ignore it entirely they use hardcoded null, undefined, and []. So I think we can do better and just move this code in last testcase where it actually uses it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] Add component tests for ConnectorFields.js (Java WebSocket Template)

3 participants