def test_app_wrap_priority(
    react_strict_mode: bool, compilable_app: tuple[App, Path], mocker
):
    """Test that the app wrap components are wrapped in the correct order.

    Args:
        react_strict_mode: Whether to use React Strict Mode.
        compilable_app: compilable_app fixture.
        mocker: pytest mocker object.
    """
    conf = rx.Config(app_name="testing", react_strict_mode=react_strict_mode)
    mocker.patch("reflex.config._get_config", return_value=conf)

    app, web_dir = compilable_app

    class Fragment1(Component):
        tag = "Fragment1"

        def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]:  # pyright: ignore [reportIncompatibleMethodOverride]
            return {(99, "Box"): rx.box()}

    class Fragment2(Component):
        tag = "Fragment2"

        def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]:  # pyright: ignore [reportIncompatibleMethodOverride]
            return {(50, "Text"): rx.text()}

    class Fragment3(Component):
        tag = "Fragment3"

        def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]:  # pyright: ignore [reportIncompatibleMethodOverride]
            return {(10, "Fragment2"): Fragment2.create()}

    def page():
        return Fragment1.create(Fragment3.create())

    app.add_page(page)
    app._compile()
    app_js_contents = (web_dir / "pages" / "_app.js").read_text()
    app_js_lines = [
        line.strip() for line in app_js_contents.splitlines() if line.strip()
    ]
    lines = "".join(app_js_lines)
    expected = (
        "function AppWrap({children}) {"
        "return ("
        + ("jsx(StrictMode,{}," if react_strict_mode else "")
        + "jsx(RadixThemesBox,{},"
        'jsx(RadixThemesText,{as:"p"},'
        "jsx(RadixThemesColorModeProvider,{},"
        "jsx(Fragment2,{},"
        "jsx(Fragment,{},"
        "jsx(MemoizedToastProvider,{},),"
        "jsx(Fragment,{},"
        "children"
        ",),),),),)" + (",)" if react_strict_mode else "")
    )
    assert expected in lines
Test that the app wrap components are wrapped in the correct order.

    Args:
        react_strict_mode: Whether to use React Strict Mode.
        compilable_app: compilable_app fixture.
        mocker: pytest mocker object.
    
tests/units/test_app.py