Skip to content

test(Menubar): lazy mount menu content (#1847)#2083

Open
kotAPI wants to merge 2 commits into
mainfrom
test/issue-1847-menubar-lazy-mount
Open

test(Menubar): lazy mount menu content (#1847)#2083
kotAPI wants to merge 2 commits into
mainfrom
test/issue-1847-menubar-lazy-mount

Conversation

@kotAPI

@kotAPI kotAPI commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

assert menu content is not mounted until opened

Test plan

  • Related unit tests pass locally

Related to #1847

Summary by CodeRabbit

  • Tests
    • Added coverage for Menubar lazy-mount behavior.
    • Verified menu content is not rendered until the menu is opened, and appears after clicking the trigger.

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d7e97f6

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

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@kotAPI, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 54 minutes and 7 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e05ecaa7-052f-479b-9e5c-7c2ba4b80be5

📥 Commits

Reviewing files that changed from the base of the PR and between 691cc78 and d7e97f6.

📒 Files selected for processing (1)
  • src/components/ui/Menubar/tests/Menubar.lazyMount.test.tsx
📝 Walkthrough

Walkthrough

A new test file is added for the Menubar component that covers lazy-mount behavior. It contains two tests: one asserting menu content is absent from the DOM before the trigger is opened, and one asserting the "New" menu item appears after clicking the trigger via async userEvent.

Changes

Menubar Lazy Mount Tests

Layer / File(s) Summary
Lazy mount before/after interaction tests
src/components/ui/Menubar/tests/Menubar.lazyMount.test.tsx
Adds two RTL tests: one checks that menu content (data-testid and item text) is absent before trigger interaction; the other clicks the trigger with async userEvent and asserts the "New" item is present in the DOM.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

automerge

Suggested reviewers

  • mrkazmi333

Poem

🐇 Hop, hop, before the click —
No menu found, the DOM is slick!
A tap of the trigger, swift and true,
"New" appears in the rendered view.
Lazy mounting, tested right,
The rabbit cheers with pure delight! 🥕

🚥 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 clearly matches the main change: adding a Menubar test for lazy mounting of menu content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/issue-1847-menubar-lazy-mount

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@src/components/ui/Menubar/tests/Menubar.lazyMount.test.tsx`:
- Around line 41-42: The Menubar lazy-mount test is using a synchronous text
query immediately after opening the menu, which can race with delayed rendering.
Update the assertion in Menubar.lazyMount.test.tsx to use an async query after
the user.click interaction, and locate the change around the test that checks
the File menu and verifies “New” is shown by awaiting the rendered content.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef00d63e-14d2-4e1b-907b-3dfa83df7c9c

📥 Commits

Reviewing files that changed from the base of the PR and between 56746ce and 691cc78.

📒 Files selected for processing (1)
  • src/components/ui/Menubar/tests/Menubar.lazyMount.test.tsx

Comment on lines +41 to +42
await user.click(screen.getByText('File'));
expect(screen.getByText('New')).toBeInTheDocument();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Use async query after click to avoid timing flakes.

Menu content can render on a later tick; getByText here may be flaky in CI. Prefer findByText after the interaction.

Suggested change
-        await user.click(screen.getByText('File'));
-        expect(screen.getByText('New')).toBeInTheDocument();
+        await user.click(screen.getByText('File'));
+        expect(await screen.findByText('New')).toBeInTheDocument();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await user.click(screen.getByText('File'));
expect(screen.getByText('New')).toBeInTheDocument();
await user.click(screen.getByText('File'));
expect(await screen.findByText('New')).toBeInTheDocument();
🤖 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 `@src/components/ui/Menubar/tests/Menubar.lazyMount.test.tsx` around lines 41 -
42, The Menubar lazy-mount test is using a synchronous text query immediately
after opening the menu, which can race with delayed rendering. Update the
assertion in Menubar.lazyMount.test.tsx to use an async query after the
user.click interaction, and locate the change around the test that checks the
File menu and verifies “New” is shown by awaiting the rendered content.

Mock matchMedia and render under Theme for portal consistency.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

This report compares the PR with the base branch. "Δ" shows how the PR affects each metric.

Metric PR Δ
Statements 78.24% +0.04%
Branches 60.88% +0.03%
Functions 63.6% +0.09%
Lines 79.83% +0.04%

Coverage improved or stayed the same. Great job!

Run npm run coverage:ci locally for detailed reports and target untested areas to raise these numbers.

@kotAPI

kotAPI commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Code review

Reviewed and pushed follow-up fixes addressing handler composition, test patterns (rerender vs unmount), Theme/mockMatchMedia wrappers, and flaky focus assertions.

CI was green before fixes; please re-run checks on latest commit.

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.

1 participant