Skip to content

Conversation

@rafalmaksymiuk
Copy link
Contributor

@rafalmaksymiuk rafalmaksymiuk commented Aug 11, 2025

Created thin wrapper over withRouter that respects routerDisabled prop and is transparent wrapper if it is set to true.

Summary by CodeRabbit

  • New Features

    • Added a routing wrapper that conditionally injects router props and can be disabled via a prop or feature flag.
  • Refactor

    • Updated sidebar, versions, and task-button components to use the conditional router wrapper and treat router history as optional for safer operation when routing is disabled.
  • Tests

    • Added tests for router enabled, disabled via prop, and disabled via feature flag.

@rafalmaksymiuk rafalmaksymiuk requested review from a team as code owners August 11, 2025 14:26
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

Walkthrough

Adds a conditional HOC withRouterIfEnabled, re-exports it, switches several sidebar components to use it (making history optional and guarding navigation calls), and adds unit tests covering router-enabled, prop-disabled, and feature-flag-disabled scenarios.

Changes

Cohort / File(s) Summary of changes
Routing HOC & exports
src/elements/common/routing/withRouterIfEnabled.js, src/elements/common/routing/index.js
New default-export HOC withRouterIfEnabled that conditionally applies withRouter based on props.routerDisabled or features.routerDisabled.value; added // @flow and re-exported from routing index.
Component wrappers updated
src/elements/content-sidebar/AddTaskButton.js, src/elements/content-sidebar/SidebarToggle.js, src/elements/content-sidebar/versions/VersionsSidebarContainer.js
Replaced withRouter(...) with withRouterIfEnabled(...); made history prop optional and guarded history.replace/history.push calls behind existence checks; adjusted imports to use withRouterIfEnabled.
Tests
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js
New unit tests validating default router-enabled behavior, router disabled via prop, and router disabled via feature flag; tests assert presence/absence of injected history/location/match and data-router-disabled.

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant HOC as withRouterIfEnabled
  participant Flags as isFeatureEnabled
  participant Router as react-router withRouter
  participant C as WrappedComponent

  App->>HOC: Render(WrappedComponent, props)
  HOC->>Flags: check props.features for "routerDisabled.value"
  alt router disabled (prop or feature)
    HOC->>C: Render original component with props (no router injection)
  else router enabled
    HOC->>Router: wrap component => WrappedWithRouter
    HOC->>WrappedWithRouter: Render (injected history/location/match)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • jankowiakdawid
  • greg-in-a-box

Poem

I hop through routes both near and far,
Sometimes wrapped tight, sometimes free as a star.
A flag or prop whispers "stay" or "go",
I nudge the paths and make the logic flow.
Rabbit tests pass — hooray! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (4)
src/elements/common/routing/withRouterIfEnabled.js (2)

17-21: Hoist non-React statics from Wrapped

The outer HOC doesn’t hoist statics (defaultProps, static methods, etc.). react-router’s withRouter hoists them; your wrapper should, too, to avoid regressions where consumers read statics off the exported component.

Suggested change:

 import * as React from 'react';
 import { withRouter } from 'react-router-dom';
 import { isFeatureEnabled } from '../feature-checking';
+import hoistNonReactStatics from 'hoist-non-react-statics';

 export default function withRouterIfEnabled(Wrapped: React.ComponentType<any>) {
     const WrappedWithRouter = withRouter(Wrapped);

     const WithRouterIfEnabled = (props: any) => {
         const routerDisabled =
             props?.routerDisabled === true || isFeatureEnabled(props?.features, 'routerDisabled.value');

         const Component = routerDisabled ? Wrapped : WrappedWithRouter;
         return <Component {...props} />;
     };

     const name = Wrapped.displayName || Wrapped.name || 'Component';
     WithRouterIfEnabled.displayName = `withRouterIfEnabled(${name})`;
+    hoistNonReactStatics(WithRouterIfEnabled, Wrapped);

     return WithRouterIfEnabled;
 }

6-6: Optional: tighten types with generics

If you want Flow to preserve prop types through the HOC, you can add a generic:

export default function withRouterIfEnabled<T: {}>(
    Wrapped: React.ComponentType<T>,
): React.ComponentType<T & { routerDisabled?: boolean, features?: mixed }> { ... }

This is optional, but helps catch prop mistakes at compile time.

src/elements/content-sidebar/versions/VersionsSidebarContainer.js (1)

353-353: Consider marking history/match as optional in Props

Under routerDisabled, withRouterIfEnabled won’t inject router props. The implementation already guards usage, but Flow types still require history and match. Consider:

type Props = {
-    history: RouterHistory,
+    history?: RouterHistory,
-    match: Match,
+    match?: Match,
    ...
}

