Skip to content

test(content-sidebar): convert Sidebar tests to React Testing Library - #4971

Open
rafalmaksymiuk wants to merge 2 commits into
box:masterfrom
rafalmaksymiuk:sidebar-tests-rtl
Open

rafalmaksymiuk wants to merge 2 commits into
box:masterfrom
rafalmaksymiuk:sidebar-tests-rtl

Conversation

@rafalmaksymiuk

@rafalmaksymiuk rafalmaksymiuk commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Converting Sidebar component tests to RTL before major component refactor.

Summary by CodeRabbit

  • Tests
    • Updated sidebar tests to validate behavior through the rendered interface, including navigation, location and file changes, forced-open state, panel selection, sidebar visibility, and feature-flag conditions.
    • Added checks that panel refreshes receive the expected properties and that dragging updates sidebar widths, respects the viewport-width limit, and records resize actions.

@rafalmaksymiuk
rafalmaksymiuk requested review from a team as code owners November 23, 2026 16:19
@mergify

mergify Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Sidebar test suite replaces Enzyme and direct component-instance access with shared Testing Library rendering. The tests use DOM assertions, rerendering, captured panel callbacks, and pointer events.

Changes

Sidebar test coverage

Layer / File(s) Summary
Shared renderer and rerender tests
src/elements/content-sidebar/__tests__/Sidebar.test.js
Tests use shared Testing Library utilities and a forwarded-ref SidebarPanels mock. Mount, file-change, and redirect cases use rendering and rerendering.
Panel, navigation, and refresh assertions
src/elements/content-sidebar/__tests__/Sidebar.test.js
Tests invoke callbacks through the mock and check panel props, rendered output, navigation, forced-open state, refresh behavior, and initial-panel behavior.
Pointer-driven resize tests
src/elements/content-sidebar/__tests__/Sidebar.test.js
Tests simulate resize-handle dragging and check handle visibility, resulting widths, maximum width, and resize-action records.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: mrscobbler, jmcbgaston, greg-in-a-box

Merge Risk: Minimal · up to 6e2a5

This change only updates tests and does not alter production behavior. No merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description is a single sentence stating the purpose: converting Sidebar component tests to RTL before a major component refactor. It conveys intent, but it does not follow the repository template… Expand the description to cover the specific changes: the move from Enzyme shallow rendering to React Testing Library, the new test utilities and mocks, the resize drag tests that use userEvent, and any tests whose coverage changed. Follow …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "test(content-sidebar): convert Sidebar tests to React Testing Library" matches the main change. The raw summary shows the Sidebar test file moving from Enzyme shallow rendering and instance…
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.
Full details: Title check

Explanation

The title "test(content-sidebar): convert Sidebar tests to React Testing Library" matches the main change. The raw summary shows the Sidebar test file moving from Enzyme shallow rendering and instance-method checks to React Testing Library rendering, DOM assertions, and user interactions. The title is concise, specific, and follows a conventional commit style.

Full details: Description check

Explanation

The description is a single sentence stating the purpose: converting Sidebar component tests to RTL before a major component refactor. It conveys intent, but it does not follow the repository template. It lacks the template's guidance on approvals and the ready-to-merge label, and it gives no detail on the test changes, such as the resize drag tests or the removal of Enzyme. The template's merge-process content is mostly process guidance, not required author input, so the gap is moderate.

Resolution

Expand the description to cover the specific changes: the move from Enzyme shallow rendering to React Testing Library, the new test utilities and mocks, the resize drag tests that use userEvent, and any tests whose coverage changed. Follow the repository description template's structure, and confirm the ready-to-merge process as the template describes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

I’m a rabbit, ears held high,
I watch the sidebar tests pass by.
A pointer drags; the widths are clear,
Callbacks show what happens here.
DOM assertions mark the way,
I nibble greens and hop away.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b222e443-f79e-40e3-ac3a-46381b752de4
Commits

Reviewing files that changed from the base of the PR and between 53d0613 and 6e2a596.

Files selected for processing: 1

  • src/elements/content-sidebar/__tests__/Sidebar.test.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

This branch has not been deployed

No deployments
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.

3 participants