From 2b45e43e05046a78194869b59358acd19f7449dd Mon Sep 17 00:00:00 2001 From: sabril <5334504+saturninoabril@users.noreply.github.com> Date: Mon, 6 Apr 2026 11:04:56 +0800 Subject: [PATCH] MM-66627 (test): VH1-8 + EC Enzyme to RTL bulk migration (#35768) * (test): vh1-8+EC enzyme to rtl bulk migration * address comments --- .../src/components/CLAUDE.OPTIONAL.md | 1 + .../__snapshots__/textbox.test.tsx.snap | 638 +++------------- .../add_user_to_channel_modal.test.tsx.snap | 205 +++-- .../add_user_to_channel_modal.test.tsx | 307 +++++--- .../manage_teams_modal.test.tsx | 46 +- .../apps_form_field/apps_form_field.test.tsx | 61 +- .../audio_video_preview.test.tsx.snap | 77 +- .../audio_video_preview.test.tsx | 16 +- .../channel_invite_modal.test.tsx | 32 +- .../center_channel/center_channel.test.tsx | 37 +- .../channel_identifier_router.test.tsx | 43 +- .../__snapshots__/channel_view.test.tsx.snap | 178 +++-- .../channel_view/channel_view.test.tsx | 89 ++- .../with_use_get_usage_deltas.test.tsx.snap | 16 +- .../with_get_cloud_subscription.test.tsx | 9 +- .../cloud/with_use_get_usage_deltas.test.tsx | 7 +- .../data_prefetch/data_prefetch.test.tsx | 209 ++++-- .../interactive_dialog.test.tsx | 91 ++- .../invitation_modal/result_table.test.tsx | 49 +- .../latex_inline/latex_inline.test.tsx | 27 +- .../markdown_image_expand.test.tsx.snap | 56 +- .../markdown_image_expand.test.tsx | 25 +- .../modal_controller.test.tsx.snap | 30 +- .../modal_controller.test.tsx | 82 +- .../permalink_view.test.tsx.snap | 47 +- .../permalink_view/permalink_view.test.tsx | 25 +- .../embedded_binding.test.tsx.snap | 296 +++----- .../embedded_binding.test.tsx | 31 +- .../select_binding/select_binding.test.tsx | 75 +- .../__snapshots__/post_list.test.tsx.snap | 78 +- .../post_view/post_list/post_list.test.tsx | 370 ++++++--- .../__snapshots__/post_list_row.test.tsx.snap | 185 +++-- .../post_list_row/post_list_row.test.tsx | 88 ++- .../post_list_virtualized.test.tsx | 708 +++++++++++++----- .../product_notices.test.tsx | 88 +-- .../__snapshots__/rhs_thread.test.tsx.snap | 47 +- .../components/rhs_thread/rhs_thread.test.tsx | 44 +- .../command_provider.test.tsx.snap | 63 +- .../command_provider.test.tsx | 10 +- .../channels/src/components/textbox.test.tsx | 81 +- .../__snapshots__/thread_list.test.tsx.snap | 183 ++--- .../virtualized_thread_list.test.tsx.snap | 36 +- .../virtualized_thread_list_row.test.tsx.snap | 241 ++++-- .../thread_list/thread_list.test.tsx | 50 +- .../virtualized_thread_list.test.tsx | 27 +- .../virtualized_thread_list_row.test.tsx | 39 +- .../__snapshots__/thread_pane.test.tsx.snap | 94 +-- .../thread_pane/thread_pane.test.tsx | 70 +- .../__snapshots__/thread_viewer.test.tsx.snap | 54 +- .../thread_viewer/thread_viewer.test.tsx | 148 ++-- .../virtualized_thread_viewer.test.tsx | 132 ++-- .../unreads_status_handler.test.tsx | 184 +++-- .../group_member_list.test.tsx | 55 +- .../user_group_popover.test.tsx | 57 +- .../ad_ldap_upsell_banner.test.tsx | 22 +- ...menu_item_toggle_modal_redux.test.tsx.snap | 37 +- .../menu_item_toggle_modal_redux.test.tsx | 30 +- .../__snapshots__/submenu_modal.test.tsx.snap | 218 ++++-- .../submenu_modal/submenu_modal.test.tsx | 21 +- .../src/plugins/textbox/index.test.tsx | 32 +- .../src/tests/react_testing_utils.tsx | 23 + .../message_html_to_component.test.tsx.snap | 518 ++++++++----- .../utils/message_html_to_component.test.tsx | 104 ++- 63 files changed, 3818 insertions(+), 3124 deletions(-) diff --git a/webapp/channels/src/components/CLAUDE.OPTIONAL.md b/webapp/channels/src/components/CLAUDE.OPTIONAL.md index 3c36a25863f..c9cf6016e14 100644 --- a/webapp/channels/src/components/CLAUDE.OPTIONAL.md +++ b/webapp/channels/src/components/CLAUDE.OPTIONAL.md @@ -78,6 +78,7 @@ const intl = useIntl(); - Add/extend RTL tests alongside the component (`*.test.tsx`). See `../tests/react_testing_utils.tsx` for helpers. - Prefer `userEvent` and accessible queries (`getByRole`) over implementation-specific selectors. - Avoid snapshots; assert visible behavior instead. +- **Import Rule**: Never import directly from `@testing-library/react` or `react-dom/test-utils`. All testing utilities (`act`, `screen`, `fireEvent`, `waitFor`, `waitForElementToBeRemoved`, `userEvent`, `renderWithContext`, etc.) must be imported from `tests/react_testing_utils`, which re-exports everything from `@testing-library/react` alongside project-specific helpers. ## Icons - **Menu items and components should use Compass icon components** from `@mattermost/compass-icons/components` (e.g., ``), not raw `` elements. diff --git a/webapp/channels/src/components/__snapshots__/textbox.test.tsx.snap b/webapp/channels/src/components/__snapshots__/textbox.test.tsx.snap index e2795627527..bad50933627 100644 --- a/webapp/channels/src/components/__snapshots__/textbox.test.tsx.snap +++ b/webapp/channels/src/components/__snapshots__/textbox.test.tsx.snap @@ -1,578 +1,118 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`components/TextBox should match snapshot with additional, optional props 1`] = ` -
+
- +
+
+ some test text +
+
+
-
`; exports[`components/TextBox should match snapshot with required props 1`] = ` -
+
- +
+
+ some test text +
+
+
-
`; exports[`components/TextBox should throw error when new property is too long 1`] = ` -
+
- +
+
+ some test text that exceeds char limit +
+
+
-
`; exports[`components/TextBox should throw error when value is too long 1`] = ` -
+
- +
+
+ some test text that exceeds char limit +
+
+
-
`; diff --git a/webapp/channels/src/components/add_user_to_channel_modal/__snapshots__/add_user_to_channel_modal.test.tsx.snap b/webapp/channels/src/components/add_user_to_channel_modal/__snapshots__/add_user_to_channel_modal.test.tsx.snap index 10e7e90ee6e..cab7e8638dd 100644 --- a/webapp/channels/src/components/add_user_to_channel_modal/__snapshots__/add_user_to_channel_modal.test.tsx.snap +++ b/webapp/channels/src/components/add_user_to_channel_modal/__snapshots__/add_user_to_channel_modal.test.tsx.snap @@ -1,128 +1,97 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`components/AddUserToChannelModal should match snapshot 1`] = ` - -