This better reflects runtime and avoids misleading type requirements.

src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1)

52-63: Feature-flag disable test LGTM; consider adding displayName/static hoisting checks

Optionally add:

  • displayName assertion: expect(WithRouterIfEnabled.displayName).toBe('withRouterIfEnabled(TestComponent)')
  • If you adopt static hoisting, a test that a static property on TestComponent is visible on WithRouterIfEnabled.

These would guard future regressions in the HOC wrapper behavior.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da932f1 and 875194d.

📒 Files selected for processing (6)
  • src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1 hunks)
  • src/elements/common/routing/index.js (1 hunks)
  • src/elements/common/routing/withRouterIfEnabled.js (1 hunks)
  • src/elements/content-sidebar/AddTaskButton.js (2 hunks)
  • src/elements/content-sidebar/SidebarToggle.js (2 hunks)
  • src/elements/content-sidebar/versions/VersionsSidebarContainer.js (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-06-11T16:30:10.431Z
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: `VersionSidebarView` intentionally uses the `versionId` field to stay consistent with current URL parameter naming; a potential rename to `fileVersionId` is deferred until React Router is removed.

Applied to files:

  • src/elements/content-sidebar/versions/VersionsSidebarContainer.js
📚 Learning: 2025-06-17T13:30:02.172Z
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.

Applied to files:

  • src/elements/content-sidebar/versions/VersionsSidebarContainer.js
🧬 Code Graph Analysis (5)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1)
src/elements/common/routing/withRouterIfEnabled.js (2)
  • WithRouterIfEnabled (9-15)
  • withRouterIfEnabled (6-21)
src/elements/content-sidebar/AddTaskButton.js (1)
src/elements/common/routing/withRouterIfEnabled.js (1)
  • withRouterIfEnabled (6-21)
src/elements/content-sidebar/versions/VersionsSidebarContainer.js (1)
src/elements/common/routing/withRouterIfEnabled.js (1)
  • withRouterIfEnabled (6-21)
src/elements/common/routing/withRouterIfEnabled.js (1)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1)
  • WithRouterIfEnabled (23-23)
src/elements/content-sidebar/SidebarToggle.js (1)
src/elements/common/routing/withRouterIfEnabled.js (1)
  • withRouterIfEnabled (6-21)
🪛 Biome (2.1.2)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js

[error] 8-8: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

src/elements/content-sidebar/AddTaskButton.js

[error] 3-3: 'import { type x ident }' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

src/elements/common/routing/withRouterIfEnabled.js

[error] 6-6: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)


[error] 9-9: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

src/elements/content-sidebar/SidebarToggle.js

[error] 8-8: 'import { type x ident }' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (12)
src/elements/common/routing/withRouterIfEnabled.js (3)

13-15: Heads-up: toggling routerDisabled remounts the wrapped component

Switching between Wrapped and WrappedWithRouter changes the element type and will unmount/remount the child, losing its local state. If routerDisabled can change at runtime (feature flag flips, prop updates), this is a UX risk.

  • If the flag is static per session, this is fine. Otherwise, consider a strategy that preserves instance identity or ensure the flag doesn’t change post-mount.

6-6: Flow syntax vs Biome errors

