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.
(
react_strict_mode: bool,
compilable_app: tuple[App, Path],
mocker: MockerFixture,
)
| 2848 | [True, False], |
| 2849 | ) |
| 2850 | def test_app_wrap_priority( |
| 2851 | react_strict_mode: bool, |
| 2852 | compilable_app: tuple[App, Path], |
| 2853 | mocker: MockerFixture, |
| 2854 | ): |
| 2855 | """Test that the app wrap components are wrapped in the correct order. |
| 2856 | |
| 2857 | Args: |
| 2858 | react_strict_mode: Whether to use React Strict Mode. |
| 2859 | compilable_app: compilable_app fixture. |
| 2860 | mocker: pytest mocker object. |
| 2861 | """ |
| 2862 | conf = rx.Config(app_name="testing", react_strict_mode=react_strict_mode) |
| 2863 | mocker.patch("reflex_base.config._get_config", return_value=conf) |
| 2864 | |
| 2865 | app, web_dir = compilable_app |
| 2866 | |
| 2867 | class Fragment1(Component): |
| 2868 | tag = "Fragment1" |
| 2869 | |
| 2870 | def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: # pyright: ignore [reportIncompatibleMethodOverride] |
| 2871 | return {(99, "Box"): rx.box()} |
| 2872 | |
| 2873 | class Fragment2(Component): |
| 2874 | tag = "Fragment2" |
| 2875 | |
| 2876 | def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: # pyright: ignore [reportIncompatibleMethodOverride] |
| 2877 | return {(50, "Text"): rx.text()} |
| 2878 | |
| 2879 | class Fragment3(Component): |
| 2880 | tag = "Fragment3" |
| 2881 | |
| 2882 | def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: # pyright: ignore [reportIncompatibleMethodOverride] |
| 2883 | return {(10, "Fragment2"): Fragment2.create()} |
| 2884 | |
| 2885 | def page(): |
| 2886 | return Fragment1.create(Fragment3.create()) |
| 2887 | |
| 2888 | app.add_page(page) |
| 2889 | app._compile() |
| 2890 | app_js_contents = ( |
| 2891 | web_dir / constants.Dirs.PAGES / constants.PageNames.APP_ROOT |
| 2892 | ).read_text() |
| 2893 | # AppWrap renders the priority-ordered chain inside its body. |
| 2894 | # ``addEvents`` is reached via module-level import so the events hook |
| 2895 | # block is empty. |
| 2896 | function_app_definition = app_js_contents[ |
| 2897 | app_js_contents.index("function AppWrap") : app_js_contents.index( |
| 2898 | "export function Layout" |
| 2899 | ) |
| 2900 | ].strip() |
| 2901 | error_boundary_tag = _find_error_boundary_memo_tag(function_app_definition) |
| 2902 | toast_provider_tag = _find_mirrored_memo_symbol( |
| 2903 | function_app_definition, "MemoizedToastProvider" |
| 2904 | ) |
| 2905 | overlay_tag = _find_mirrored_memo_symbol( |
| 2906 | function_app_definition, "DefaultOverlayComponents" |
| 2907 | ) |
nothing calls this directly
no test coverage detected