This file is Flow-typed (// @flow). Biome’s “TypeScript-only” parse errors are false positives. Prefer configuring Biome to understand Flow or exclude Flow files from Biome’s parser.

Examples to consider:

  • Configure Biome to ignore files with // @flow.
  • Or scope Biome to TS/JS without Flow in this folder.

No code changes required here.

Also applies to: 9-11


6-21: Overall HOC approach looks good

DisplayName is set, feature gate is consistent with existing patterns, and props are preserved.

src/elements/common/routing/index.js (1)

2-2: Public re-export LGTM

withRouterIfEnabled is correctly re-exported from the routing index.

src/elements/content-sidebar/SidebarToggle.js (2)

56-57: Wrapper swap LGTM

Default export now uses withRouterIfEnabled, matching the new pattern. Internals already branch on routerDisabled/history, so behavior remains correct.


8-9: Flow type import is correct; Biome warning is a false positive

import { type RouterHistory } from 'react-router-dom'; is valid Flow syntax. Please adjust Biome settings to handle Flow or exclude this file from Biome parsing to avoid “TypeScript-only” parse errors.

src/elements/content-sidebar/AddTaskButton.js (1)

3-4: Flow vs Biome configuration

The import { type RouterHistory } Flow syntax is valid. Please configure Biome to support Flow or exclude this file to avoid spurious parse errors.

src/elements/content-sidebar/versions/VersionsSidebarContainer.js (2)

353-353: Composition order looks correct

flow([withRouterIfEnabled, withAPIContext, withFeatureConsumer]) results in withFeatureConsumer being the outermost HOC, so features will be available to withRouterIfEnabled at render time. Good.


12-12: Verify route pattern compatibility with generatePath

history.push(generatePath(match.path, { ...match.params, versionId })) depends on match.path declaring :versionId? as optional. If versionId is undefined, generatePath will omit it only when the path param is optional.

Please confirm the route path uses an optional param for versionId.

src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (3)

25-39: Nice coverage for default-enabled behavior

Test validates injected router props in a Router context and absence of routerDisabled. Good.


41-50: Prop-based disable test LGTM

Correctly asserts no router props and routerDisabled flag presence.


8-8: Flow types in tests vs Biome

The props: any type annotation is Flow; Biome’s “TypeScript-only” parse error is a tooling issue. Please adjust Biome config or ignore Flow-typed test files.

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: 2

🧹 Nitpick comments (4)
src/elements/common/routing/withRouterIfEnabled.js (1)

6-8: Biome parse errors on Flow types — adjust linter config

Biome doesn’t parse Flow. Either ignore Flow-typed JS files in Biome or disable Biome lint for this path to avoid false parse errors on Flow annotations.

Suggested steps:

  • Add this file (or directory) to Biome’s ignore list or disable its linter for src/elements/common/routing/**.
  • Keep ESLint/Flow handling as before.

If helpful, I can draft a targeted Biome config update.

src/elements/content-sidebar/AddTaskButton.js (2)

1-5: Biome parse error on Flow imports — exclude or disable Biome for Flow JS

import { type ... } is Flow; Biome flags it as TS-only. Adjust Biome config to ignore/disable lint for Flow files.


48-60: Optional: add a test to cover router-disabled vs. history paths

A small unit test for handleClickMenuItem can assert:

  • when routerDisabled && internalSidebarNavigationHandler → handler is called;
  • else-if historyhistory.replace is called.
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1)

1-8: Biome parse error on Flow in tests — ignore Flow files in Biome

Tests use Flow (// @flow, props: any); Biome can’t parse them. Add test paths to Biome ignore or disable Biome lint for tests.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 875194d and 6311e90.

⛔ Files ignored due to path filters (1)
  • src/elements/content-sidebar/__tests__/__snapshots__/ActivitySidebar.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1 hunks)
  • src/elements/common/routing/withRouterIfEnabled.js (1 hunks)
  • src/elements/content-sidebar/AddTaskButton.js (4 hunks)
  • src/elements/content-sidebar/versions/VersionsSidebarContainer.js (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/elements/content-sidebar/versions/VersionsSidebarContainer.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-17T13:30:02.172Z
Learnt from: rafalmaksymiuk
PR: box/box-ui-elements#4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.

Applied to files:

  • src/elements/content-sidebar/AddTaskButton.js
🧬 Code Graph Analysis (3)
src/elements/content-sidebar/AddTaskButton.js (1)
src/elements/common/routing/withRouterIfEnabled.js (1)
  • withRouterIfEnabled (6-21)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1)
src/elements/common/routing/withRouterIfEnabled.js (2)
  • WithRouterIfEnabled (8-15)
  • withRouterIfEnabled (6-21)
src/elements/common/routing/withRouterIfEnabled.js (1)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (2)
  • WithRouterIfEnabled (21-21)
  • props (8-8)
🪛 Biome (2.1.2)
src/elements/content-sidebar/AddTaskButton.js

[error] 3-3: 'import { type x ident }' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

src/elements/common/routing/__tests__/withRouterIfEnabled.test.js

[error] 7-7: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

src/elements/common/routing/withRouterIfEnabled.js

[error] 6-6: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)


[error] 8-8: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (4)
src/elements/content-sidebar/AddTaskButton.js (2)

15-22: Good: history made optional to reflect conditional router injection

Aligns types with runtime when the router is disabled. Matches how SidebarToggle was handled.


58-60: Good: guard navigation behind history availability

Prevents errors when router is disabled and history is absent.

src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (2)

23-35: Good: verifies router injection when inside a Router

Solid positive-path coverage for default behavior.


37-54: Good: verifies both router-disabled paths (prop and feature flag)

Covers the two opt-out mechanisms.

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

♻️ Duplicate comments (1)
src/elements/common/routing/withRouterIfEnabled.js (1)

8-16: Resolved: Stable HOC identity (no HOC creation in render path)

Creating WrappedWithRouter outside the render path avoids remounts/state loss from new component identities each render. Good fix.

🧹 Nitpick comments (1)
src/elements/common/routing/withRouterIfEnabled.js (1)

11-13: Confirm feature flag key path 'routerDisabled.value'

Validate that isFeatureEnabled supports dotted paths and that this flag name is correct. If yes, consider extracting to a constant to avoid typos.

Suggested tweak:

-        const routerDisabled =
-            props?.routerDisabled === true || isFeatureEnabled(props?.features, 'routerDisabled.value');
+        const routerDisabledFlag = 'routerDisabled.value';
+        const routerDisabled =
+            props?.routerDisabled === true || isFeatureEnabled(props?.features, routerDisabledFlag);

Also ensure isFeatureEnabled safely handles undefined features and returns false rather than throwing.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6311e90 and 6e26448.

📒 Files selected for processing (1)
  • src/elements/common/routing/withRouterIfEnabled.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/elements/common/routing/withRouterIfEnabled.js (1)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (2)
  • WithRouterIfEnabled (21-21)
  • props (8-8)
🪛 Biome (2.1.2)
src/elements/common/routing/withRouterIfEnabled.js

[error] 6-6: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)


[error] 10-10: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Summary
  • GitHub Check: lint_test_build
🔇 Additional comments (1)
src/elements/common/routing/withRouterIfEnabled.js (1)

6-6: Biome parse errors: Flow type annotations flagged as “TypeScript-only”

This file is Flow-typed (// @flow), but Biome 2.1.2 doesn’t support Flow parsing. Adjust CI/lint config so Biome doesn’t parse Flow files (or this path), and rely on the Flow toolchain/ESLint for these files. Otherwise, convert to TS (out of scope for this PR).

Action options:

  • Exclude Flow files or this directory in Biome config (recommended).
  • Keep Flow and ensure the Babel/Flow toolchain strips types before Biome runs.
  • If you’re migrating to TS, convert in a follow-up PR.

Also applies to: 10-10

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

♻️ Duplicate comments (2)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (2)

56-56: Add a regression test to ensure no remount across re-renders (stable identity).

This catches the classic pitfall of creating the wrapped component inside render, which remounts every render. The current implementation defines WrappedWithRouter outside the render path, so this should pass; let’s lock it in.

Add this test at the end of the file:

test('does not remount across re-renders with unchanged props', () => {
    let mountCount = 0;

    const Stateful = () => {
        React.useEffect(() => {
            mountCount += 1;
        }, []);
        return <div data-testid="stateful" />;
    };

    const WrappedStateful = withRouterIfEnabled(Stateful);

    const { rerender } = render(
        <MemoryRouter>
            <WrappedStateful />
        </MemoryRouter>,
    );

    // Re-render with identical props; component should not remount
    rerender(
        <MemoryRouter>
            <WrappedStateful />
        </MemoryRouter>,
    );

    expect(mountCount).toBe(1);
});

1-1: Fix Biome parse error by removing Flow/TS annotations in a .js test (or convert to TS).

Biome flags the type annotation at Line 7 and won’t parse Flow. Since this is a .js test and types are non-essential here, drop the Flow directive and the inline type to unblock CI. Alternatively, migrate the file to TypeScript (.tsx) and adjust configs, but that’s heavier.

Apply this diff:

-// @flow
@@
-const TestComponent = (props: any) => {
+const TestComponent = props => {

Also applies to: 7-7

🧹 Nitpick comments (1)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1)

46-54: Optional: assert that routerDisabled is not leaked via feature-flag path.

Helps lock in the contract that the computed disable state is not forwarded as a prop.

Apply this diff:

     const component = getByTestId('test-component');
     expect(component).not.toHaveAttribute('data-has-history');
     expect(component).not.toHaveAttribute('data-has-location');
     expect(component).not.toHaveAttribute('data-has-match');
+    expect(component).not.toHaveAttribute('data-router-disabled');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77ab5d2 and 724d873.

📒 Files selected for processing (1)
  • src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (1)
src/elements/common/routing/withRouterIfEnabled.js (2)
  • WithRouterIfEnabled (10-17)
  • withRouterIfEnabled (6-23)
🪛 Biome (2.1.2)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js

[error] 7-7: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (2)
src/elements/common/routing/__tests__/withRouterIfEnabled.test.js (2)

23-35: LGTM: router-enabled scenario is covered well.

Verifies that history/location/match are injected when under a Router and not disabled. Clear and correct.


37-44: LGTM: prop-based disable path behaves correctly without a Router.

Good coverage for the routerDisabled prop path and absence of router props.

Copy link
Contributor

@jmalinna jmalinna left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tjuanitas tjuanitas left a comment

Choose a reason for hiding this comment

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

try to write new files in typescript

@mergify mergify bot merged commit f969170 into box:master Aug 14, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants